Re: [PATCH blktests v2 4/4] common/xfs: check for max supported sector size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Feb 04, 2025 / 14:57, 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.
> 
> Signed-off-by: Luis Chamberlain <mcgrof@xxxxxxxxxx>
> ---
>  common/xfs | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/common/xfs b/common/xfs
> index 8b068837fa37..dbae572e4390 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -15,11 +15,18 @@ _xfs_mkfs_and_mount() {
>  	local mount_dir=$2
>  	local bs=$(_min_io $bdev)
>  	local xfs_logsize="64m"
> +	local sysfs="/sys/block/${bdev#/dev/}"
> +	local logical_block_size=$(cat $sysfs/queue/logical_block_size)
>  
>  	if [[ $bs -gt 4096 ]]; then
>  		xfs_logsize="128m"
>  	fi
>  
> +	if [[ $logical_block_size -gt 32768 ]]; then
> +		SKIP_REASONS+=("max sector size for XFS is 32768 but device $bdev has a larger sector size $logical_block_size")

Adding SKIP_REASONS here is not ideal, since this function is called from
test() or test_device(). It's the better to check the requirement in
requires() or device_requires(), before touching the test target devices.

If test() calls _xfs_mkfs_and_mount(), the test case should be able to
control the sector size smaller than 32k, so no need to check the
requirement. I think block/032 and nvme/012 fall in this category.

If test_device() calls _xfs_mkfs_and_mount(), it's the better to check the
requirement in device_requires(). Maybe we can add a helper function
_test_dev_suits_xfs() like below (untested) to common/xfs and call it from
device_requires(). I hope this will work for nvme/035.

_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
}

> +		return 1
> +	fi
> +
>  	mkdir -p "${mount_dir}"
>  	umount "${mount_dir}"
>  	mkfs.xfs -l size=$xfs_logsize -f "${bdev}" -b size=$bs || return $?
> -- 
> 2.45.2
> 




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux