From: Christoph Hellwig Date: Wed, 29 Oct 2025 09:07:29 +0000 (+0100) Subject: mkfs: move clearing LIBXFS_DIRECT into check_device_type X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=586ee95d8098205bd878f59a5b957c2a95823199;p=thirdparty%2Fxfsprogs-dev.git mkfs: move clearing LIBXFS_DIRECT into check_device_type Keep it close to the block device vs regular file logic and remove the checks for each device in the caller. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index cb7c20e3..3ccd3792 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -1330,6 +1330,7 @@ nr_cpus(void) static void check_device_type( + struct cli_params *cli, struct libxfs_dev *dev, bool no_size, bool dry_run, @@ -1375,6 +1376,13 @@ check_device_type( dev->isfile = 1; else if (!dry_run) dev->create = 1; + + /* + * Explicitly disable direct IO for image files so we don't + * error out on sector size mismatches between the new + * filesystem and the underlying host filesystem. + */ + cli->xi->flags &= ~LIBXFS_DIRECT; return; } @@ -2378,21 +2386,14 @@ validate_sectorsize( * Before anything else, verify that we are correctly operating on * files or block devices and set the control parameters correctly. */ - check_device_type(&cli->xi->data, !cli->dsize, dry_run, "data", "d"); + check_device_type(cli, &cli->xi->data, !cli->dsize, dry_run, + "data", "d"); if (!cli->loginternal) - check_device_type(&cli->xi->log, !cli->logsize, dry_run, "log", - "l"); + check_device_type(cli, &cli->xi->log, !cli->logsize, dry_run, + "log", "l"); if (cli->xi->rt.name) - check_device_type(&cli->xi->rt, !cli->rtsize, dry_run, "RT", - "r"); - - /* - * Explicitly disable direct IO for image files so we don't error out on - * sector size mismatches between the new filesystem and the underlying - * host filesystem. - */ - if (cli->xi->data.isfile || cli->xi->log.isfile || cli->xi->rt.isfile) - cli->xi->flags &= ~LIBXFS_DIRECT; + check_device_type(cli, &cli->xi->rt, !cli->rtsize, dry_run, + "RT", "r"); memset(ft, 0, sizeof(*ft)); get_topology(cli->xi, ft, force_overwrite);