Skip to content

Commit a17d758

Browse files
AstralBobswhiteho
authored andcommitted
GFS2: Move recovery variables to journal structure in memory
If multiple nodes fail and their recovery work runs simultaneously, they would use the same unprotected variables in the superblock. For example, they would stomp on each other's revoked blocks lists, which resulted in file system metadata corruption. This patch moves the necessary variables so that each journal has its own separate area for tracking its journal replay. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent fc554ed commit a17d758

5 files changed

Lines changed: 39 additions & 43 deletions

File tree

‎fs/gfs2/incore.h‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,15 @@ struct gfs2_jdesc {
503503
unsigned int jd_jid;
504504
unsigned int jd_blocks;
505505
int jd_recover_error;
506+
/* Replay stuff */
507+
508+
unsigned int jd_found_blocks;
509+
unsigned int jd_found_revokes;
510+
unsigned int jd_replayed_blocks;
511+
512+
struct list_head jd_revoke_list;
513+
unsigned int jd_replay_tail;
514+
506515
};
507516

508517
struct gfs2_statfs_change_host {
@@ -782,15 +791,6 @@ struct gfs2_sbd {
782791
struct list_head sd_ail1_list;
783792
struct list_head sd_ail2_list;
784793

785-
/* Replay stuff */
786-
787-
struct list_head sd_revoke_list;
788-
unsigned int sd_replay_tail;
789-
790-
unsigned int sd_found_blocks;
791-
unsigned int sd_found_revokes;
792-
unsigned int sd_replayed_blocks;
793-
794794
/* For quiescing the filesystem */
795795
struct gfs2_holder sd_freeze_gh;
796796

‎fs/gfs2/lops.c‎

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -520,13 +520,11 @@ static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
520520
static void buf_lo_before_scan(struct gfs2_jdesc *jd,
521521
struct gfs2_log_header_host *head, int pass)
522522
{
523-
struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
524-
525523
if (pass != 0)
526524
return;
527525

528-
sdp->sd_found_blocks = 0;
529-
sdp->sd_replayed_blocks = 0;
526+
jd->jd_found_blocks = 0;
527+
jd->jd_replayed_blocks = 0;
530528
}
531529

532530
static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
@@ -549,9 +547,9 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
549547
for (; blks; gfs2_replay_incr_blk(sdp, &start), blks--) {
550548
blkno = be64_to_cpu(*ptr++);
551549

552-
sdp->sd_found_blocks++;
550+
jd->jd_found_blocks++;
553551

554-
if (gfs2_revoke_check(sdp, blkno, start))
552+
if (gfs2_revoke_check(jd, blkno, start))
555553
continue;
556554

557555
error = gfs2_replay_read_block(jd, start, &bh_log);
@@ -572,7 +570,7 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
572570
if (error)
573571
break;
574572

575-
sdp->sd_replayed_blocks++;
573+
jd->jd_replayed_blocks++;
576574
}
577575

578576
return error;
@@ -615,7 +613,7 @@ static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
615613
gfs2_meta_sync(ip->i_gl);
616614

617615
fs_info(sdp, "jid=%u: Replayed %u of %u blocks\n",
618-
jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
616+
jd->jd_jid, jd->jd_replayed_blocks, jd->jd_found_blocks);
619617
}
620618

621619
static void revoke_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
@@ -677,13 +675,11 @@ static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
677675
static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
678676
struct gfs2_log_header_host *head, int pass)
679677
{
680-
struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
681-
682678
if (pass != 0)
683679
return;
684680

685-
sdp->sd_found_revokes = 0;
686-
sdp->sd_replay_tail = head->lh_tail;
681+
jd->jd_found_revokes = 0;
682+
jd->jd_replay_tail = head->lh_tail;
687683
}
688684

689685
static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
@@ -715,13 +711,13 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
715711
while (offset + sizeof(u64) <= sdp->sd_sb.sb_bsize) {
716712
blkno = be64_to_cpu(*(__be64 *)(bh->b_data + offset));
717713

718-
error = gfs2_revoke_add(sdp, blkno, start);
714+
error = gfs2_revoke_add(jd, blkno, start);
719715
if (error < 0) {
720716
brelse(bh);
721717
return error;
722718
}
723719
else if (error)
724-
sdp->sd_found_revokes++;
720+
jd->jd_found_revokes++;
725721

726722
if (!--revokes)
727723
break;
@@ -741,16 +737,16 @@ static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
741737
struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
742738

743739
if (error) {
744-
gfs2_revoke_clean(sdp);
740+
gfs2_revoke_clean(jd);
745741
return;
746742
}
747743
if (pass != 1)
748744
return;
749745

750746
fs_info(sdp, "jid=%u: Found %u revoke tags\n",
751-
jd->jd_jid, sdp->sd_found_revokes);
747+
jd->jd_jid, jd->jd_found_revokes);
752748

753-
gfs2_revoke_clean(sdp);
749+
gfs2_revoke_clean(jd);
754750
}
755751

756752
/**
@@ -789,9 +785,9 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
789785
blkno = be64_to_cpu(*ptr++);
790786
esc = be64_to_cpu(*ptr++);
791787

792-
sdp->sd_found_blocks++;
788+
jd->jd_found_blocks++;
793789

794-
if (gfs2_revoke_check(sdp, blkno, start))
790+
if (gfs2_revoke_check(jd, blkno, start))
795791
continue;
796792

797793
error = gfs2_replay_read_block(jd, start, &bh_log);
@@ -811,7 +807,7 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
811807
brelse(bh_log);
812808
brelse(bh_ip);
813809

814-
sdp->sd_replayed_blocks++;
810+
jd->jd_replayed_blocks++;
815811
}
816812

817813
return error;
@@ -835,7 +831,7 @@ static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
835831
gfs2_meta_sync(ip->i_gl);
836832

837833
fs_info(sdp, "jid=%u: Replayed %u of %u data blocks\n",
838-
jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
834+
jd->jd_jid, jd->jd_replayed_blocks, jd->jd_found_blocks);
839835
}
840836

841837
static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)

‎fs/gfs2/ops_fstype.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
128128
atomic_set(&sdp->sd_log_in_flight, 0);
129129
init_waitqueue_head(&sdp->sd_log_flush_wait);
130130

131-
INIT_LIST_HEAD(&sdp->sd_revoke_list);
132-
133131
return sdp;
134132
}
135133

@@ -575,6 +573,8 @@ static int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
575573
break;
576574

577575
INIT_LIST_HEAD(&jd->extent_list);
576+
INIT_LIST_HEAD(&jd->jd_revoke_list);
577+
578578
INIT_WORK(&jd->jd_work, gfs2_recover_func);
579579
jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1);
580580
if (!jd->jd_inode || IS_ERR(jd->jd_inode)) {

‎fs/gfs2/recovery.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk,
5252
return error;
5353
}
5454

55-
int gfs2_revoke_add(struct gfs2_sbd *sdp, u64 blkno, unsigned int where)
55+
int gfs2_revoke_add(struct gfs2_jdesc *jd, u64 blkno, unsigned int where)
5656
{
57-
struct list_head *head = &sdp->sd_revoke_list;
57+
struct list_head *head = &jd->jd_revoke_list;
5858
struct gfs2_revoke_replay *rr;
5959
int found = 0;
6060

@@ -81,13 +81,13 @@ int gfs2_revoke_add(struct gfs2_sbd *sdp, u64 blkno, unsigned int where)
8181
return 1;
8282
}
8383

84-
int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where)
84+
int gfs2_revoke_check(struct gfs2_jdesc *jd, u64 blkno, unsigned int where)
8585
{
8686
struct gfs2_revoke_replay *rr;
8787
int wrap, a, b, revoke;
8888
int found = 0;
8989

90-
list_for_each_entry(rr, &sdp->sd_revoke_list, rr_list) {
90+
list_for_each_entry(rr, &jd->jd_revoke_list, rr_list) {
9191
if (rr->rr_blkno == blkno) {
9292
found = 1;
9393
break;
@@ -97,17 +97,17 @@ int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where)
9797
if (!found)
9898
return 0;
9999

100-
wrap = (rr->rr_where < sdp->sd_replay_tail);
101-
a = (sdp->sd_replay_tail < where);
100+
wrap = (rr->rr_where < jd->jd_replay_tail);
101+
a = (jd->jd_replay_tail < where);
102102
b = (where < rr->rr_where);
103103
revoke = (wrap) ? (a || b) : (a && b);
104104

105105
return revoke;
106106
}
107107

108-
void gfs2_revoke_clean(struct gfs2_sbd *sdp)
108+
void gfs2_revoke_clean(struct gfs2_jdesc *jd)
109109
{
110-
struct list_head *head = &sdp->sd_revoke_list;
110+
struct list_head *head = &jd->jd_revoke_list;
111111
struct gfs2_revoke_replay *rr;
112112

113113
while (!list_empty(head)) {

‎fs/gfs2/recovery.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ static inline void gfs2_replay_incr_blk(struct gfs2_sbd *sdp, unsigned int *blk)
2323
extern int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk,
2424
struct buffer_head **bh);
2525

26-
extern int gfs2_revoke_add(struct gfs2_sbd *sdp, u64 blkno, unsigned int where);
27-
extern int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where);
28-
extern void gfs2_revoke_clean(struct gfs2_sbd *sdp);
26+
extern int gfs2_revoke_add(struct gfs2_jdesc *jd, u64 blkno, unsigned int where);
27+
extern int gfs2_revoke_check(struct gfs2_jdesc *jd, u64 blkno, unsigned int where);
28+
extern void gfs2_revoke_clean(struct gfs2_jdesc *jd);
2929

3030
extern int gfs2_find_jhead(struct gfs2_jdesc *jd,
3131
struct gfs2_log_header_host *head);

0 commit comments

Comments
 (0)