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

[Cluster-devel] [PATCH 8/8] libgfs2: Remove exit call from build_rgrps



Change build_rgrps to return an error value instead of void and push the
exit call down into fsck.gfs2 and gfs2_grow.

Signed-off-by: Andrew Price <anprice redhat com>
---
 gfs2/fsck/rgrepair.c       |  5 ++++-
 gfs2/libgfs2/fs_geometry.c | 10 ++++------
 gfs2/libgfs2/libgfs2.h     |  2 +-
 gfs2/mkfs/main_grow.c      |  5 ++++-
 4 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 1ebdc70..2c1d613 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -654,7 +654,10 @@ static int gfs2_rindex_calculate(struct gfs2_sbd *sdp, int *num_rgs)
 	/* Compute the default resource group layout as mkfs would have done */
 	compute_rgrp_layout(sdp, &sdp->rgcalc, TRUE);
 	debug_print_rgrps(sdp, &sdp->rgcalc);
-	build_rgrps(sdp, FALSE); /* FALSE = calc but don't write to disk. */
+	if (build_rgrps(sdp, FALSE)) { /* FALSE = calc but don't write to disk. */
+		fprintf(stderr, _("Failed to build resource groups\n"));
+		exit(-1);
+	}
 	log_debug( _("fs_total_size = 0x%llx blocks.\n"),
 		  (unsigned long long)sdp->device.length);
 	log_warn( _("L3: number of rgs in the index = %d.\n"), *num_rgs);
diff --git a/gfs2/libgfs2/fs_geometry.c b/gfs2/libgfs2/fs_geometry.c
index 932a2e6..4bdb64a 100644
--- a/gfs2/libgfs2/fs_geometry.c
+++ b/gfs2/libgfs2/fs_geometry.c
@@ -171,7 +171,7 @@ uint32_t rgblocks2bitblocks(const unsigned int bsize, const uint32_t rgblocks, u
  * If fd > 0, write the data to the given file handle.
  * Otherwise, use gfs2 buffering in buf.c.
  */
-void build_rgrps(struct gfs2_sbd *sdp, int do_write)
+int build_rgrps(struct gfs2_sbd *sdp, int do_write)
 {
 	struct osi_node *n, *next = NULL;
 	struct rgrp_tree *rl;
@@ -207,11 +207,8 @@ 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->sd_sb.sb_bsize, rl)) {
-			fprintf(stderr, "%s: Unable to build resource groups "
-				"with these characteristics.\n", __FUNCTION__);
-			exit(-1);
-		}
+		if (gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, rl))
+			return -1;
 
 		if (do_write) {
 			for (x = 0; x < bitblocks; x++) {
@@ -231,4 +228,5 @@ void build_rgrps(struct gfs2_sbd *sdp, int do_write)
 		sdp->blks_total += rgblocks;
 		sdp->fssize = ri->ri_data0 + ri->ri_data;
 	}
+	return 0;
 }
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 71adb30..cc65003 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -431,7 +431,7 @@ extern uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev,
 			       int rgsize_specified);
 extern void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree,
 				int rgsize_specified);
-extern void build_rgrps(struct gfs2_sbd *sdp, int write);
+extern int build_rgrps(struct gfs2_sbd *sdp, int write);
 
 /* fs_ops.c */
 #define IS_LEAF     (1)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 541b0f2..718bb30 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -181,7 +181,10 @@ static void initialize_new_portion(struct gfs2_sbd *sdp, int *old_rg_count)
 	discard_blocks(sdp->device_fd, rl->start * sdp->bsize,
 		       (sdp->device.length - rl->start) * sdp->bsize);
 	/* Build the remaining resource groups */
-	build_rgrps(sdp, !test);
+	if (build_rgrps(sdp, !test)) {
+		fprintf(stderr, _("Failed to build resource groups\n"));
+		exit(-1);
+	}
 
 	inode_put(&sdp->md.riinode);
 	inode_put(&sdp->master_dir);
-- 
1.8.3.1


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