All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] gfs2-utils: more fsck.gfs2 i_goal fixes
@ 2015-04-01 14:55 Abhi Das
  2015-04-01 14:55 ` [Cluster-devel] gfs2_utils: more gfs2_convert " Abhi Das
  0 siblings, 1 reply; 2+ messages in thread
From: Abhi Das @ 2015-04-01 14:55 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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
Signed-off-by: Abhi Das <adas@redhat.com>
---
 gfs2/fsck/metawalk.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 6daaf9f..f05fb51 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -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;
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Cluster-devel] gfs2_utils: more gfs2_convert i_goal fixes
  2015-04-01 14:55 [Cluster-devel] gfs2-utils: more fsck.gfs2 i_goal fixes Abhi Das
@ 2015-04-01 14:55 ` Abhi Das
  0 siblings, 0 replies; 2+ messages in thread
From: Abhi Das @ 2015-04-01 14:55 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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
Signed-off-by: Abhi Das <adas@redhat.com>
---
 gfs2/convert/gfs2_convert.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 9a42985..bb4e3a2 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -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);
 
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-01 14:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-01 14:55 [Cluster-devel] gfs2-utils: more fsck.gfs2 i_goal fixes Abhi Das
2015-04-01 14:55 ` [Cluster-devel] gfs2_utils: more gfs2_convert " Abhi Das

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.