[Ocfs2-tools-commits] manish commits r702 - in trunk: mkfs.ocfs2 tunefs.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Sun Mar 20 00:07:27 CST 2005


Author: manish
Signed-off-by: jlbec
Date: 2005-03-20 00:07:25 -0600 (Sun, 20 Mar 2005)
New Revision: 702

Modified:
   trunk/mkfs.ocfs2/mkfs.c
   trunk/mkfs.ocfs2/mkfs.h
   trunk/mkfs.ocfs2/mkfs.ocfs2.8.in
   trunk/tunefs.ocfs2/tunefs.c
   trunk/tunefs.ocfs2/tunefs.ocfs2.8.in
Log:
mkfs/tunefs changes:

Add the -x option for ocfs2console
Changed -j journal-size to J size=foo to match ext3
Rename -n and -c to -N and -C respectively, to leave room for implementing
dry run and badblock checking at a later time.

Signed-off-by: jlbec


Modified: trunk/mkfs.ocfs2/mkfs.c
===================================================================
--- trunk/mkfs.ocfs2/mkfs.c	2005-03-20 01:20:31 UTC (rev 701)
+++ trunk/mkfs.ocfs2/mkfs.c	2005-03-20 06:07:25 UTC (rev 702)
@@ -27,6 +27,8 @@
 
 static State *get_state(int argc, char **argv);
 static int get_number(char *arg, uint64_t *res);
+static void parse_journal_opts(char *progname, const char *opts,
+			       uint64_t *journal_size_in_bytes);
 static void usage(const char *progname);
 static void version(const char *progname);
 static void fill_defaults(State *s);
@@ -121,13 +123,15 @@
 
 	/* bail if volume already mounted on cluster, etc. */
 	if (ocfs2_check_volume(s))
-		goto bail;
+		return 1;
 
 	/* Abort? */
-	fprintf(stdout, "Proceed (y/N): ");
-	if (toupper(getchar()) != 'Y') {
-		printf("Aborting operation.\n");
-		goto bail;
+	if (s->prompt) {
+		fprintf(stdout, "Proceed (y/N): ");
+		if (toupper(getchar()) != 'Y') {
+			printf("Aborting operation.\n");
+			return 1;
+		}
 	}
 
 	open_device(s);
@@ -337,7 +341,6 @@
 	if (!s->quiet)
 		printf("%s successful\n\n", s->progname);
 
-bail:
 	return 0;
 }
 
@@ -352,24 +355,23 @@
 	char *dummy;
 	State *s;
 	int c;
-	int verbose = 0, quiet = 0, force = 0;
+	int verbose = 0, quiet = 0, force = 0, xtool = 0;
 	int show_version = 0;
 	char *device_name;
 	int ret;
 	uint64_t val;
 	uint64_t journal_size_in_bytes = 0;
-	uint64_t max_journal_size = 500 * ONE_MEGA_BYTE;
 
 	static struct option long_options[] = {
-		{ "blocksize", 1, 0, 'b' },
-		{ "clustersize", 1, 0, 'c' },
+		{ "block-size", 1, 0, 'b' },
+		{ "cluster-size", 1, 0, 'C' },
 		{ "label", 1, 0, 'L' },
-		{ "nodes", 1, 0, 'n' },
+		{ "nodes", 1, 0, 'N' },
 		{ "verbose", 0, 0, 'v' },
 		{ "quiet", 0, 0, 'q' },
 		{ "version", 0, 0, 'V' },
-		{ "journalsize", 0, 0, 'j'},
-		{ "force", 0, 0, 'f'},
+		{ "journal-options", 0, 0, 'J'},
+		{ "force", 0, 0, 'F'},
 		{ 0, 0, 0, 0}
 	};
 
@@ -379,7 +381,7 @@
 		progname = strdup("mkfs.ocfs2");
 
 	while (1) {
-		c = getopt_long(argc, argv, "b:c:L:n:j:vqVf", long_options, 
+		c = getopt_long(argc, argv, "b:C:L:N:J:vqVFx", long_options, 
 				NULL);
 
 		if (c == -1)
@@ -404,7 +406,7 @@
 			blocksize = (unsigned int) val;
 			break;
 
-		case 'c':
+		case 'C':
 			ret = get_number(optarg, &val);
 
 			if (ret ||
@@ -435,7 +437,7 @@
 
 			break;
 
-		case 'n':
+		case 'N':
 			initial_nodes = strtoul(optarg, &dummy, 0);
 
 			if (initial_nodes > OCFS2_MAX_NODES || *dummy != '\0') {
@@ -451,23 +453,9 @@
 
 			break;
 
-		case 'j':
-			ret = get_number(optarg, &val);
-
-			if (ret || 
-			    val < OCFS2_MIN_JOURNAL_SIZE ||
-			    val > max_journal_size) {
-				com_err(progname, 0,
-					"Invalid journal size %s: must be "
-					"between %d and %"PRIu64" bytes",
-					optarg,
-					OCFS2_MIN_JOURNAL_SIZE,
-					max_journal_size);
-				exit(1);
-			}
-
-			journal_size_in_bytes = val;
-
+		case 'J':
+			parse_journal_opts(progname, optarg,
+					   &journal_size_in_bytes);
 			break;
 
 		case 'v':
@@ -482,10 +470,14 @@
 			show_version = 1;
 			break;
 
-		case 'f':
+		case 'F':
 			force = 1;
 			break;
 
+		case 'x':
+			xtool = 1;
+			break;
+
 		default:
 			usage(progname);
 			break;
@@ -529,6 +521,8 @@
 	s->quiet         = quiet;
 	s->force         = force;
 
+	s->prompt        = xtool ? 0 : 1;
+
 	s->blocksize     = blocksize;
 	s->cluster_size  = cluster_size;
 	s->vol_label     = vol_label;
@@ -588,11 +582,75 @@
 	return 0;
 }
 
+/* derived from e2fsprogs */
 static void
+parse_journal_opts(char *progname, const char *opts,
+		   uint64_t *journal_size_in_bytes)
+{
+	char *options, *token, *next, *p, *arg;
+	int ret, journal_usage = 0;
+	uint64_t val;
+	uint64_t max_journal_size = 500 * ONE_MEGA_BYTE;
+
+	options = strdup(opts);
+
+	for (token = options; token && *token; token = next) {
+		p = strchr(token, ',');
+		next = NULL;
+
+		if (p) {
+			*p = '\0';
+			next = p + 1;
+		}
+
+		arg = strchr(token, '=');
+
+		if (arg) {
+			*arg = '\0';
+			arg++;
+		}
+
+		if (strcmp(token, "size") == 0) {
+			if (!arg) {
+				journal_usage++;
+				continue;
+			}
+
+			ret = get_number(arg, &val);
+
+			if (ret ||
+			    val < OCFS2_MIN_JOURNAL_SIZE ||
+			    val > max_journal_size) {
+				com_err(progname, 0,
+					"Invalid journal size: %s\nSize must "
+					"be between %d and %"PRIu64" bytes",
+					arg,
+					OCFS2_MIN_JOURNAL_SIZE,
+					max_journal_size);
+				exit(1);
+			}
+
+			*journal_size_in_bytes = val;
+		} else
+			journal_usage++;
+	}
+
+	if (journal_usage) {
+		com_err(progname, 0,
+			"Bad journal options specified. Valid journal "
+			"options are:\n"
+			"\tsize=<journal size>\n");
+		exit(1);
+	}
+
+	free(options);
+}
+
+static void
 usage(const char *progname)
 {
-	fprintf(stderr, "Usage: %s [-b blocksize] [-c cluster-size] [-L volume-label]\n"
-			"\t[-n number-of-nodes] [-j journal-size] [-fqvV] device [blocks-count]\n",
+	fprintf(stderr, "Usage: %s [-b block-size] [-C cluster-size] [-L volume-label]\n"
+			"\t[-N number-of-nodes] [-J journal-options] [-FqvV] device [blocks-count]\n",
 			progname);
 	exit(0);
 }
@@ -1722,9 +1780,10 @@
 	printf("Filesystem label=%s\n", s->vol_label);
 	printf("Block size=%u (bits=%u)\n", s->blocksize, s->blocksize_bits);
 	printf("Cluster size=%u (bits=%u)\n", s->cluster_size, s->cluster_size_bits);
-	printf("Volume size=%llu (%u clusters) (%"PRIu64" blocks)\n",
-	       (unsigned long long) s->volume_size_in_bytes,
-	       s->volume_size_in_clusters, s->volume_size_in_blocks);
+	printf("Volume size=%"PRIu64" (%u clusters) (%"PRIu64" blocks)\n",
+	       s->volume_size_in_bytes, s->volume_size_in_clusters,
+	       s->volume_size_in_blocks);
+	printf("Journal size=%"PRIu64"\n", s->journal_size_in_bytes);
 	printf("%u cluster groups (tail covers %u clusters, rest cover %u "
 	       "clusters)\n", s->nr_cluster_groups, s->tail_group_bits,
 	       s->global_cpg);

Modified: trunk/mkfs.ocfs2/mkfs.h
===================================================================
--- trunk/mkfs.ocfs2/mkfs.h	2005-03-20 01:20:31 UTC (rev 701)
+++ trunk/mkfs.ocfs2/mkfs.h	2005-03-20 06:07:25 UTC (rev 702)
@@ -193,6 +193,7 @@
 	int verbose;
 	int quiet;
 	int force;
+	int prompt;
 
 	uint32_t blocksize;
 	uint32_t blocksize_bits;

Modified: trunk/mkfs.ocfs2/mkfs.ocfs2.8.in
===================================================================
--- trunk/mkfs.ocfs2/mkfs.ocfs2.8.in	2005-03-20 01:20:31 UTC (rev 701)
+++ trunk/mkfs.ocfs2/mkfs.ocfs2.8.in	2005-03-20 06:07:25 UTC (rev 702)
@@ -2,17 +2,17 @@
 .SH "NAME"
 mkfs.ocfs2 \- Build an OCFS2 file system.
 .SH "SYNOPSIS"
-\fBmkfs.ocfs2\fR [ \fB\-b\fR \fIblocksize\fR ] [ \fB\-c\fR \fIcluster\-size\fR ] [ \fB\-L\fR \fIvolume\-label\fR ] [ \fB\-n\fR \fInumber\-of\-nodes\fR ] [ \fB\-j\fR \fIjournal\-size\fR ] [ \fB\-f\fR ] [ \fB\-q\fR ] [ \fB\-v\fR ] [ \fB\-V\fR ] \fIdevice\fR
+\fBmkfs.ocfs2\fR [ \fB\-b\fR \fIblock\-size\fR ] [ \fB\-C\fR \fIcluster\-size\fR ] [ \fB\-L\fR \fIvolume\-label\fR ] [ \fB\-N\fR \fInumber\-of\-nodes\fR ] [ \fB\-J\fR \fIjournal\-options\fR ] [ \fB\-F\fR ] [ \fB\-q\fR ] [ \fB\-v\fR ] [ \fB\-V\fR ] \fIdevice\fR
 .SH "DESCRIPTION"
 .PP 
 \fBmkfs.ocfs2\fR is used to build an OCFS2 file system on a \fIdevice\fR, usually a partition in a shared disk. In order to prevent data loss, \fBmkfs.ocfs2\fR will not format a specified device if a node has it mounted. Different than OCFS, there is no need to mount the partition exclusively after formatting it.
 .SH "OPTIONS"
 .TP
-\fB\-b\fR \fIblocksize\fR
-\fIBlocksize\fR can be specified in bytes or kbytes. The value of the /fIblocksize\fR can range from 512 to 4096 bytes (512-4k).
+\fB\-b\fR \fIblock\-size\fR
+\fIBlock size\fR can be specified in bytes or kbytes. The value of the /fIblock\-size\fR can range from 512 to 4096 bytes (512-4k).
 
 .TP
-\fB\-c\fR \fIcluster\-size\fR
+\fB\-C\fR \fIcluster\-size\fR
 \fIcluster\-size\fR are specified in kbytes and range from 4k to 1M. The size of the \fIcluster\-size\fR will determine the maximum filesystem size possible for the OCFS2 (32Gb\-8Tb). For database files, 128k \fIcluster\-size\fR is still recommended. For use as a generic filesystem, 4k \fIcluster\-size\fR is recommended.
 
 .TP
@@ -20,15 +20,21 @@
 \fIVolume\-label\fR is usefull when the \fILABEL\fR option is used to mount the partitions. The maximum \fIvolume-label\fR lenght allowed is 64 bytes.
 
 .TP
-\fB\-n\fR \fInumber\-of\-nodes\fR 
+\fB\-N\fR \fInumber\-of\-nodes\fR 
 \fInumber\-of\-nodes\fR specify the max number of nodes where the partition will be mounted. The maximum \fInumber\-of\-nodes\fR allowed is 255. That will allow a better control of allocated space and make OCFS2 more efficient.
 
 .TP
-\fB\-j\fR \fIjournal\-size\fR 
-\fIjournal\-size\fR specify the size of the journal that will be created. Valid sizes range from 4Mb to 500Mb.
+\fB\-J\fR \fIjournal\-options\fR 
+Create the journal using options specified on the command\-line. Journal options are comma separated, and may take an argument using the equals ('=') sign.
+The following journal options are supported:
+.RS 1.2i
+.TP
+\fBsize\fR=\fIjournal\-size\fR
+Create a journal of size \fIjournal\-size\fR. Valid sizes range from 4Mb to 500Mb.
+.RE
 
 .TP
-\fB\-f\fR 
+\fB\-F\fR 
 Force the execution of \fBmkfs.ocfs2\fR. This parameter should be used if the partition was previously used by OCFS2 or when the OCFS2 cluster service is not running.
 
 .TP

Modified: trunk/tunefs.ocfs2/tunefs.c
===================================================================
--- trunk/tunefs.ocfs2/tunefs.c	2005-03-20 01:20:31 UTC (rev 701)
+++ trunk/tunefs.ocfs2/tunefs.c	2005-03-20 06:07:25 UTC (rev 702)
@@ -61,6 +61,7 @@
 	char *device;
 	int verbose;
 	int quiet;
+	int prompt;
 	time_t tune_time;
 	int fd;
 } ocfs2_tune_opts;
@@ -73,8 +74,9 @@
  */
 static void usage(const char *progname)
 {
-	fprintf(stderr, "usage: %s [-L volume-label] [-n number-of-nodes]\n"
-			"\t\t[-j journal-size] [-S volume-size] [-qvV] device\n",
+	fprintf(stderr, "usage: %s [-L volume-label] [-N number-of-nodes]\n"
+			"\t[-J journal-options] [-S volume-size] [-qvV] "
+			"device\n",
 			progname);
 	exit(0);
 }
@@ -134,6 +136,70 @@
 	return 0;
 }
 
+/* derived from e2fsprogs */
+static void
+parse_journal_opts(char *progname, const char *opts,
+		   uint64_t *journal_size_in_bytes)
+{
+	char *options, *token, *next, *p, *arg;
+	int ret, journal_usage = 0;
+	uint64_t val;
+	uint64_t max_journal_size = 500 * ONE_MEGA_BYTE;
+
+	options = strdup(opts);
+
+	for (token = options; token && *token; token = next) {
+		p = strchr(token, ',');
+		next = NULL;
+
+		if (p) {
+			*p = '\0';
+			next = p + 1;
+		}
+
+		arg = strchr(token, '=');
+
+		if (arg) {
+			*arg = '\0';
+			arg++;
+		}
+
+		if (strcmp(token, "size") == 0) {
+			if (!arg) {
+				journal_usage++;
+				continue;
+			}
+
+			ret = get_number(arg, &val);
+
+			if (ret ||
+			    val < OCFS2_MIN_JOURNAL_SIZE ||
+			    val > max_journal_size) {
+				com_err(progname, 0,
+					"Invalid journal size: %s\nSize must "
+					"be between %d and %"PRIu64" bytes",
+					arg,
+					OCFS2_MIN_JOURNAL_SIZE,
+					max_journal_size);
+				exit(1);
+			}
+
+			*journal_size_in_bytes = val;
+		} else
+			journal_usage++;
+	}
+
+	if (journal_usage) {
+		com_err(progname, 0,
+			"Bad journal options specified. Valid journal "
+			"options are:\n"
+			"\tsize=<journal size>\n");
+		exit(1);
+	}
+
+	free(options);
+}
+
 /*
  * get_options()
  *
@@ -145,16 +211,15 @@
 	int ret;
 	char *dummy;
 	uint64_t val;
-	uint64_t max_journal_size = 500 * ONE_MEGA_BYTE;
 
 	static struct option long_options[] = {
 		{ "label", 1, 0, 'L' },
-		{ "nodes", 1, 0, 'n' },
+		{ "nodes", 1, 0, 'N' },
 		{ "verbose", 0, 0, 'v' },
 		{ "quiet", 0, 0, 'q' },
 		{ "version", 0, 0, 'V' },
-		{ "journalsize", 0, 0, 'j'},
-		{ "volumesize", 0, 0, 'S'},
+		{ "journal-options", 0, 0, 'J'},
+		{ "volume-size", 0, 0, 'S'},
 		{ 0, 0, 0, 0}
 	};
 
@@ -163,8 +228,10 @@
 	else
 		opts.progname = strdup("tunefs.ocfs2");
 
+	opts.prompt = 1;
+
 	while (1) {
-		c = getopt_long(argc, argv, "L:n:j:S:vqV", long_options, 
+		c = getopt_long(argc, argv, "L:N:J:S:vqV", long_options, 
 				NULL);
 
 		if (c == -1)
@@ -183,7 +250,7 @@
 			}
 			break;
 
-		case 'n':
+		case 'N':
 			opts.num_nodes = strtoul(optarg, &dummy, 0);
 
 			if (opts.num_nodes > OCFS2_MAX_NODES ||
@@ -199,22 +266,9 @@
 			}
 			break;
 
-		case 'j':
-			ret = get_number(optarg, &val);
-
-			if (ret || 
-			    val < OCFS2_MIN_JOURNAL_SIZE ||
-			    val > max_journal_size) {
-				com_err(opts.progname, 0,
-					"Invalid journal size %s: must be "
-					"between %d and %"PRIu64" bytes",
-					optarg,
-					OCFS2_MIN_JOURNAL_SIZE,
-					max_journal_size);
-				exit(1);
-			}
-
-			opts.jrnl_size = val;
+		case 'J':
+			parse_journal_opts(opts.progname, optarg,
+					   &opts.jrnl_size);
 			break;
 
 		case 'S':
@@ -236,6 +290,10 @@
 			show_version = 1;
 			break;
 
+		case 'x':
+			opts.prompt = 0;
+			break;
+
 		default:
 			usage(opts.progname);
 			break;
@@ -585,10 +643,12 @@
 	}
 
 	/* Abort? */
-	printf("Proceed (y/N): ");
-	if (toupper(getchar()) != 'Y') {
-		printf("Aborting operation.\n");
-		goto unlock;
+	if (opts.prompt) {
+		printf("Proceed (y/N): ");
+		if (toupper(getchar()) != 'Y') {
+			printf("Aborting operation.\n");
+			goto unlock;
+		}
 	}
 
 	/* update volume label */

Modified: trunk/tunefs.ocfs2/tunefs.ocfs2.8.in
===================================================================
--- trunk/tunefs.ocfs2/tunefs.ocfs2.8.in	2005-03-20 01:20:31 UTC (rev 701)
+++ trunk/tunefs.ocfs2/tunefs.ocfs2.8.in	2005-03-20 06:07:25 UTC (rev 702)
@@ -2,7 +2,7 @@
 .SH "NAME"
 tunefs.ocfs2 \- Change OCFS2 partition parameters.
 .SH "SYNOPSIS"
-\fBtunefs.ocfs2\fR [\fB\-L\fR \fIvolume-label\fR] [\fB\-n\fR \fInumber-of-nodes\fR] [\fB\-j\fR \fIjournal-size\fR] [\fB\-S\fR \fIvolume-size\fR] [\fB\-qvV\fR] \fIdevice\fR
+\fBtunefs.ocfs2\fR [\fB\-L\fR \fIvolume-label\fR] [\fB\-N\fR \fInumber-of-nodes\fR] [\fB\-J\fR \fIjournal-options\fR] [\fB\-S\fR \fIvolume-size\fR] [\fB\-qvV\fR] \fIdevice\fR
 .SH "DESCRIPTION"
 .PP 
 \fBtunefs.ocfs2\fR is used to adjust OCFS2 file system parameters on disk. In order to prevent data loss, \fBtunefs.ocfs2\fR will not perform any action to a specified device if any node has it mounted. 
@@ -12,12 +12,18 @@
 \fIvolume\-label\fR specifiy the new label name of a device. The maximum \fIvolume-label\fR lenght allowed is 64 bytes.
 
 .TP
-\fB\-n\fR \fInumber\-of\-nodes\fR
+\fB\-N\fR \fInumber\-of\-nodes\fR
 \fInumber\-of\-nodes\fR specify the number of nodes that will be sharing a specific OCFS2 partition. The maximum value allowed for \fInumber\-of\-nodes\fR is 255. Note that one can increase the number of nodes, but not decrease it. Future versions may allow decrease of the number of nodes.
 
 .TP
-\fB\-j\fR \fIjournal\-size\fR
-\fIjournal\-size\fR specify the size of the OCFS2 journal used by the partition. Valid size values range from 4Mb to 500Mb. Note that one can increase the size of the OCFS2 journal, but not decrease it. Future versions may allow decrease of the OCFS2 journal size.
+\fB\-J\fR \fIjournal\-options\fR
+Modify the journal using options specified on the command\-line. Journal options are comma separated, and may take an argument using the equals ('=') sign.
+The following journal options are supported:
+.RS 1.2i
+.TP
+\fBsize\fR=\fIjournal\-size\fR
+Create a journal of size \fIjournal\-size\fR. Valid sizes range from 4Mb to 500Mb.
+.RE
 
 .TP
 \fB\-S\fR \fIvolume\-size\fR 



More information about the Ocfs2-tools-commits mailing list