Use the min_dio_alignment C tool to check the minimum alignment.
This allows using the values obtained from statx instead of just guessing
based on the sector size and page size.
For tests using the scratch device this sometimes required moving code
around a bit to ensure the scratch device is actually mounted before
querying the alignment.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
printf '%s\n' "$args"
}
-#
-# Return the logical block size if running on a block device,
-# else substitute the page size.
-#
-_min_dio_alignment()
-{
- local dev=$1
-
- if [ -b "$dev" ]; then
- blockdev --getss $dev
- else
- $here/src/feature -s
- fi
-}
-
run_check()
{
echo "# $@" >> $seqres.full 2>&1
_require_odirect
psize=`$here/src/feature -s`
-bsize=`_min_dio_alignment $TEST_DEV`
+bsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
# fsx usage:
#
_require_odirect
_require_aio
+_scratch_mkfs >>$seqres.full 2>&1
+_scratch_mount
+
iodepth=$((16 * LOAD_FACTOR))
iodepth_batch=$((8 * LOAD_FACTOR))
numjobs=$((5 * LOAD_FACTOR))
fio_config=$tmp.fio
fio_out=$tmp.fio.out
-blksz=$(_min_dio_alignment $SCRATCH_DEV)
+blksz=`$here/src/min_dio_alignment $SCRATCH_MNT $SCRATCH_DEV`
cat >$fio_config <<EOF
[global]
bs=8k
echo 'bs=$pagesize' >> $fio_config
_require_fio $fio_config
-_scratch_mkfs >>$seqres.full 2>&1
-_scratch_mount
# There's a known EIO failure to report collisions between directio and buffered
# writes to userspace, refer to upstream linux 5a9d929d6e13. So ignore EIO error
_require_aiodio aio-dio-eof-race
# Test does 512 byte DIO, so make sure that'll work
-logical_block_size=`_min_dio_alignment $TEST_DEV`
+logical_block_size=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
if [ "$logical_block_size" -gt "512" ]; then
_notrun "device block size: $logical_block_size greater than 512"
rm -f $TEST_DIR/aiodio_sparse
-logical_block_size=`_min_dio_alignment $TEST_DEV`
+logical_block_size=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
fs_block_size=`_get_block_size $TEST_DIR`
file_size=$((8 * $fs_block_size))
bufnr=128
filesize=$((blksz * nr))
bufsize=$((blksz * bufnr))
-alignment=`_min_dio_alignment $TEST_DEV`
+alignment=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 5 / 4))
_require_odirect
psize=`$here/src/feature -s`
-bsize=`_min_dio_alignment $TEST_DEV`
+bsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
run_fsx -N 10000 -o 8192 -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z
run_fsx -N 10000 -o 128000 -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z
bufnr=128
filesize=$((blksz * nr))
bufsize=$((blksz * bufnr))
-alignment=`_min_dio_alignment $TEST_DEV`
+alignment=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
bufnr=128
filesize=$((blksz * nr))
bufsize=$((blksz * bufnr))
-alignment=`_min_dio_alignment $TEST_DEV`
+alignment=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
_require_odirect
tfile=$TEST_DIR/testfile_${seq}
-ssize=`_min_dio_alignment $TEST_DEV`
+ssize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
bsize=`_get_block_size $TEST_DIR`
# let's focus on the specific bug that only happens when $ssize <= $bsize
_require_test_program "feature"
testfile=$TEST_DIR/$seq.$$
-min_dio_align=`_min_dio_alignment $TEST_DEV`
+min_dio_align=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
page_size=`$here/src/feature -s`
echo "non-aio dio test"
_require_aiodio aio-dio-write-verify
localfile=$TEST_DIR/${seq}-aio-dio-write-verify-testfile
-diosize=`_min_dio_alignment $TEST_DEV`
+diosize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
blocksize=`_get_block_size $TEST_DIR`
bufsize=$((blocksize * 2))
truncsize=$((bufsize+diosize))
_scratch_mount
localfile=$SCRATCH_MNT/testfile
-diosize=`_min_dio_alignment $SCRATCH_DEV`
+diosize=`$here/src/min_dio_alignment $SCRATCH_MNT $SCRATCH_DEV`
# The maximum write size and offset are both 32k diosize. So the maximum
# file size will be (32 * 2)k
_require_odirect
_require_test_program "splice-test"
-diosize=`_min_dio_alignment $TEST_DEV`
+diosize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
$here/src/splice-test -s $diosize -r $TEST_DIR/a
$here/src/splice-test -rd $TEST_DIR/a
# For this test we use block size = 1/8 page size
pgsize=`$here/src/feature -s`
blksize=`expr $pgsize / 8`
-secsize=`_min_dio_alignment $SCRATCH_DEV`
-
-if [ $secsize -gt $blksize ];then
- _notrun "sector size($secsize) too large for platform page size($pgsize)"
-fi
# Filter out file mountpoint and physical location info
# Input:
# we need 512 byte block size, so crc's are turned off
_scratch_mkfs_xfs -m crc=0 -b size=$blksize >/dev/null 2>&1
_scratch_mount
+
+secsize=`$here/src/min_dio_alignment $SCRATCH_MNT $SCRATCH_DEV`
+if [ $secsize -gt $blksize ];then
+ _notrun "sector size($secsize) too large for platform page size($pgsize)"
+fi
+
test "$(_get_block_size $SCRATCH_MNT)" = $blksize || \
_notrun "Could not get $blksize-byte blocks"
file=$SCRATCH_MNT/f
-min_align=`_min_dio_alignment $SCRATCH_DEV`
-
do_pwrite()
{
+ min_align=$3
offset=`expr $1 \* $min_align`
end=`expr $2 \* $min_align`
length=`expr $end - $offset`
_scratch_mkfs_xfs >/dev/null 2>&1
_scratch_mount
+min_align=`$here/src/min_dio_alignment $SCRATCH_MNT $SCRATCH_DEV`
+
# Create a fragmented file
-do_pwrite 30792 31039
-do_pwrite 30320 30791
-do_pwrite 29688 30319
-do_pwrite 29536 29687
-do_pwrite 27216 29535
-do_pwrite 24368 27215
-do_pwrite 21616 24367
-do_pwrite 20608 21615
-do_pwrite 19680 20607
-do_pwrite 19232 19679
-do_pwrite 17840 19231
-do_pwrite 16928 17839
-do_pwrite 15168 16927
-do_pwrite 14048 15167
-do_pwrite 12152 14047
-do_pwrite 11344 12151
-do_pwrite 8792 11343
-do_pwrite 6456 8791
-do_pwrite 5000 6455
-do_pwrite 1728 4999
-do_pwrite 0 1727
+do_pwrite 30792 31039 $min_align
+do_pwrite 30320 30791 $min_align
+do_pwrite 29688 30319 $min_align
+do_pwrite 29536 29687 $min_align
+do_pwrite 27216 29535 $min_align
+do_pwrite 24368 27215 $min_align
+do_pwrite 21616 24367 $min_align
+do_pwrite 20608 21615 $min_align
+do_pwrite 19680 20607 $min_align
+do_pwrite 19232 19679 $min_align
+do_pwrite 17840 19231 $min_align
+do_pwrite 16928 17839 $min_align
+do_pwrite 15168 16927 $min_align
+do_pwrite 14048 15167 $min_align
+do_pwrite 12152 14047 $min_align
+do_pwrite 11344 12151 $min_align
+do_pwrite 8792 11343 $min_align
+do_pwrite 6456 8791 $min_align
+do_pwrite 5000 6455 $min_align
+do_pwrite 1728 4999 $min_align
+do_pwrite 0 1727 $min_align
sync
sync
bufnr=128
filesize=$((blksz * nr))
bufsize=$((blksz * bufnr))
-alignment=`_min_dio_alignment $TEST_DEV`
+alignment=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
_require_congruent_file_oplen $SCRATCH_MNT $blksz
bufsize=$((blksz * bufnr))
filesize=$filesize
bufsize=$bufsize
-alignment=`_min_dio_alignment $TEST_DEV`
+alignment=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
# All sector numbers that we feed to the kernel must be in units of 512b, but
# they also must be aligned to the device's logical block size.
-logical_block_size=$(_min_dio_alignment $SCRATCH_DEV)
+logical_block_size=`$here/src/min_dio_alignment $SCRATCH_MNT $SCRATCH_DEV`
kernel_sectors_per_device_lba=$((logical_block_size / 512))
# Mark as bad one of the device LBAs in the middle of the extent. Target the