On Feb 12, 2025 / 12:54, Luis Chamberlain wrote: > When using fio we should not issue IOs smaller than the device supports. > Today a lot of places have in place 4k, but soon we will have devices > which support bs > ps. For those devices we should check the minimum > supported IO. > > However, since we also have a min optimal IO, we might as well use that > as well. By using this we can also leverage the same lookup with stat > whether or not the target file is a block device or a file. > > Signed-off-by: Luis Chamberlain <mcgrof@xxxxxxxxxx> > --- > common/fio | 26 ++++++++++++++++++++++++-- > common/rc | 24 ++++++++++++++++++++++++ > 2 files changed, 48 insertions(+), 2 deletions(-) > > diff --git a/common/fio b/common/fio > index b9ea087fc6c5..d147214f3d16 100644 > --- a/common/fio > +++ b/common/fio > @@ -189,15 +189,37 @@ _run_fio() { > return $rc > } > > +_fio_opts_to_min_io() { > + local arg path > + local -i min_io=4096 > + > + for arg in "$@"; do Still spaces are left in the linve above. > + [[ "$arg" =~ ^--filename= || "$arg" =~ --directory= ]] || continue > + path="${arg##*=}" > + min_io=$(_min_io "$path") > + # Keep 4K minimum IO size for historical consistency > + ((min_io < 4096)) && min_io=4096 I think the 4k comparison above is no longer required, since you added it in _min_io(). > + break > + done > + > + echo "$min_io" > +} > + > # Wrapper around _run_fio used if you need some I/O but don't really care much > # about the details > _run_fio_rand_io() { > - _run_fio --bs=4k --rw=randread --norandommap --numjobs="$(nproc)" \ > + local bs > + > + bs=$(_fio_opts_to_min_io "$@") || return 1 > + _run_fio --bs="$bs" --rw=randread --norandommap --numjobs="$(nproc)" \ > --name=reads --direct=1 "$@" > } > > _run_fio_verify_io() { > - _run_fio --name=verify --rw=randwrite --direct=1 --ioengine=libaio --bs=4k \ > + local bs > + > + bs=$(_fio_opts_to_min_io "$@") || return 1 > + _run_fio --name=verify --rw=randwrite --direct=1 --ioengine=libaio --bs="$bs" \ > --iodepth=16 --verify=crc32c --verify_state_save=0 "$@" > } > > diff --git a/common/rc b/common/rc > index a7e899cfb419..6e7bddc844bf 100644 > --- a/common/rc > +++ b/common/rc > @@ -400,6 +400,30 @@ _test_dev_is_partition() { > [[ -n ${TEST_DEV_PART_SYSFS} ]] > } > > +_min_io() { > + local path_or_dev=$1 > + local min_io=4096 > + if [ -z "$path_or_dev" ]; then > + echo "path for min_io does not exist" > + return 1 > + fi > + > + if [ -c "$path_or_dev" ]; then > + if [[ "$path_or_dev" == /dev/ng* ]]; then > + path_or_dev="${path_or_dev/ng/nvme}" > + fi > + fi > + > + if [ -e "$path_or_dev" ]; then > + min_io=$(stat --printf=%o "$path_or_dev") > + ((min_io < 4096)) && min_io=4096 > + echo "$min_io" Here's the added check, so _min_io() return value is always 4k or larger, isn't it? > + else > + echo "Error: '$path_or_dev' does not exist or is not accessible" > + return 1 > + fi > +} > + > # Return max open zones or max active zones of the test target device. > # If the device has both, return smaller value. > _test_dev_max_open_active_zones() { > -- > 2.45.2 >