Message ID | 20250212205448.2107005-7-mcgrof@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | enable bs > ps device testing | expand |
On Feb 12, 2025 / 12:54, Luis Chamberlain wrote: > mkfs.xfs will use the sector size exposed by the device, if this > is larger than 32k this will fail as the largest sector size on XFS > is 32k. Provide a sanity check to ensure we skip creating a filesystem > if the sector size is larger than what XFS supports. > > Suggested-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com> > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> > --- > common/xfs | 11 +++++++++++ > tests/block/032 | 3 ++- > tests/nvme/012 | 1 + > tests/nvme/035 | 1 + > 4 files changed, 15 insertions(+), 1 deletion(-) > > diff --git a/common/xfs b/common/xfs > index 226fdbd1c83f..1342a8e61f0b 100644 > --- a/common/xfs > +++ b/common/xfs > @@ -10,6 +10,17 @@ _have_xfs() { > _have_fs xfs && _have_program mkfs.xfs > } > > +_test_dev_suits_xfs() { > + local logical_block_size > + > + logical_block_size=$(_test_dev_queue_get logical_block_size) > + if ((logical_block_size > 32768 )); then > + SKIP_REASONS+=("sector size ${logical_block_size} is larger than max XFS sector size 32768") > + return 1 > + fi > + return 0 > +} > + > _xfs_mkfs_and_mount() { > local bdev=$1 > local mount_dir=$2 > diff --git a/tests/block/032 b/tests/block/032 > index fc6d1a51dcad..74688f7fca6e 100755 > --- a/tests/block/032 > +++ b/tests/block/032 > @@ -15,6 +15,7 @@ QUICK=1 > requires() { > _have_xfs > _have_module scsi_debug > + _test_dev_suits_xfs I don't think this check is needed. _test_dev_suits_xfs() calls _test_dev_queue_get(), which works only for test cases with test_device(). Then, it works for nvme/035. But does not work for either block/032 or nvme/012, which prepares test target device in test(), so they do not need the check. > } > > test() { > @@ -25,7 +26,7 @@ test() { > fi > > mkdir -p "${TMPDIR}/mnt" > - _xfs_mkfs_and_mount "/dev/${SCSI_DEBUG_DEVICES[0]}" "${TMPDIR}/mnt" >> $FULL || return $? > + _xfs_mkfs_and_mount "/dev/${SCSI_DEBUG_DEVICES[0]}" "${TMPDIR}/mnt" >> "$FULL" || return $? > echo 1 > "/sys/block/${SCSI_DEBUG_DEVICES[0]}/device/delete" > udevadm settle > umount "${TMPDIR}/mnt" || return $? > diff --git a/tests/nvme/012 b/tests/nvme/012 > index f9bbdca911c0..f2727c06c893 100755 > --- a/tests/nvme/012 > +++ b/tests/nvme/012 > @@ -17,6 +17,7 @@ requires() { > _have_loop > _require_nvme_trtype_is_fabrics > _require_nvme_test_img_size 350m > + _test_dev_suits_xfs Same here. > } > > set_conditions() { > diff --git a/tests/nvme/035 b/tests/nvme/035 > index 9f84ced53ce6..14aa8c22956b 100755 > --- a/tests/nvme/035 > +++ b/tests/nvme/035 > @@ -14,6 +14,7 @@ requires() { > _have_kernel_option NVME_TARGET_PASSTHRU > _have_xfs > _have_fio > + _test_dev_suits_xfs This is the requirement check for TEST_DEV, so I suggest to move it from requires() to device_requires(). > } > > device_requires() { > -- > 2.45.2 >
diff --git a/common/xfs b/common/xfs index 226fdbd1c83f..1342a8e61f0b 100644 --- a/common/xfs +++ b/common/xfs @@ -10,6 +10,17 @@ _have_xfs() { _have_fs xfs && _have_program mkfs.xfs } +_test_dev_suits_xfs() { + local logical_block_size + + logical_block_size=$(_test_dev_queue_get logical_block_size) + if ((logical_block_size > 32768 )); then + SKIP_REASONS+=("sector size ${logical_block_size} is larger than max XFS sector size 32768") + return 1 + fi + return 0 +} + _xfs_mkfs_and_mount() { local bdev=$1 local mount_dir=$2 diff --git a/tests/block/032 b/tests/block/032 index fc6d1a51dcad..74688f7fca6e 100755 --- a/tests/block/032 +++ b/tests/block/032 @@ -15,6 +15,7 @@ QUICK=1 requires() { _have_xfs _have_module scsi_debug + _test_dev_suits_xfs } test() { @@ -25,7 +26,7 @@ test() { fi mkdir -p "${TMPDIR}/mnt" - _xfs_mkfs_and_mount "/dev/${SCSI_DEBUG_DEVICES[0]}" "${TMPDIR}/mnt" >> $FULL || return $? + _xfs_mkfs_and_mount "/dev/${SCSI_DEBUG_DEVICES[0]}" "${TMPDIR}/mnt" >> "$FULL" || return $? echo 1 > "/sys/block/${SCSI_DEBUG_DEVICES[0]}/device/delete" udevadm settle umount "${TMPDIR}/mnt" || return $? diff --git a/tests/nvme/012 b/tests/nvme/012 index f9bbdca911c0..f2727c06c893 100755 --- a/tests/nvme/012 +++ b/tests/nvme/012 @@ -17,6 +17,7 @@ requires() { _have_loop _require_nvme_trtype_is_fabrics _require_nvme_test_img_size 350m + _test_dev_suits_xfs } set_conditions() { diff --git a/tests/nvme/035 b/tests/nvme/035 index 9f84ced53ce6..14aa8c22956b 100755 --- a/tests/nvme/035 +++ b/tests/nvme/035 @@ -14,6 +14,7 @@ requires() { _have_kernel_option NVME_TARGET_PASSTHRU _have_xfs _have_fio + _test_dev_suits_xfs } device_requires() {
mkfs.xfs will use the sector size exposed by the device, if this is larger than 32k this will fail as the largest sector size on XFS is 32k. Provide a sanity check to ensure we skip creating a filesystem if the sector size is larger than what XFS supports. Suggested-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> --- common/xfs | 11 +++++++++++ tests/block/032 | 3 ++- tests/nvme/012 | 1 + tests/nvme/035 | 1 + 4 files changed, 15 insertions(+), 1 deletion(-)