mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
tests: dd: support 4 KiB alignment for direct I/O
Some file systems/device combinations reject 512-byte direct writes with EINVAL but accept 4 KiB writes. Try 4 KiB blocks before skipping the direct I/O test. * tests/dd/direct.sh: Probe 512-byte blocks first and fall back to 4 KiB blocks. Use the selected input and output block sizes in each test case, and size the short input to one byte less than a block. Link: https://github.com/coreutils/coreutils/pull/406
This commit is contained in:
1 parent
3f01618856
commit
fd366bec13
1 file changed
+16
-5
+16
-5
@@ -19,17 +19,28 @@
|
||||
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
|
||||
print_ver_ dd
|
||||
|
||||
truncate -s 8192 in || framework_failure_
|
||||
dd if=in oflag=direct of=out 2> /dev/null \
|
||||
|| skip_ '512 byte aligned O_DIRECT is not supported on this (file) system'
|
||||
# dd "$1" to 'out' using Direct I/O with the current defined $block_size
|
||||
dd_direct() {
|
||||
dd if="$1" of=out ibs=$block_size obs=$block_size iflag=direct oflag=direct
|
||||
}
|
||||
|
||||
truncate -s 511 short || framework_failure_
|
||||
truncate -s 8192 in || framework_failure_
|
||||
|
||||
block_size=512
|
||||
if ! dd_direct 'in' 2>/dev/null; then
|
||||
# Some file systems/devices require 4 KiB alignment for direct I/O.
|
||||
block_size=4096
|
||||
dd_direct 'in' 2>/dev/null ||
|
||||
skip_ 'neither 512B or 4KiB aligned DIRECT I/O succeeded'
|
||||
fi
|
||||
|
||||
truncate -s $((block_size - 1)) short || framework_failure_
|
||||
truncate -s 8191 m1 || framework_failure_
|
||||
truncate -s 8193 p1 || framework_failure_
|
||||
|
||||
for i in short m1 p1; do
|
||||
rm -f out
|
||||
dd if=$i iflag=direct oflag=direct of=out || fail=1
|
||||
dd_direct "$i" || fail=1
|
||||
done
|
||||
|
||||
Exit $fail
|
||||
Reference in new issue
Block a user