Skip to contentSkip to conversation

bz 450641 - fix gfs2 block allocation

PATCH New Benjamin Marzinski 2 participants 2 messages Jun 17, 2008 – Jun 24, 2008 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bz 450641 - fix gfs2 block allocation

This patch fixes bz 450641.

This patch changes the computation for zero_metapath_length(). When you are
extending the metadata tree, The indirect blocks that point to the new data
block must either diverge from the existing tree either at the inode, or at the
first indirect block. They can diverge at the first indirect block because the
inode has room for 483 pointers while the indirect blocks have room for 509
pointers, so when the tree is grown, there is some free space in the first
indirect block. What zero_metapath_length now computes is the height where the
first indirect block for the new data block is located. It can either be 1 (if
the indirect block diverges from the inode) or 2 (if it diverges from the first
indirect block).

The previous computation for this was incorrect.

-Ben

---
 bmap.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

-------------- next part --------------

fs/gfs2/bmap.c +3 -6
Index: gfs2-2.6-nmw/fs/gfs2/bmap.c
===================================================================
@@ -249,12 +249,9 @@ static void find_metapath(const struct g
 static inline unsigned int zero_metapath_length(const struct metapath *mp,
 						unsigned height)
 {
-	unsigned int i;
-	for (i = 0; i < height - 1; i++) {
-		if (mp->mp_list[i] != 0)
-			return i;
-	}
-	return height;
+	if (mp->mp_list[0] == 0)
+		return 2;
+	return 1;
 }
 
 /**
#1 lore raw

PATCH 1/1 bz 450641 - fix gfs2 block allocation

Hi,

Quoted 42 lines · Benjamin Marzinski

This patch fixes bz 450641.

This patch changes the computation for zero_metapath_length(). When you are
extending the metadata tree, The indirect blocks that point to the new data
block must either diverge from the existing tree either at the inode, or at the
first indirect block. They can diverge at the first indirect block because the
inode has room for 483 pointers while the indirect blocks have room for 509
pointers, so when the tree is grown, there is some free space in the first
indirect block. What zero_metapath_length now computes is the height where the
first indirect block for the new data block is located. It can either be 1 (if
the indirect block diverges from the inode) or 2 (if it diverges from the first
indirect block).

The previous computation for this was incorrect.

-Ben

---
 bmap.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

plain text document attachment (gfs2_alloc.patch)
Index: gfs2-2.6-nmw/fs/gfs2/bmap.c
===================================================================

fs/gfs2/bmap.c +0 -2
@@ -249,12 +249,9 @@ static void find_metapath(const struct g
 static inline unsigned int zero_metapath_length(const struct metapath *mp,
 						unsigned height)
 {
-	unsigned int i;
-	for (i = 0; i < height - 1; i++) {

fs/gfs2/bmap.c static void find_metapath(const struct g · line 257

Quoted 10 lines
fs/gfs2/bmap.c +3 -4
-		if (mp->mp_list[i] != 0)
-			return i;
-	}
-	return height;
+	if (mp->mp_list[0] == 0)
+		return 2;
+	return 1;
 }
 
 /**

The patch looks good, but could you also remove the "height" argument to the function since that it no longer required,

Steve.