All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Iliopoulos <ailiop@suse.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 4/6] mkfs: introduce -y option to force incompat config combinations
Date: Mon, 24 Aug 2020 22:37:22 +0200	[thread overview]
Message-ID: <20200824203724.13477-5-ailiop@suse.com> (raw)
In-Reply-To: <20200824203724.13477-1-ailiop@suse.com>

Introduce a new command line option that can be used to override bailing
out on combinations of incompatible configurations and other warnings.

The -f option is currently overloaded to include these semantics, but it
conceals cases where there is an fs signature detected and confirmation
is required to overwrite the filesystem.

Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
---
 libfrog/topology.c  | 14 +++++++-------
 man/man8/mkfs.xfs.8 |  6 ++++++
 mkfs/xfs_mkfs.c     | 16 ++++++++++------
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/libfrog/topology.c b/libfrog/topology.c
index 713358b01b4c..ad317fe4e287 100644
--- a/libfrog/topology.c
+++ b/libfrog/topology.c
@@ -181,7 +181,7 @@ static void blkid_get_topology(
 	int		*lsectorsize,
 	int		*psectorsize,
 	int		*dax,
-	int		force_overwrite)
+	int		force)
 {
 
 	blkid_topology tp;
@@ -240,9 +240,9 @@ static void blkid_get_topology(
 			_("warning: device is not properly aligned %s\n"),
 			device);
 
-		if (!force_overwrite) {
+		if (!force) {
 			fprintf(stderr,
-				_("Use -f to force usage of a misaligned device\n"));
+				_("Use -y to force usage of a misaligned device\n"));
 
 			exit(EXIT_FAILURE);
 		}
@@ -281,7 +281,7 @@ static void blkid_get_topology(
 	int		*lsectorsize,
 	int		*psectorsize,
 	int		*dax,
-	int		force_overwrite)
+	int		force)
 {
 	/*
 	 * Shouldn't make any difference (no blkid = no block device access),
@@ -296,7 +296,7 @@ static void blkid_get_topology(
 void get_topology(
 	libxfs_init_t		*xi,
 	struct fs_topology	*ft,
-	int			force_overwrite)
+	int			force)
 {
 	struct stat statbuf;
 	char *dfile = xi->volname ? xi->volname : xi->dname;
@@ -326,7 +326,7 @@ void get_topology(
 	} else {
 		blkid_get_topology(dfile, &ft->dsunit, &ft->dswidth,
 				   &ft->lsectorsize, &ft->psectorsize,
-				   &ft->dax, force_overwrite);
+				   &ft->dax, force);
 	}
 
 	if (xi->rtname && !xi->risfile) {
@@ -334,6 +334,6 @@ void get_topology(
 
 		blkid_get_topology(xi->rtname, &sunit, &ft->rtswidth,
 				   &lsectorsize, &psectorsize, &ft->dax,
-				   force_overwrite);
+				   force);
 	}
 }
diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8
index 9d762a43011a..d84db416db1b 100644
--- a/man/man8/mkfs.xfs.8
+++ b/man/man8/mkfs.xfs.8
@@ -41,6 +41,8 @@ mkfs.xfs \- construct an XFS filesystem
 .B \-N
 ] [
 .B \-K
+] [
+.B \-y
 ]
 .I device
 .br
@@ -919,6 +921,10 @@ Do not attempt to discard blocks at mkfs time.
 .TP
 .B \-V
 Prints the version number and exits.
+.TP
+.B \-y
+Override warnings and force usage of incompatible features.
+.TP
 .SH SEE ALSO
 .BR xfs (5),
 .BR mkfs (8),
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index b8739c2b9093..75e910dd4a30 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1813,7 +1813,7 @@ _("warning: block size should match platform page size on dax devices.\n"));
 
 		if (!force) {
 			fprintf(stderr,
-				_("Use -f to force usage of block size\n"));
+				_("Use -y to force usage of block size\n"));
 			usage();
 		}
 	}
@@ -2010,7 +2010,7 @@ _("rmapbt not supported with realtime devices\n"));
 
 		if (!force) {
 			fprintf(stderr,
-				_("Use -f to force enabling reflink\n"));
+				_("Use -y to force enabling reflink\n"));
 			usage();
 		}
 	}
@@ -3586,6 +3586,7 @@ main(
 	int			dry_run = 0;
 	int			discard = 1;
 	int			force_overwrite = 0;
+	int			force = 0;
 	int			quiet = 0;
 	char			*protofile = NULL;
 	char			*protostring = NULL;
@@ -3658,7 +3659,7 @@ main(
 	memcpy(&cli.sb_feat, &dft.sb_feat, sizeof(cli.sb_feat));
 	memcpy(&cli.fsx, &dft.fsx, sizeof(cli.fsx));
 
-	while ((c = getopt(argc, argv, "b:d:i:l:L:m:n:KNp:qr:s:CfV")) != EOF) {
+	while ((c = getopt(argc, argv, "b:d:i:l:L:m:n:KNp:qr:s:CfVy")) != EOF) {
 		switch (c) {
 		case 'C':
 		case 'f':
@@ -3696,6 +3697,9 @@ main(
 		case 'V':
 			printf(_("%s version %s\n"), progname, VERSION);
 			exit(0);
+		case 'y':
+			force = 1;
+			break;
 		default:
 			unknown(optopt, "");
 		}
@@ -3714,8 +3718,8 @@ main(
 	 * Extract as much of the valid config as we can from the CLI input
 	 * before opening the libxfs devices.
 	 */
-	get_topology(cli.xi, &ft, force_overwrite);
-	validate_blocksize(&cfg, &cli, &dft, &ft, force_overwrite);
+	get_topology(cli.xi, &ft, force);
+	validate_blocksize(&cfg, &cli, &dft, &ft, force);
 	validate_sectorsize(&cfg, &cli, &dft, &ft, dfile, dry_run);
 
 	/*
@@ -3726,7 +3730,7 @@ main(
 	sectorsize = cfg.sectorsize;
 
 	validate_log_sectorsize(&cfg, &cli, &dft);
-	validate_sb_features(&cfg, &cli, &ft, force_overwrite);
+	validate_sb_features(&cfg, &cli, &ft, force);
 
 	/*
 	 * we've now completed basic validation of the features, sector and
-- 
2.28.0


  parent reply	other threads:[~2020-08-24 20:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-24 20:37 [PATCH 0/6] xfsprogs: blockdev dax detection and warnings Anthony Iliopoulos
2020-08-24 20:37 ` [PATCH 1/6] libfrog: add dax capability detection in topology probing Anthony Iliopoulos
2020-08-24 20:37 ` [PATCH 2/6] mkfs: warn if blocksize doesn't match pagesize on dax devices Anthony Iliopoulos
2020-08-24 20:37 ` [PATCH 3/6] mkfs: warn if reflink option is enabled on dax-capable devices Anthony Iliopoulos
2020-08-24 20:37 ` Anthony Iliopoulos [this message]
2020-08-24 20:37 ` [PATCH 5/6] mkfs: remove redundant assignment of cli sb options on failure Anthony Iliopoulos
2020-09-28 21:49   ` Eric Sandeen
2020-09-28 21:56     ` Eric Sandeen
2020-08-24 20:37 ` [PATCH 6/6] mkfs: remove a couple of unused function parameters Anthony Iliopoulos
2020-09-28 21:50   ` Eric Sandeen
2020-08-24 22:55 ` [PATCH 0/6] xfsprogs: blockdev dax detection and warnings Dave Chinner
2020-08-25  8:48   ` Anthony Iliopoulos
2020-08-25 13:59   ` Eric Sandeen
2020-08-25 14:40     ` Darrick J. Wong
2020-08-25 22:31       ` Dave Chinner
2020-08-25 15:09     ` Anthony Iliopoulos
2020-08-25 17:32       ` Eric Sandeen

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=20200824203724.13477-5-ailiop@suse.com \
    --to=ailiop@suse.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.