]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
generic: check logical-sector sized O_DIRECT
authorZorro Lang <zlang@kernel.org>
Mon, 7 Nov 2022 04:56:18 +0000 (12:56 +0800)
committerZorro Lang <zlang@kernel.org>
Wed, 23 Nov 2022 03:55:03 +0000 (11:55 +0800)
If the physical sector size is 4096, but the logical sector size
is 512, the 512b dio write/read should be allowed.

Signed-off-by: Zorro Lang <zlang@kernel.org>
Reviewed-by: Andrey Albershteyn <aalbersh@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/generic/704 [new file with mode: 0755]
tests/generic/704.out [new file with mode: 0644]

diff --git a/tests/generic/704 b/tests/generic/704
new file mode 100755 (executable)
index 0000000..c0142a6
--- /dev/null
@@ -0,0 +1,52 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test No. 704
+#
+# Make sure logical-sector sized O_DIRECT write is allowed
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+# Override the default cleanup function.
+_cleanup()
+{
+       cd /
+       rm -r -f $tmp.*
+       [ -d "$SCSI_DEBUG_MNT" ] && $UMOUNT_PROG $SCSI_DEBUG_MNT 2>/dev/null
+       _put_scsi_debug_dev
+}
+
+# Import common functions.
+. ./common/scsi_debug
+
+# real QA test starts here
+_supported_fs generic
+_fixed_by_kernel_commit 7c71ee78031c "xfs: allow logical-sector sized O_DIRECT"
+_require_scsi_debug
+# If TEST_DEV is block device, make sure current fs is a localfs which can be
+# written on scsi_debug device
+_require_test
+_require_block_device $TEST_DEV
+
+echo "Get a device with 4096 physical sector size and 512 logical sector size"
+SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 256`
+blockdev --getpbsz --getss $SCSI_DEBUG_DEV
+
+echo "mkfs and mount"
+_mkfs_dev $SCSI_DEBUG_DEV || _fail "Can't make $FSTYP on scsi_debug device"
+SCSI_DEBUG_MNT="$TEST_DIR/scsi_debug_$seq"
+rm -rf $SCSI_DEBUG_MNT
+mkdir $SCSI_DEBUG_MNT
+run_check _mount $SCSI_DEBUG_DEV $SCSI_DEBUG_MNT
+
+echo "DIO read/write 512 bytes"
+# This dio write should succeed, even the physical sector size is 4096, but
+# the logical sector size is 512
+$XFS_IO_PROG -d -f -c "pwrite 0 512" $SCSI_DEBUG_MNT/testfile >> $seqres.full
+$XFS_IO_PROG -d -c "pread 0 512" $SCSI_DEBUG_MNT/testfile >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/704.out b/tests/generic/704.out
new file mode 100644 (file)
index 0000000..b7e8cd2
--- /dev/null
@@ -0,0 +1,6 @@
+QA output created by 704
+Get a device with 4096 physical sector size and 512 logical sector size
+4096
+512
+mkfs and mount
+DIO read/write 512 bytes