From: Zorro Lang <zlang@kernel.org>
To: fstests@vger.kernel.org
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH] generic: check logical-sector sized O_DIRECT
Date: Mon, 7 Nov 2022 12:56:18 +0800 [thread overview]
Message-ID: <20221107045618.2772009-1-zlang@kernel.org> (raw)
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>
---
Hi,
This reproducer was written for xfs, I try to make it to be a generic
test case for localfs. Current it test passed on xfs, extN and btrfs,
the bug can be reproduced on old rhel-6.6 [1]. If it's not right for
someone fs, please feel free to tell me.
Thanks,
Zorro
[1]
# ./check generic/888
FSTYP -- xfs (non-debug)
PLATFORM -- Linux/x86_64 xxx-xxxxx-xxxxxx 2.6.32-504.el6.x86_64
MKFS_OPTIONS -- -f -bsize=4096 /dev/loop1
MOUNT_OPTIONS -- -o context=system_u:object_r:nfs_t:s0 /dev/loop1 /mnt/scratch
generic/888 - output mismatch (see /root/xfstests-dev/results//generic/888.out.bad)
--- tests/generic/888.out 2022-11-06 23:42:44.683040977 -0500
+++ /root/xfstests-dev/results//generic/888.out.bad 2022-11-06 23:48:33.986481844 -0500
@@ -4,3 +4,4 @@
512
mkfs and mount
DIO read/write 512 bytes
+pwrite64: Invalid argument
...
(Run 'diff -u tests/generic/888.out /root/xfstests-dev/results//generic/888.out.bad' to see the entire diff)
Ran: generic/888
Failures: generic/888
Failed 1 of 1 tests
tests/generic/888 | 52 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/888.out | 6 +++++
2 files changed, 58 insertions(+)
create mode 100755 tests/generic/888
create mode 100644 tests/generic/888.out
diff --git a/tests/generic/888 b/tests/generic/888
new file mode 100755
index 00000000..b5075d1e
--- /dev/null
+++ b/tests/generic/888
@@ -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. 888
+#
+# 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/888.out b/tests/generic/888.out
new file mode 100644
index 00000000..0f142ce9
--- /dev/null
+++ b/tests/generic/888.out
@@ -0,0 +1,6 @@
+QA output created by 888
+Get a device with 4096 physical sector size and 512 logical sector size
+4096
+512
+mkfs and mount
+DIO read/write 512 bytes
--
2.31.1
next reply other threads:[~2022-11-07 4:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-07 4:56 Zorro Lang [this message]
2024-02-28 15:59 ` [PATCH] generic: check logical-sector sized O_DIRECT Darrick J. Wong
2024-02-28 16:04 ` Christoph Hellwig
2024-02-29 0:52 ` Zorro Lang
2024-02-29 1:41 ` Darrick J. Wong
2024-02-29 1:55 ` Zorro Lang
2024-02-29 11:39 ` Andrey Albershteyn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221107045618.2772009-1-zlang@kernel.org \
--to=zlang@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox