[PATCH 2/6] mkfs: warn if blocksize doesn't match pagesize on dax devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Block devices that are dax-capable require that the blocksize matches
the platform page size in order to enable dax. Warn if this is not the
case during mkfs, to make it clear that the filesystem will not be
mountable with the dax option enabled.

Make the option overridable so that incompatible filesystem configs 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@xxxxxxxx>
---
 mkfs/xfs_mkfs.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 2e6cd280e388..4fe0bbdcc40c 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1693,8 +1693,7 @@ validate_sectorsize(
 	struct mkfs_default_params *dft,
 	struct fs_topology	*ft,
 	char			*dfile,
-	int			dry_run,
-	int			force_overwrite)
+	int			dry_run)
 {
 	/*
 	 * Before anything else, verify that we are correctly operating on
@@ -1719,9 +1718,6 @@ validate_sectorsize(
 	if (cli->xi->disfile || cli->xi->lisfile || cli->xi->risfile)
 		cli->xi->isdirect = 0;
 
-	memset(ft, 0, sizeof(*ft));
-	get_topology(cli->xi, ft, force_overwrite);
-
 	/* set configured sector sizes in preparation for checks */
 	if (!cli->sectorsize) {
 		/*
@@ -1781,7 +1777,9 @@ static void
 validate_blocksize(
 	struct mkfs_params	*cfg,
 	struct cli_params	*cli,
-	struct mkfs_default_params *dft)
+	struct mkfs_default_params *dft,
+	struct fs_topology	*ft,
+	int			force)
 {
 	/*
 	 * Blocksize and sectorsize first, other things depend on them
@@ -1809,6 +1807,16 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
 		usage();
 	}
 
+	if (ft->dax && cfg->blocksize != getpagesize()) {
+		fprintf(stderr,
+_("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"));
+			usage();
+		}
+	}
 }
 
 /*
@@ -3694,9 +3702,9 @@ main(
 	 * Extract as much of the valid config as we can from the CLI input
 	 * before opening the libxfs devices.
 	 */
-	validate_blocksize(&cfg, &cli, &dft);
-	validate_sectorsize(&cfg, &cli, &dft, &ft, dfile, dry_run,
-			    force_overwrite);
+	get_topology(cli.xi, &ft, force_overwrite);
+	validate_blocksize(&cfg, &cli, &dft, &ft, force_overwrite);
+	validate_sectorsize(&cfg, &cli, &dft, &ft, dfile, dry_run);
 
 	/*
 	 * XXX: we still need to set block size and sector size global variables
-- 
2.28.0




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux