]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: don't default to the physical sector size if > XFS_MAX_SECTORSIZE
authorJeff Moyer <jmoyer@redhat.com>
Fri, 16 Apr 2021 17:36:14 +0000 (13:36 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 16 Apr 2021 17:36:14 +0000 (13:36 -0400)
Hi,

In testing on ppc64, I ran into the following error when making a file
system:

# ./mkfs.xfs -b size=65536 -f /dev/ram0
illegal sector size 65536

Which is odd, because I didn't specify a sector size!  The problem is
that validate_sectorsize defaults to the physical sector size, but in
this case, the physical sector size is bigger than XFS_MAX_SECTORSIZE.

# cat /sys/block/ram0/queue/physical_block_size
65536

Fall back to the default (logical sector size) if the physical sector
size is greater than XFS_MAX_SECTORSIZE.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[sandeen: shorten subject, rebase]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
mkfs/xfs_mkfs.c

index 36b274d5ccb29705134fd223c9fd2de6978c9532..0eac5336962a84455ef03d2b0933e0431ac12325 100644 (file)
@@ -1898,8 +1898,14 @@ validate_sectorsize(
                if (!ft->lsectorsize)
                        ft->lsectorsize = dft->sectorsize;
 
-               /* Older kernels may not have physical/logical distinction */
-               if (!ft->psectorsize)
+               /*
+                * Older kernels may not have physical/logical distinction.
+                *
+                * Some architectures have a page size > XFS_MAX_SECTORSIZE.
+                * In that case, a ramdisk or persistent memory device may
+                * advertise a physical sector size that is too big to use.
+                */
+               if (!ft->psectorsize || ft->psectorsize > XFS_MAX_SECTORSIZE)
                        ft->psectorsize = ft->lsectorsize;
 
                cfg->sectorsize = ft->psectorsize;