[Ocfs2-tools-commits] smushran commits r790 - trunk/mkfs.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Apr 7 18:57:24 CDT 2005


Author: smushran
Date: 2005-04-07 18:57:22 -0500 (Thu, 07 Apr 2005)
New Revision: 790

Modified:
   trunk/mkfs.ocfs2/check.c
   trunk/mkfs.ocfs2/mkfs.c
Log:
mkfs rounds down the value of blocksize and clustersize
some error msgs improved
Sign-Off: mfasheh

Modified: trunk/mkfs.ocfs2/check.c
===================================================================
--- trunk/mkfs.ocfs2/check.c	2005-04-06 02:39:39 UTC (rev 789)
+++ trunk/mkfs.ocfs2/check.c	2005-04-07 23:57:22 UTC (rev 790)
@@ -52,6 +52,11 @@
 		if (ret) {
 			ocfs2_close(fs);
 			com_err(s->progname, ret, "while initializing the dlm");
+			fprintf(stderr,
+				"As this is an existing OCFS2 volume, it could be mounted on an another node in the cluster.\n"
+				"However, as %s is unable to initialize the dlm, it cannot detect if the volume is in use or not.\n"
+				"To skip this check, use --force or -F.\n",
+				s->progname);
 			return -1;
 		}
 
@@ -60,15 +65,17 @@
 			ocfs2_shutdown_dlm(fs);
 			ocfs2_close(fs);
 			com_err(s->progname, ret, "while locking the cluster");
+			fprintf(stderr,
+				"This volume appears to be in use in the cluster.\n");
+				
 			return -1;
 		}
 
 		ocfs2_release_cluster(fs);
 		ocfs2_shutdown_dlm(fs);
 	} else {
-		fprintf(stdout, "Cluster check has been disabled by --force.\n"
-			"Please ensure that the volume is not mounted on any other node\n"
-			"else re-run %s without --force.\n", s->progname);
+		fprintf(stderr,
+			"WARNING: Cluster check disabled.\n");
 	}
 
 	ocfs2_close(fs);

Modified: trunk/mkfs.ocfs2/mkfs.c
===================================================================
--- trunk/mkfs.ocfs2/mkfs.c	2005-04-06 02:39:39 UTC (rev 789)
+++ trunk/mkfs.ocfs2/mkfs.c	2005-04-07 23:57:22 UTC (rev 790)
@@ -33,6 +33,7 @@
 static void version(const char *progname);
 static void fill_defaults(State *s);
 static int get_bits(State *s, int num);
+static uint64_t get_valid_size(uint64_t num, uint64_t lo, uint64_t hi);
 static void *do_malloc(State *s, size_t size);
 static void do_pwrite(State *s, const void *buf, size_t count, 
 		      uint64_t offset);
@@ -395,15 +396,15 @@
 			    val < OCFS2_MIN_BLOCKSIZE ||
 			    val > OCFS2_MAX_BLOCKSIZE) {
 				com_err(progname, 0,
-					"Invalid blocksize %s: "
-					"must be between %d and %d bytes",
-					optarg,
-					OCFS2_MIN_BLOCKSIZE,
+					"Specify a blocksize between %d and %d "
+					"in powers of 2", OCFS2_MIN_BLOCKSIZE,
 					OCFS2_MAX_BLOCKSIZE);
 				exit(1);
 			}
 
-			blocksize = (unsigned int) val;
+			blocksize = (unsigned int)
+					get_valid_size(val, OCFS2_MIN_BLOCKSIZE,
+						       OCFS2_MAX_BLOCKSIZE);
 			break;
 
 		case 'C':
@@ -413,15 +414,15 @@
 			    val < OCFS2_MIN_CLUSTERSIZE ||
 			    val > OCFS2_MAX_CLUSTERSIZE) {
 				com_err(progname, 0,
-					"Invalid cluster size %s: "
-					"must be between %d and %d bytes",
-					optarg,
-					OCFS2_MIN_CLUSTERSIZE,
+					"Specify a clustersize between %d and "
+					"%d in powers of 2", OCFS2_MIN_CLUSTERSIZE,
 					OCFS2_MAX_CLUSTERSIZE);
 				exit(1);
 			}
 
-			cluster_size = (unsigned int) val;
+			cluster_size = (unsigned int)
+					get_valid_size(val, OCFS2_MIN_CLUSTERSIZE,
+						       OCFS2_MAX_CLUSTERSIZE);
 			break;
 
 		case 'L':
@@ -824,6 +825,24 @@
 	return bits;
 }
 
+static uint64_t
+get_valid_size(uint64_t num, uint64_t lo, uint64_t hi)
+{
+	uint64_t tmp = lo;
+
+	for ( ; lo <= hi; lo <<= 1) {
+		if (lo == num)
+			return num;
+
+		if (lo < num)
+			tmp = lo;
+		else
+			break;
+	}
+
+	return tmp;
+}
+
 static void *
 do_malloc(State *s, size_t size)
 {



More information about the Ocfs2-tools-commits mailing list