From: Jeff Moyer Date: Fri, 16 Apr 2021 17:36:14 +0000 (-0400) Subject: mkfs: don't default to the physical sector size if > XFS_MAX_SECTORSIZE X-Git-Tag: v5.12.0-rc1~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=92abc149347a69ecfaa64b1f39aec43ad9b779ab;p=thirdparty%2Fxfsprogs-dev.git mkfs: don't default to the physical sector size if > XFS_MAX_SECTORSIZE 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 Reviewed-by: Eric Sandeen [sandeen: shorten subject, rebase] Signed-off-by: Eric Sandeen --- diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 36b274d5c..0eac53369 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -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;