[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH] fsck.gfs2: special handling for gfs1 sb update



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 <adas redhat com>

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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]