GFS2: Fix off-by-one in gfs2_blk2rgrpd
authorSteven Whitehouse <swhiteho@redhat.com>
Thu, 8 Sep 2011 09:21:13 +0000 (10:21 +0100)
committerSteven Whitehouse <swhiteho@redhat.com>
Fri, 21 Oct 2011 11:39:46 +0000 (12:39 +0100)
commitf75bbfb4dda68c86eb33cde7e2b5c1343c6d5812
tree42d5f7a3637061cddc3170aac8e57c4933007898
parent13d921e37174e3d1042deeb303537c1d935da553
GFS2: Fix off-by-one in gfs2_blk2rgrpd

Bob reported:

I found an off-by-one problem with how I coded this section:
It should be:

+ else if (blk >= cur->rd_data0 + cur->rd_data)

In fact, cur->rd_data0 + cur->rd_data is the start of the next
rgrp (the next ri_addr), so without the "=" check it can land on
the wrong rgrp.

In all normal cases, this won't be a problem: you're searching
for a block _within_ the rgrp, which will pass the test properly.
Where it gets into trouble is if you search the rgrps for the
block exactly equal to ri_addr.  I don't think anything in the
kernel does this, but I found a place in gfs2-utils gfs2_edit
where it does.  So I definitely need to fix it in libgfs2.  I'd
like to suggest we fix it in the kernel as well for the sake of
keeping the functions similar.

So this patch fixes the above mentioned off by one error as well
as removing the unused parent pointer.

Reported-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
fs/gfs2/rgrp.c