10 #include <linux/module.h>
11 #include <linux/slab.h>
33 struct buffer_head **bh)
103 revoke = (
wrap) ? (a || b) : (a &&
b);
113 while (!list_empty(head)) {
150 static int get_log_header(
struct gfs2_jdesc *jd,
unsigned int blk,
153 struct buffer_head *bh;
165 hash =
crc32_le(hash, (
unsigned char const *)¬hing,
sizeof(nothing));
167 error = gfs2_log_header_in(&lh, bh->b_data);
191 static int find_good_lh(
struct gfs2_jdesc *jd,
unsigned int *blk,
194 unsigned int orig_blk = *
blk;
198 error = get_log_header(jd, *blk, head);
205 if (*blk == orig_blk) {
233 error = get_log_header(jd, blk, &lh);
266 u32 blk_1, blk_2, blk_m;
273 blk_m = (blk_1 + blk_2) / 2;
275 error = find_good_lh(jd, &blk_1, &lh_1);
279 error = find_good_lh(jd, &blk_m, &lh_m);
283 if (blk_1 == blk_m || blk_m == blk_2)
292 error = jhead_scan(jd, &lh_1);
313 static int foreach_descriptor(
struct gfs2_jdesc *jd,
unsigned int start,
314 unsigned int end,
int pass)
317 struct buffer_head *bh;
323 offset +=
sizeof(
__be64) - 1;
324 offset &= ~(
sizeof(
__be64) - 1);
326 while (start != end) {
330 if (gfs2_meta_check(sdp, bh)) {
339 error = get_log_header(jd, start, &lh);
341 gfs2_replay_incr_blk(sdp, &start);
355 ptr = (
__be64 *)(bh->b_data + offset);
356 error = lops_scan_elements(jd, start, ld, ptr, pass);
363 gfs2_replay_incr_blk(sdp, &start);
388 struct buffer_head *bh;
390 struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 };
393 gfs2_replay_incr_blk(sdp, &lblock);
394 bh_map.b_size = 1 << ip->
i_inode.i_blkbits;
398 if (!bh_map.b_blocknr) {
403 bh = sb_getblk(sdp->
sd_vfs, bh_map.b_blocknr);
405 memset(bh->b_data, 0, bh->b_size);
406 set_buffer_uptodate(bh);
407 clear_buffer_dirty(bh);
420 hash = gfs2_disk_hash((
const char *)lh,
sizeof(
struct gfs2_log_header));
423 set_buffer_dirty(bh);
432 static void gfs2_recovery_done(
struct gfs2_sbd *sdp,
unsigned int jid,
437 char *envp[] = { env_jid, env_status,
NULL };
442 sprintf(env_jid,
"JID=%d", jid);
443 sprintf(env_status,
"RECOVERY=%s",
448 sdp->
sd_lockstruct.ls_ops->lm_recovery_result(sdp, jid, message);
464 if (sdp->
sd_args.ar_spectator ||
466 fs_info(sdp,
"jid=%u: Trying to acquire journal lock...\n",
492 fs_info(sdp,
"jid=%u, already locked for use\n", jd->
jd_jid);
499 goto fail_gunlock_ji;
503 goto fail_gunlock_ji;
506 fs_info(sdp,
"jid=%u: Acquiring the transaction lock...\n",
517 goto fail_gunlock_ji;
529 fs_info(sdp,
"recovery required on "
530 "read-only filesystem.\n");
531 fs_info(sdp,
"write access will be "
532 "enabled during recovery.\n");
538 fs_warn(sdp,
"jid=%u: Can't replay: read-only block "
541 goto fail_gunlock_tr;
546 for (pass = 0; pass < 2; pass++) {
547 lops_before_scan(jd, &head, pass);
548 error = foreach_descriptor(jd, head.
lh_tail,
550 lops_after_scan(jd, error, pass);
552 goto fail_gunlock_tr;
555 error = clean_journal(jd, &head);
557 goto fail_gunlock_tr;
561 fs_info(sdp,
"jid=%u: Journal replayed in %lus\n",
584 fs_info(sdp,
"jid=%u: %s\n", jd->
jd_jid, (error) ?
"Failed" :
"Done");
594 static int gfs2_recovery_wait(
void *
word)