From: Zorro Lang Date: Mon, 7 Nov 2022 04:56:18 +0000 (+0800) Subject: generic: check logical-sector sized O_DIRECT X-Git-Tag: v2022.11.27~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b4feba30c81c43d38b7d30af207511130b9fbc57;p=xfstests-dev.git generic: check logical-sector sized O_DIRECT 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 Reviewed-by: Andrey Albershteyn Signed-off-by: Zorro Lang --- diff --git a/tests/generic/704 b/tests/generic/704 new file mode 100755 index 00000000..c0142a60 --- /dev/null +++ b/tests/generic/704 @@ -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 index 00000000..b7e8cd2a --- /dev/null +++ b/tests/generic/704.out @@ -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