From: Christoph Hellwig Date: Mon, 27 Jan 2025 13:54:03 +0000 (+0100) Subject: mkfs: use a default sector size that is also suitable for the rtdev X-Git-Tag: v6.13.0~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c988ff56258abf338bf0403323cfe0a4d173de3a;p=thirdparty%2Fxfsprogs-dev.git mkfs: use a default sector size that is also suitable for the rtdev When creating a filesytem where the data device has a sector size smalle than that of the RT device without further options, mkfs currently fails with: mkfs.xfs: error - cannot set blocksize 512 on block device $RTDEV: Invalid argument This is because XFS sets the sector size based on logical block size of the data device, but not that of the RT device. Change the code so that is uses the larger of the two values. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 073e79ac..f5556fcc 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -2299,7 +2299,9 @@ validate_sectorsize( * advertised sector size of the device. We use the physical * sector size unless the requested block size is smaller * than that, then we can use logical, but warn about the - * inefficiency. + * inefficiency. If the file system has a RT device, the + * sectorsize needs to be the maximum of the data and RT + * device. * * Some architectures have a page size > XFS_MAX_SECTORSIZE. * In that case, a ramdisk or persistent memory device may @@ -2309,8 +2311,18 @@ validate_sectorsize( ft->data.physical_sector_size = ft->data.logical_sector_size; } - cfg->sectorsize = ft->data.physical_sector_size; + + if (cli->xi->rt.name) { + if (ft->rt.physical_sector_size > XFS_MAX_SECTORSIZE) { + ft->rt.physical_sector_size = + ft->rt.logical_sector_size; + } + + if (cfg->sectorsize < ft->rt.physical_sector_size) + cfg->sectorsize = ft->rt.physical_sector_size; + } + if (cfg->blocksize < cfg->sectorsize && cfg->blocksize >= ft->data.logical_sector_size) { fprintf(stderr,