cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 4/4] mkfs.gfs2: Add align option and update docs
Date: Thu,  6 Jun 2013 13:03:33 +0100	[thread overview]
Message-ID: <1370520213-29676-4-git-send-email-anprice@redhat.com> (raw)
In-Reply-To: <1370520213-29676-1-git-send-email-anprice@redhat.com>

Add an 'align' extended option for enabling and disabling resource group
alignment and update the mkfs.gfs2 man page to document the new extended
options.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/man/mkfs.gfs2.8  | 31 +++++++++++++++++++++++++++++++
 gfs2/mkfs/main_mkfs.c | 47 +++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 74 insertions(+), 4 deletions(-)

diff --git a/gfs2/man/mkfs.gfs2.8 b/gfs2/man/mkfs.gfs2.8
index 4613305..ceb6f38 100644
--- a/gfs2/man/mkfs.gfs2.8
+++ b/gfs2/man/mkfs.gfs2.8
@@ -48,6 +48,37 @@ storage).
 This option prevents gfs2_mkfs from asking for confirmation before writing
 the filesystem.
 .TP
+\fB-o\fP
+Specify extended options. Multiple options can be separated by commas. Valid extended options are:
+.RS 1.0i
+.TP
+.BI help
+Display an extended options help summary, then exit.
+.TP
+.BI sunit= bytes
+This is used to specify the stripe unit for a RAID device or striped logical
+volume.  This option ensures that resource groups will be stripe unit aligned
+and overrides the stripe unit value obtained by probing the device. This value
+must be a multiple of the file system block size and must be specified with the
+.I swidth
+option.
+.TP
+.BI swidth= bytes
+This is used to specify the stripe width for a RAID device or striped logical
+volume.  This option ensures that resource groups will be stripe aligned and overrides the stripe width value obtained by probing the device. This value must be a multiple of the
+.I sunit
+option and must also be specified with it.
+.TP
+.BI align= [0|1]
+Disable or enable the alignment of resource groups. The default behaviour is to
+align resource groups to the stripe width and stripe unit values obtained from
+probing the device or specified with the
+.I swidth
+and
+.I sunit
+extended options.
+.RE
+.TP
 \fB-p\fP \fILockProtoName\fR 
 LockProtoName is the name of the  locking  protocol to use.  Acceptable
 locking protocols are \fIlock_dlm\fR (for shared storage) or if you are
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index dcfb032..fb4b5ca 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -57,7 +57,7 @@ static void print_usage(const char *prog_name)
 	    "-j", _("<number>"), _("Number of journals"),
 	    "-K", NULL,          _("Don't try to discard unused blocks"),
 	    "-O", NULL,          _("Don't ask for confirmation"),
-	    "-o", _("<key>[=<value>][,...]"), _("Specify extended options"),
+	    "-o", _("<key>[=<value>][,...]"), _("Specify extended options. See '-o help'."),
 	    "-p", _("<name>"),   _("Name of the locking protocol"),
 	    "-q", NULL,          _("Don't print anything"),
 	    "-r", _("<size>"),   _("Size of resource groups, in megabytes"),
@@ -80,6 +80,22 @@ static void print_usage(const char *prog_name)
 	}
 }
 
+static void print_ext_opts(void)
+{
+	int i;
+	const char *options[] = {
+		"help", _("Display this help, then exit"),
+		"swidth=N",  _("Specify the stripe width of the device, overriding probed values"),
+		"sunit=N", _("Specify the stripe unit of the device, overriding probed values"),
+		"align=[0|1]", _("Disable or enable alignment of resource groups"),
+		NULL, NULL
+	};
+	printf(_("Extended options:\n"));
+	for (i = 0; options[i] != NULL; i+=2) {
+		printf("%15s  %-22s\n", options[i], options[i+1]);
+	}
+}
+
 struct mkfs_opts {
 	unsigned bsize;
 	unsigned qcsize;
@@ -111,6 +127,7 @@ struct mkfs_opts {
 	unsigned expert:1;
 	unsigned debug:1;
 	unsigned confirm:1;
+	unsigned align:1;
 };
 
 /**
@@ -165,6 +182,7 @@ static void opts_init(struct mkfs_opts *opts)
 	opts->lockproto = "lock_dlm";
 	opts->locktable = "";
 	opts->confirm = 1;
+	opts->align = 1;
 }
 
 #ifndef BLKDISCARD
@@ -250,6 +268,18 @@ static unsigned long parse_ulong(struct mkfs_opts *opts, const char *key, const
 	return (unsigned long)l;
 }
 
+static unsigned parse_bool(struct mkfs_opts *opts, const char *key, const char *val)
+{
+	if (strnlen(val, 2) == 1) {
+		if (*val == '0')
+			return 0;
+		if (*val == '1')
+			return 1;
+	}
+	fprintf(stderr, _("Option '%s' must be either 1 or 0\n"), key);
+	exit(-1);
+}
+
 static void opt_parse_extended(char *str, struct mkfs_opts *opts)
 {
 	char *opt;
@@ -266,6 +296,11 @@ static void opt_parse_extended(char *str, struct mkfs_opts *opts)
 		} else if (strcmp("swidth", key) == 0) {
 			opts->swidth = parse_ulong(opts, "swidth", val);
 			opts->got_swidth = 1;
+		} else if (strcmp("align", key) == 0) {
+			opts->align = parse_bool(opts, "align", val);
+		} else if (strcmp("help", key) == 0) {
+			print_ext_opts();
+			exit(0);
 		} else {
 			fprintf(stderr, _("Invalid option '%s'\n"), key);
 			exit(-1);
@@ -603,7 +638,7 @@ static uint64_t align_block(const uint64_t base, const uint64_t align, const uin
 static void rgs_init(struct mkfs_rgs *rgs, struct mkfs_opts *opts, struct mkfs_dev *dev, struct gfs2_sbd *sdp)
 {
 	memset(rgs, 0, sizeof(*rgs));
-	if (opts->got_sunit) {
+	if (opts->align && opts->got_sunit) {
 		if ((opts->sunit % sdp->bsize) != 0) {
 			fprintf(stderr, _("Stripe unit (%lu) must be a multiple of block size (%u)\n"),
 			        opts->sunit, sdp->bsize);
@@ -616,7 +651,7 @@ static void rgs_init(struct mkfs_rgs *rgs, struct mkfs_opts *opts, struct mkfs_d
 			rgs->align = opts->swidth / sdp->bsize;
 			rgs->align_off = opts->sunit / sdp->bsize;
 		}
-	} else {
+	} else if (opts->align) {
 		if ((dev->minimum_io_size > dev->physical_sector_size) &&
 		    (dev->optimal_io_size > dev->physical_sector_size)) {
 			rgs->align = dev->optimal_io_size / sdp->bsize;
@@ -871,7 +906,11 @@ void main_mkfs(int argc, char *argv[])
 		printf("  fssize = %"PRIu64"\n", opts.fssize);
 		printf("  sunit = %lu\n", opts.sunit);
 		printf("  swidth = %lu\n", opts.swidth);
-		printf("  rgrp align = %lu+%lu blocks\n", rgs.align, rgs.align_off);
+		printf("  rgrp align = ");
+		if (opts.align)
+			printf("%lu+%lu blocks\n", rgs.align, rgs.align_off);
+		else
+			printf("(disabled)\n");
 	}
 
 	warn_of_destruction(opts.device);
-- 
1.8.1.4



  parent reply	other threads:[~2013-06-06 12:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-06 12:03 [Cluster-devel] [PATCH 1/4] mkfs.gfs2: Set sunit and swidth from probed io limits Andrew Price
2013-06-06 12:03 ` [Cluster-devel] [PATCH 2/4] mkfs.gfs2: Align resource groups to RAID stripes Andrew Price
2013-06-06 12:06   ` Steven Whitehouse
2013-06-06 12:19     ` Andrew Price
2013-06-06 12:57   ` Bob Peterson
2013-06-06 13:04     ` Andrew Price
2013-06-06 13:17       ` Bob Peterson
2013-06-06 13:11     ` Steven Whitehouse
2013-06-06 13:30       ` Bob Peterson
2013-06-06 15:17       ` Andrew Price
2013-06-06 12:03 ` [Cluster-devel] [PATCH 3/4] mkfs.gfs2: Create new resource groups on-demand Andrew Price
2013-06-06 13:07   ` Bob Peterson
2013-06-06 13:50     ` Andrew Price
2013-06-06 12:03 ` Andrew Price [this message]
2013-06-06 12:15   ` [Cluster-devel] [PATCH 4/4] mkfs.gfs2: Add align option and update docs Steven Whitehouse
2013-06-06 12:45     ` Andrew Price
2013-06-06 12:53       ` Steven Whitehouse
2013-06-06 13:13   ` Bob Peterson
2013-06-06 13:53     ` Andrew Price

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1370520213-29676-4-git-send-email-anprice@redhat.com \
    --to=anprice@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).