Skip to contentSkip to conversation

gfs2-utils: more fsck.gfs2 i_goal fixes

Cluster-devel Abhi Das 1 participant 2 messages Apr 1, 2015

lore
Share & tools
lore

Abhi Das

author
#0 lore raw

fsck.gfs2 doesn't traverse the metadata tree for dirs in pass1 to be able to get at the last allocated block for it and attempts to set it to the inode block itself when it finds the i_goal value to be outside of the current rgrp. This is not desirable and fsck.gfs2 should probably leave directories alone.

This patch simply skips over directories whose goal blocks fall within the boundaries of the fs, assuming they are valid.

Resolves: rhbz#1186515

---
 gfs2/fsck/metawalk.c | 8 ++++++++
 1 file changed, 8 insertions(+)
gfs2/fsck/metawalk.c +8 -0
index 6daaf9f..f05fb51 100644
@@ -1995,6 +1995,14 @@ int check_i_goal(struct gfs2_inode *ip, uint64_t goal_blk,
 	if (sdp->gfs1 || ip->i_di.di_flags & GFS2_DIF_SYSTEM ||
 		ip->i_di.di_goal_meta == i_block)
 		return 0;
+	/* Don't fix directory goal blocks unless we know they're wrong.
+	 * i.e. out of bounds of the fs. Directories can easily have blocks
+	 * outside of the dinode's rgrp and thus we have no way of knowing
+	 * if the goal block is bogus or not. */
+	if (is_dir(&ip->i_di, ip->i_sbd->gfs1) &&
+	    (ip->i_di.di_goal_meta > sdp->sb_addr &&
+	     ip->i_di.di_goal_meta <= sdp->fssize))
+		return 0;
 	/* We default to the inode block */
 	if (!goal_blk)
 		goal_blk = i_block;
Signature · 1 line
1.8.1.4
author
#1 lore raw

[Cluster-devel] gfs2_utils: more gfs2_convert i_goal fixes

The correct goal was only being set on files that are >= meta height 2. This patch fixes this and sets correct goal values for stuffed, height 1 and jdata files as well

Resolves: rhbz#1186847

---
 gfs2/convert/gfs2_convert.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
gfs2/convert/gfs2_convert.c +12 -6
index 9a42985..bb4e3a2 100644
@@ -435,9 +435,9 @@ static void jdata_mp_gfs1_to_gfs2(struct gfs2_sbd *sbp, int gfs1_h, int gfs2_h,
 	}
 }
 
-static void fix_jdatatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
-		  struct blocklist *blk, char *srcptr,
-		  unsigned int size)
+static uint64_t fix_jdatatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
+			      struct blocklist *blk, char *srcptr,
+			      unsigned int size)
 {
 	uint64_t block;
 	struct gfs2_buffer_head *bh;
@@ -499,6 +499,7 @@ static void fix_jdatatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
 		amount = size - copied;
 		ptramt = 0;
 	}
+	return block;
 }
 
 static int get_inode_metablocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip, struct blocklist *blocks)
@@ -620,7 +621,7 @@ static int fix_ind_reg_or_dir(struct gfs2_sbd *sbp, struct gfs2_inode *ip, uint3
 	blk->height -= di_height - gfs2_hgt;
 	if (len) {
 		fix_metatree(sbp, ip, blk, ptr1, len);
-		ip->i_di.di_goal_data = ip->i_di.di_goal_meta = be64_to_cpu(*ptr2);
+		ip->i_di.di_goal_meta = be64_to_cpu(*ptr2);
 	}
 
 	return 0;
@@ -687,7 +688,8 @@ static int fix_ind_jdata(struct gfs2_sbd *sbp, struct gfs2_inode *ip, uint32_t d
 		memcpy(&newblk->mp, &gfs2mp, sizeof(struct metapath));
 		newblk->height -= di_height - gfs2_hgt;
 		if (len)
-			fix_jdatatree(sbp, ip, newblk, newblk->ptrbuf, len);
+			ip->i_di.di_goal_meta = fix_jdatatree(sbp, ip, newblk,
+							      newblk->ptrbuf, len);
 		free(newblk->ptrbuf);
 		free(newblk);
 	}
@@ -705,12 +707,16 @@ static int adjust_indirect_blocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip)
 	int isdir = S_ISDIR(ip->i_di.di_mode); /* is always jdata */
 	int isjdata = ((GFS2_DIF_JDATA & ip->i_di.di_flags) && !isdir);
 	int isreg = (!isjdata && !isdir);
+	int issys = (GFS2_DIF_SYSTEM & ip->i_di.di_flags);
 
 	/* regular files and dirs are same upto height=2
 	   jdata files (not dirs) are same only when height=0 */
 	if (((isreg||isdir) && ip->i_di.di_height <= 1) ||
-	    (isjdata && ip->i_di.di_height == 0))
+	    (isjdata && ip->i_di.di_height == 0)) {
+		if (!issys)
+			ip->i_di.di_goal_meta = ip->i_di.di_num.no_addr;
 		return 0; /* nothing to do */
+	}
 
 	osi_list_init(&blocks.list);
 
Signature · 1 line
1.8.1.4