From mboxrd@z Thu Jan 1 00:00:00 1970 From: Abhijith Das Date: Mon, 24 Feb 2014 22:15:15 -0500 (EST) Subject: [Cluster-devel] [PATCH] fsck.gfs2: special handling for gfs1 sb update In-Reply-To: <1392648480-5085-1-git-send-email-anprice@redhat.com> References: <1392648480-5085-1-git-send-email-anprice@redhat.com> Message-ID: <951042609.5397017.1393298115981.JavaMail.zimbra@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Since the gfs2_sb structure doesn't contain all the gfs1 fields, updating using lgfs2_sb_write overwrites some gfs1 fields with zeros and breaks the filesystem. We need to update only the gfs2_sb fields and leave the rest as-is. Signed-off-by: Abhi Das diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c index 0f33aa6..cf45a5c 100644 --- a/gfs2/fsck/initialize.c +++ b/gfs2/fsck/initialize.c @@ -60,6 +60,9 @@ static int block_mounters(struct gfs2_sbd *sdp, int block_em) } } + if (sdp->gfs1) + return lgfs2_sb_update(sdp); + if (lgfs2_sb_write(&sdp->sd_sb, sdp->device_fd, sdp->bsize)) { stack; return -1; diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index 6372128..a20e369 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -754,6 +754,7 @@ static inline unsigned int rgrp_size(struct rgrp_tree *rgrp) extern int build_master(struct gfs2_sbd *sdp); extern void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize); extern int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize); +extern int lgfs2_sb_update(struct gfs2_sbd *sbp); extern int build_journal(struct gfs2_sbd *sdp, int j, struct gfs2_inode *jindex); extern int build_jindex(struct gfs2_sbd *sdp); diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c index 2cc9a98..641d875 100644 --- a/gfs2/libgfs2/structures.c +++ b/gfs2/libgfs2/structures.c @@ -105,6 +105,17 @@ void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize) #endif } +int lgfs2_sb_update(struct gfs2_sbd *sbp) +{ + struct gfs2_buffer_head *bh; + + bh = bread(sbp, GFS2_SB_ADDR >> sbp->sd_fsb2bb_shift); + gfs2_sb_out(&sbp->sd_sb, bh->b_data); + brelse(bh); + fsync(sbp->device_fd); /* make sure the change gets to disk ASAP */ + return 0; +} + int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize) { int i, err = -1;