[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH 6/6] libgfs2: Clarify gfs2_compute_bitstructs's parameters



gfs2_compute_bitstructs accepted an sdp and only used it to look up the
block size. Replace the sdp parameter with a bsize parameter to make it
easier to reason through code which uses this function.

Signed-off-by: Andrew Price <anprice redhat com>
---
 gfs2/convert/gfs2_convert.c |  2 +-
 gfs2/fsck/rgrepair.c        |  6 +++---
 gfs2/libgfs2/fs_geometry.c  |  2 +-
 gfs2/libgfs2/libgfs2.h      |  2 +-
 gfs2/libgfs2/rgrp.c         | 10 +++++-----
 gfs2/libgfs2/super.c        |  2 +-
 gfs2/mkfs/main_mkfs.c       |  2 +-
 7 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index d286512..d4bad1d 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1898,7 +1898,7 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
 			rgd->bh[x] = bget(sdp, rgd->ri.ri_addr + x);
 			memset(rgd->bh[x]->b_data, 0, sdp->bsize);
 		}
-		if (gfs2_compute_bitstructs(sdp, rgd)) {
+		if (gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, rgd)) {
 			log_crit(_("gfs2_convert: Error converting bitmaps.\n"));
 			exit(-1);
 		}
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 27368a2..1ebdc70 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -503,7 +503,7 @@ static int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs,
 				break; /* end of bitmap, so call it quits. */
 		} /* for subsequent bitmaps */
 		
-		gfs2_compute_bitstructs(sdp, calc_rgd);
+		gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, calc_rgd);
 		calc_rgd->ri.ri_data0 = calc_rgd->ri.ri_addr +
 			calc_rgd->ri.ri_length;
 		if (prev_rgd) {
@@ -732,7 +732,7 @@ static int expect_rindex_sanity(struct gfs2_sbd *sdp, int *num_rgs)
 		memcpy(&exp->rg, &rgd->rg, sizeof(exp->rg));
 		exp->bits = NULL;
 		exp->bh = NULL;
-		gfs2_compute_bitstructs(sdp, exp);
+		gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, exp);
 	}
 	sdp->rgrps = *num_rgs;
 	return 0;
@@ -948,7 +948,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *rg_count, int *sane)
 			}
 			else
 				log_err( _("rindex not fixed.\n"));
-			gfs2_compute_bitstructs(sdp, actual);
+			gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, actual);
 			rindex_modified = FALSE;
 		}
 		e = enext;
diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c
index e716127..932a2e6 100644
--- a/gfs2/libgfs2/fs_geometry.c
+++ b/gfs2/libgfs2/fs_geometry.c
@@ -207,7 +207,7 @@ void build_rgrps(struct gfs2_sbd *sdp, int do_write)
 		rl->rg.rg_header.mh_format = GFS2_FORMAT_RG;
 		rl->rg.rg_free = rgblocks;
 
-		if (gfs2_compute_bitstructs(sdp, rl)) {
+		if (gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, rl)) {
 			fprintf(stderr, "%s: Unable to build resource groups "
 				"with these characteristics.\n", __FUNCTION__);
 			exit(-1);
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index e069e9d..997e23f 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -725,7 +725,7 @@ extern int gfs2_find_jhead(struct gfs2_inode *ip, struct gfs2_log_header *head);
 extern int clean_journal(struct gfs2_inode *ip, struct gfs2_log_header *head);
 
 /* rgrp.c */
-extern int gfs2_compute_bitstructs(struct gfs2_sbd *sdp, struct rgrp_tree *rgd);
+extern int gfs2_compute_bitstructs(const uint32_t bsize, struct rgrp_tree *rgd);
 extern struct rgrp_tree *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, uint64_t blk);
 extern uint64_t gfs2_rgrp_read(struct gfs2_sbd *sdp, struct rgrp_tree *rgd);
 extern void gfs2_rgrp_relse(struct rgrp_tree *rgd);
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index f7dc01e..f2b8304 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -12,11 +12,11 @@
 
 /**
  * gfs2_compute_bitstructs - Compute the bitmap sizes
- * @rgd: The resource group descriptor
- *
+ * bsize: Block size
+ * rgd: The resource group descriptor
  * Returns: 0 on success, -1 on error
  */
-int gfs2_compute_bitstructs(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
+int gfs2_compute_bitstructs(const uint32_t bsize, struct rgrp_tree *rgd)
 {
 	struct gfs2_bitmap *bits;
 	uint32_t length = rgd->ri.ri_length;
@@ -49,7 +49,7 @@ int gfs2_compute_bitstructs(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
 			bits->bi_len = bytes;
 		}
 		else if (x == 0){
-			bytes = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_rgrp);
+			bytes = bsize - sizeof(struct gfs2_rgrp);
 			bits->bi_offset = sizeof(struct gfs2_rgrp);
 			bits->bi_start = 0;
 			bits->bi_len = bytes;
@@ -61,7 +61,7 @@ int gfs2_compute_bitstructs(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
 			bits->bi_len = bytes;
 		}
 		else{
-			bytes = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
+			bytes = bsize - sizeof(struct gfs2_meta_header);
 			bits->bi_offset = sizeof(struct gfs2_meta_header);
 			bits->bi_start = rgd->ri.ri_bitbytes - bytes_left;
 			bits->bi_len = bytes;
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index 21c9f7b..eb97c40 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -188,7 +188,7 @@ int rindex_read(struct gfs2_sbd *sdp, int fd, int *count1, int *sane)
 			prev_rgd->length = rgrp_size(prev_rgd);
 		}
 
-		if(gfs2_compute_bitstructs(sdp, rgd))
+		if(gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, rgd))
 			*sane = 0;
 
 		(*count1)++;
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index aadd501..76b34b8 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -613,7 +613,7 @@ static int place_rgrps(struct gfs2_sbd *sdp, const struct mkfs_opts *opts)
 
 		/* TODO: This call allocates buffer heads and bitmap pointers
 		 * in rgt. We really shouldn't need to do that. */
-		err = gfs2_compute_bitstructs(sdp, rgt);
+		err = gfs2_compute_bitstructs(sdp->bsize, rgt);
 		if (err != 0) {
 			fprintf(stderr, _("Could not compute bitmaps. "
 			        "Check resource group and block size options.\n"));
-- 
1.8.1.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]