]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commit
fstests: fix min_dio_alignment logic for getting device block size
authorFilipe Manana <fdmanana@suse.com>
Mon, 16 Sep 2024 12:03:12 +0000 (13:03 +0100)
committerZorro Lang <zlang@kernel.org>
Thu, 19 Sep 2024 20:08:48 +0000 (04:08 +0800)
commit185d797c73e1d9313d70e362ea7fcd2d1daa7832
tree1764eda1d5c052f52799ccfe765126d4d6a822ad
parent9b41da945b200087ca9bb0dc59bff62505ddcd74
fstests: fix min_dio_alignment logic for getting device block size

If we failed to get the dio alignment from statx we try to get the
device's block size using the BLKSSZGET ioctl, however we failed to
return it because we don't check if the ioctl succeeded (returned 0).
Furthermore in case the ioctl returned an error, we end up returning an
undefined value since the 'logical_block_size' variable ends up not
being initialized.

This was causing some tests to be skipped on btrfs after commit
ee799a0cf1d4 ("replace _min_dio_alignment with calls to
src/min_dio_alignment"), like generic/240 for example:

  $ ./check generic/240
  FSTYP         -- btrfs
  PLATFORM      -- Linux/x86_64 debian0 6.11.0-rc7-btrfs-next-174+ #1 SMP PREEMPT_DYNAMIC Tue Sep 10 17:11:38 WEST 2024
  MKFS_OPTIONS  -- /dev/sdc
  MOUNT_OPTIONS -- /dev/sdc /home/fdmanana/btrfs-tests/scratch_1

  generic/240 1s ... [not run] fs block size must be larger than the device block size.  fs block size: 4096, device block size: 4096
  Ran: generic/240
  Not run: generic/240
  Passed all 1 tests

Where before that commit the test ran.

Fix this by checking that the ioctl succeeded.

Fixes: 0e5f196d0a6a ("add a new min_dio_alignment helper")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
src/min_dio_alignment.c