diff mbox series

[3/6] mkfs: warn if reflink option is enabled on dax-capable devices

Message ID 20200824203724.13477-4-ailiop@suse.com (mailing list archive)
State New, archived
Headers show
Series xfsprogs: blockdev dax detection and warnings | expand

Commit Message

Anthony Iliopoulos Aug. 24, 2020, 8:37 p.m. UTC
Reflink is currently not supported in conjunction with dax. Warn if this
config is enabled during mkfs to make it clear that the filesystem will
not be mountable with reflinks and dax enabled.

Make the option overridable so that incompatible fs configurations can
still be created, e.g. for testing or for cases where the filesystem is
not intended to be mounted with the dax option switched on.

Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
---
 mkfs/xfs_mkfs.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 4fe0bbdcc40c..b8739c2b9093 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1883,7 +1883,9 @@  _("log stripe unit specified, using v2 logs\n"));
 static void
 validate_sb_features(
 	struct mkfs_params	*cfg,
-	struct cli_params	*cli)
+	struct cli_params	*cli,
+	struct fs_topology	*ft,
+	int			force)
 {
 	/*
 	 * Now we have blocks and sector sizes set up, check parameters that are
@@ -2003,6 +2005,16 @@  _("rmapbt not supported with realtime devices\n"));
 		cli->sb_feat.rmapbt = false;
 	}
 
+	if (cli->sb_feat.reflink && ft->dax) {
+		fprintf(stderr, _("reflink not supported with dax devices\n"));
+
+		if (!force) {
+			fprintf(stderr,
+				_("Use -f to force enabling reflink\n"));
+			usage();
+		}
+	}
+
 	/*
 	 * Copy features across to config structure now.
 	 */
@@ -3714,7 +3726,7 @@  main(
 	sectorsize = cfg.sectorsize;
 
 	validate_log_sectorsize(&cfg, &cli, &dft);
-	validate_sb_features(&cfg, &cli);
+	validate_sb_features(&cfg, &cli, &ft, force_overwrite);
 
 	/*
 	 * we've now completed basic validation of the features, sector and