]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: use a default sector size that is also suitable for the rtdev
authorChristoph Hellwig <hch@lst.de>
Mon, 27 Jan 2025 13:54:03 +0000 (14:54 +0100)
committerAndrey Albershteyn <aalbersh@kernel.org>
Wed, 29 Jan 2025 09:32:10 +0000 (10:32 +0100)
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 <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
mkfs/xfs_mkfs.c

index 073e79ac58303c9d9534324f3d1cecdbcd2b1ad8..f5556fcc4040ed121d9c9f3ac1cdb985b01278b2 100644 (file)
@@ -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,