RHEL5 - mkfs.gfs2: should have an optional fs size parm

Bob Peterson rpeterso@fedoraproject.org
Fri Aug 8 21:55:00 GMT 2008


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=12749e4f6dfec9ade39522dc3c6cb9d82fbac050
Commit:        12749e4f6dfec9ade39522dc3c6cb9d82fbac050
Parent:        3f70f30c69a229caaeed037306eb12b1ad6bd9b1
Author:        Bob Peterson <rpeterso@redhat.com>
AuthorDate:    Fri Aug 8 15:38:29 2008 -0500
Committer:     Bob Peterson <rpeterso@redhat.com>
CommitterDate: Fri Aug 8 15:54:20 2008 -0500

mkfs.gfs2: should have an optional fs size parm

bz 450764

This patch fixes two problems with the previous patch for
an optional "blocks" parameter to mkfs.gfs2.  The bugs
are: (1) If the blocks specified is too big, it gave a wrong
message.  This fixes the message and prints out what the
numbers are (to help the user get it right).  (2) If the
number of blocks was specified, the device size was reported
incorrectly.
---
 gfs2/mkfs/main_mkfs.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 0db34e7..c31c2d0 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -329,7 +329,7 @@ void check_mount(char *device)
  */
 
 static void
-print_results(struct gfs2_sbd *sdp)
+print_results(struct gfs2_sbd *sdp, uint64_t real_device_size)
 {
 	if (sdp->debug)
 		printf("\n");
@@ -343,7 +343,8 @@ print_results(struct gfs2_sbd *sdp)
 
 	printf("Blocksize:                 %u\n", sdp->bsize);
 	printf("Device Size                %.2f GB (%"PRIu64" blocks)\n",
-	       sdp->device_size / ((float)(1 << 30)) * sdp->bsize, sdp->device_size);
+	       real_device_size / ((float)(1 << 30)),
+	       real_device_size / sdp->bsize);
 	printf("Filesystem Size:           %.2f GB (%"PRIu64" blocks)\n",
 	       sdp->fssize / ((float)(1 << 30)) * sdp->bsize, sdp->fssize);
 
@@ -376,6 +377,7 @@ main_mkfs(int argc, char *argv[])
 	unsigned int x;
 	int error;
 	int rgsize_specified = 0;
+	uint64_t real_device_size;
 
 	memset(sdp, 0, sizeof(struct gfs2_sbd));
 	sdp->bsize = GFS2_DEFAULT_BSIZE;
@@ -412,14 +414,19 @@ main_mkfs(int argc, char *argv[])
 
 	/* Get the device geometry */
 
+	device_size(sdp->device_fd, &real_device_size);
 	device_geometry(sdp);
 	/* Convert optional block-count to basic blocks */
 	if (sdp->orig_fssize) {
 		sdp->orig_fssize *= sdp->bsize;
 		sdp->orig_fssize >>= GFS2_BASIC_BLOCK_SHIFT;
-		if (sdp->orig_fssize > sdp->device.length)
-			die("specified block count is smaller than the"
-			    "actual device.\n");
+		if (sdp->orig_fssize > sdp->device.length) {
+			fprintf(stderr, "%s: Specified block count is bigger "
+				"than the actual device.\n", prog_name);
+			die("Device Size is %.2f GB (%"PRIu64" blocks)\n",
+			       real_device_size / ((float)(1 << 30)),
+			       real_device_size / sdp->bsize);
+		}
 		sdp->device.length = sdp->orig_fssize;
 	}
 	fix_device_geometry(sdp);
@@ -460,5 +467,5 @@ main_mkfs(int argc, char *argv[])
 		die("error closing device (%d): %s\n",
 		    error, strerror(errno));
 
-	print_results(sdp);
+	print_results(sdp, real_device_size);
 }



More information about the Cluster-cvs mailing list