* [PATCH V2] xfs: Check if a direct write can result in a false ENOSPC error
@ 2022-08-24 9:30 Chandan Babu R
2022-08-24 15:05 ` Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Chandan Babu R @ 2022-08-24 9:30 UTC (permalink / raw)
To: fstests; +Cc: Chandan Babu R, zlang, linux-xfs, djwong
This commit adds a test to check if a direct write on a delalloc extent
present in CoW fork can result in a false ENOSPC error. The bug has been fixed
by upstream commit d62113303d691 ("xfs: Fix false ENOSPC when performing
direct write on a delalloc extent in cow fork").
Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
---
Changelog:
V1 -> V2:
1. Use file blocks as units instead of bytes to specify file offsets.
tests/xfs/553 | 65 +++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/553.out | 9 +++++++
2 files changed, 74 insertions(+)
create mode 100755 tests/xfs/553
create mode 100644 tests/xfs/553.out
diff --git a/tests/xfs/553 b/tests/xfs/553
new file mode 100755
index 00000000..ae52e9fc
--- /dev/null
+++ b/tests/xfs/553
@@ -0,0 +1,65 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022 Oracle. All Rights Reserved.
+#
+# FS QA Test 553
+#
+# Test to check if a direct write on a delalloc extent present in CoW fork can
+# result in an ENOSPC error.
+#
+. ./common/preamble
+_begin_fstest auto quick clone
+
+# Import common functions.
+. ./common/reflink
+. ./common/inject
+
+# real QA test starts here
+_supported_fs xfs
+_fixed_by_kernel_commit d62113303d691 \
+ "xfs: Fix false ENOSPC when performing direct write on a delalloc extent in cow fork"
+_require_scratch_reflink
+_require_xfs_debug
+_require_test_program "punch-alternating"
+_require_xfs_io_error_injection "bmap_alloc_minlen_extent"
+_require_xfs_io_command "reflink"
+_require_xfs_io_command "cowextsize"
+
+source=${SCRATCH_MNT}/source
+destination=${SCRATCH_MNT}/destination
+fragmented_file=${SCRATCH_MNT}/fragmented_file
+
+echo "Format and mount fs"
+_scratch_mkfs >> $seqres.full
+_scratch_mount >> $seqres.full
+
+blksz=$(_get_block_size $SCRATCH_MNT)
+
+echo "Create source file"
+$XFS_IO_PROG -f -c "pwrite 0 $((blksz * 8192))" $source >> $seqres.full
+
+echo "Reflink destination file with source file"
+$XFS_IO_PROG -f -c "reflink $source" $destination >> $seqres.full
+
+echo "Set destination file's cowextsize to 4096 blocks"
+$XFS_IO_PROG -c "cowextsize $((blksz * 4096))" $destination >> $seqres.full
+
+echo "Fragment FS"
+$XFS_IO_PROG -f -c "pwrite 0 $((blksz * 16384))" $fragmented_file >> $seqres.full
+sync
+$here/src/punch-alternating $fragmented_file >> $seqres.full
+
+echo "Inject bmap_alloc_minlen_extent error tag"
+_scratch_inject_error bmap_alloc_minlen_extent 1
+
+echo "Create delalloc extent of length 4096 blocks in destination file's CoW fork"
+$XFS_IO_PROG -c "pwrite 0 $blksz" $destination >> $seqres.full
+
+sync
+
+echo "Direct I/O write at 3rd block in destination file"
+$XFS_IO_PROG -d -c "pwrite $((blksz * 3)) $((blksz * 2))" $destination >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/553.out b/tests/xfs/553.out
new file mode 100644
index 00000000..9f5679de
--- /dev/null
+++ b/tests/xfs/553.out
@@ -0,0 +1,9 @@
+QA output created by 553
+Format and mount fs
+Create source file
+Reflink destination file with source file
+Set destination file's cowextsize to 4096 blocks
+Fragment FS
+Inject bmap_alloc_minlen_extent error tag
+Create delalloc extent of length 4096 blocks in destination file's CoW fork
+Direct I/O write at 3rd block in destination file
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH V2] xfs: Check if a direct write can result in a false ENOSPC error
2022-08-24 9:30 [PATCH V2] xfs: Check if a direct write can result in a false ENOSPC error Chandan Babu R
@ 2022-08-24 15:05 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2022-08-24 15:05 UTC (permalink / raw)
To: Chandan Babu R; +Cc: fstests, zlang, linux-xfs
On Wed, Aug 24, 2022 at 03:00:57PM +0530, Chandan Babu R wrote:
> This commit adds a test to check if a direct write on a delalloc extent
> present in CoW fork can result in a false ENOSPC error. The bug has been fixed
> by upstream commit d62113303d691 ("xfs: Fix false ENOSPC when performing
> direct write on a delalloc extent in cow fork").
>
> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
> ---
> Changelog:
> V1 -> V2:
> 1. Use file blocks as units instead of bytes to specify file offsets.
>
> tests/xfs/553 | 65 +++++++++++++++++++++++++++++++++++++++++++++++
> tests/xfs/553.out | 9 +++++++
> 2 files changed, 74 insertions(+)
> create mode 100755 tests/xfs/553
> create mode 100644 tests/xfs/553.out
>
> diff --git a/tests/xfs/553 b/tests/xfs/553
> new file mode 100755
> index 00000000..ae52e9fc
> --- /dev/null
> +++ b/tests/xfs/553
> @@ -0,0 +1,65 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2022 Oracle. All Rights Reserved.
> +#
> +# FS QA Test 553
> +#
> +# Test to check if a direct write on a delalloc extent present in CoW fork can
> +# result in an ENOSPC error.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick clone
> +
> +# Import common functions.
> +. ./common/reflink
> +. ./common/inject
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_fixed_by_kernel_commit d62113303d691 \
> + "xfs: Fix false ENOSPC when performing direct write on a delalloc extent in cow fork"
> +_require_scratch_reflink
> +_require_xfs_debug
> +_require_test_program "punch-alternating"
> +_require_xfs_io_error_injection "bmap_alloc_minlen_extent"
> +_require_xfs_io_command "reflink"
> +_require_xfs_io_command "cowextsize"
> +
> +source=${SCRATCH_MNT}/source
> +destination=${SCRATCH_MNT}/destination
> +fragmented_file=${SCRATCH_MNT}/fragmented_file
> +
> +echo "Format and mount fs"
> +_scratch_mkfs >> $seqres.full
> +_scratch_mount >> $seqres.full
> +
> +blksz=$(_get_block_size $SCRATCH_MNT)
_get_file_block_size, since COW can only be done in file allocation
units.
This is (currently) a distinction that won't make a difference until
realtime reflink, where we'll have to deal with rextsize > 1FSB, but we
might as well get this correct from the start.
With that fixed,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> +
> +echo "Create source file"
> +$XFS_IO_PROG -f -c "pwrite 0 $((blksz * 8192))" $source >> $seqres.full
> +
> +echo "Reflink destination file with source file"
> +$XFS_IO_PROG -f -c "reflink $source" $destination >> $seqres.full
> +
> +echo "Set destination file's cowextsize to 4096 blocks"
> +$XFS_IO_PROG -c "cowextsize $((blksz * 4096))" $destination >> $seqres.full
> +
> +echo "Fragment FS"
> +$XFS_IO_PROG -f -c "pwrite 0 $((blksz * 16384))" $fragmented_file >> $seqres.full
> +sync
> +$here/src/punch-alternating $fragmented_file >> $seqres.full
> +
> +echo "Inject bmap_alloc_minlen_extent error tag"
> +_scratch_inject_error bmap_alloc_minlen_extent 1
> +
> +echo "Create delalloc extent of length 4096 blocks in destination file's CoW fork"
> +$XFS_IO_PROG -c "pwrite 0 $blksz" $destination >> $seqres.full
> +
> +sync
> +
> +echo "Direct I/O write at 3rd block in destination file"
> +$XFS_IO_PROG -d -c "pwrite $((blksz * 3)) $((blksz * 2))" $destination >> $seqres.full
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/553.out b/tests/xfs/553.out
> new file mode 100644
> index 00000000..9f5679de
> --- /dev/null
> +++ b/tests/xfs/553.out
> @@ -0,0 +1,9 @@
> +QA output created by 553
> +Format and mount fs
> +Create source file
> +Reflink destination file with source file
> +Set destination file's cowextsize to 4096 blocks
> +Fragment FS
> +Inject bmap_alloc_minlen_extent error tag
> +Create delalloc extent of length 4096 blocks in destination file's CoW fork
> +Direct I/O write at 3rd block in destination file
> --
> 2.35.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-24 15:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-24 9:30 [PATCH V2] xfs: Check if a direct write can result in a false ENOSPC error Chandan Babu R
2022-08-24 15:05 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).