Gitweb:
http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 320251b01daf66d9324a32a1db9c00015c67c0e4
Parent: 3d4d902ad95128679c005373eda1e033e716d02f
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Wed Sep 7 13:53:13 2011 -0500
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Wed Sep 7 13:53:13 2011 -0500
libgfs2: Fix off-by-one error in rgrp searching
The patch fixes an off-by-one error that results in landing on the
wrong resource group when searching for an address exactly equal to
an rgrp's ri_addr.
This bug is mostly seen if you're walking the rgrps from gfs2_edit
and walk the bitmaps: The bitmap's block translation will be
calculated for the wrong rgrp. The code was checking to see if the
block is greater than ri->ri_data0 + ri->ri_data, but technically
ri->ri_data0 + ri->ri_data is the ri_addr of the next rgrp.
So the correct calculation should be block > ri_data0 + ri_data - 1
or for simplicity of coding, block >= ri_data0 + ri_data
---
gfs2/libgfs2/rgrp.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index e7b5f72..3e852d2 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -106,7 +106,7 @@ struct rgrp_tree *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, uint64_t blk)
if (blk < ri->ri_addr)
node = node->osi_left;
- else if (blk > ri->ri_data0 + ri->ri_data)
+ else if (blk >= ri->ri_data0 + ri->ri_data)
node = node->osi_right;
else
return rgd;