gfs2-utils: master - fsck.gfs2: avoid negative number in leaf depth

Bob Peterson rpeterso at fedoraproject.org
Wed Jul 17 12:59:56 UTC 2013


Gitweb:        http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=ea48ab1de8a5216eb7b5dc6ff7f2c9e19eb44c25
Commit:        ea48ab1de8a5216eb7b5dc6ff7f2c9e19eb44c25
Parent:        6a5197849a38cfa3430642c758c4bb603713f9c7
Author:        Bob Peterson <rpeterso at redhat.com>
AuthorDate:    Mon Jul 15 14:25:43 2013 -0500
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Wed Jul 17 07:31:36 2013 -0500

fsck.gfs2: avoid negative number in leaf depth

If a leaf block appears many times by mistake in the same hash table,
there's a chance it belongs in a different directory's hash table, and
was put there by mistake. In that case, the leaf depth may be too
big for the directory in which it improperly appears. When that happens,
function check_leaf_depth can come up with a negative number when it
calculates the depth. This patch prevents the negative leaf depth error
by flagging an error when it determines the leaf depth is wrong.
The error causes pass2 to relocate the leaf to lost+found when it returns.

rhbz#984085
---
 gfs2/fsck/pass2.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index f97e494..abf5f48 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -276,6 +276,9 @@ static int check_leaf_depth(struct gfs2_inode *ip, uint64_t leaf_no,
 		factor++;
 		divisor >>= 1;
 	}
+	if (ip->i_di.di_depth < factor) /* can't be fixed--leaf must be on the
+					   wrong dinode. */
+		return -1;
 	correct_depth = ip->i_di.di_depth - factor;
 	if (cur_depth == correct_depth)
 		return 0;


More information about the cluster-commits mailing list