gfs2-utils: master - libgfs2: Clean up broken rgrp length check

Andrew Price andyp at fedoraproject.org
Fri Sep 19 13:44:57 UTC 2014


Gitweb:        http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=45047cbf2cdfa57f309e2235334ed4cb038efb99
Commit:        45047cbf2cdfa57f309e2235334ed4cb038efb99
Parent:        f67b54c097b5fbb6ace1c3589139c35e3d46adf1
Author:        Andrew Price <anprice at redhat.com>
AuthorDate:    Fri Sep 19 11:20:05 2014 +0100
Committer:     Andrew Price <anprice at redhat.com>
CommitterDate: Fri Sep 19 11:20:05 2014 +0100

libgfs2: Clean up broken rgrp length check

This length check had broken logic (!length && length > ...) and always
used the theoretical maximum rgrp size instead of a real maximum for the
fs. Replace the check with a check for a zero length.

Signed-off-by: Andrew Price <anprice at redhat.com>
---
 gfs2/libgfs2/rgrp.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index 0d0f000..1abcc82 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -154,15 +154,9 @@ void lgfs2_rgrp_bitbuf_free(lgfs2_rgrp_t rg)
 uint64_t gfs2_rgrp_read(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
 {
 	unsigned x, length = rgd->ri.ri_length;
-	uint64_t max_rgrp_bitbytes, max_rgrp_len;
 	struct gfs2_buffer_head **bhs;
 
-	/* Max size of an rgrp is 2GB.  Figure out how many blocks that is: */
-	max_rgrp_bitbytes = ((2147483648 / sdp->bsize) / GFS2_NBBY);
-	max_rgrp_len = max_rgrp_bitbytes / sdp->bsize;
-	if (!length && length > max_rgrp_len)
-		return -1;
-	if (gfs2_check_range(sdp, rgd->ri.ri_addr))
+	if (length == 0 || gfs2_check_range(sdp, rgd->ri.ri_addr))
 		return -1;
 
 	bhs = calloc(length, sizeof(struct gfs2_buffer_head *));


More information about the cluster-commits mailing list