From patchwork Wed Dec 27 14:04:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508586 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1115E7FD; Mon, 1 Jan 2024 01:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VjOUTSp+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79F21C433C8; Mon, 1 Jan 2024 01:04:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704071055; bh=GjLOsoERXAYmfabWejcrAfWx6TRZA8QYmHxgrsIg0AQ=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=VjOUTSp+6gUvfJBjfX8g15w6O+PR/PjLj8wZiYtiaJ1iPdLHSlH0v/PjxrDhBYFpd Nf4qynONs7raVZTyvNGpwjksUXvsRIStS6d0CRH4ML2mniqK7cgxfLuffCUr/VbRMT /iOySRSfYFWzHijr5EsXPMWbHZB0zbxW7X4UIwn1CpJPWwmvrs88/4gnTbuylH6TCZ 9JgW+zKIz0SoUy0hIYx7WPvQi7+mEjxOUmJB6OaS3eaj8Uydv2j4pzJoRuNMA2ddDa dJXgo6MRJUwb8fFY/u9un0MjMHgZvd2r6W4ui33E0j9dF3J9jvrw/hSNXn6OHHaV0z k+tu40DB82H0A== Date: Sun, 31 Dec 2023 17:04:14 +9900 Subject: [PATCH 1/5] xfs: make sure that CoW will write around when rextsize > 1 From: "Darrick J. Wong" To: djwong@kernel.org, zlang@redhat.com Cc: guan@eryu.me, linux-xfs@vger.kernel.org, fstests@vger.kernel.org Message-ID: <170405032749.1827706.9594372070506702354.stgit@frogsfrogsfrogs> In-Reply-To: <170405032733.1827706.12312180709769839153.stgit@frogsfrogsfrogs> References: <170405032733.1827706.12312180709769839153.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Make sure that CoW triggers the intended copy-around behavior when we write a tiny amount to the middle of a large rt extent. Signed-off-by: Darrick J. Wong --- tests/xfs/1919 | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1919.out | 84 +++++++++++++++++++++++++++ 2 files changed, 247 insertions(+) create mode 100755 tests/xfs/1919 create mode 100644 tests/xfs/1919.out diff --git a/tests/xfs/1919 b/tests/xfs/1919 new file mode 100755 index 0000000000..00b16737e7 --- /dev/null +++ b/tests/xfs/1919 @@ -0,0 +1,163 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2024 Oracle. All Rights Reserved. +# +# FS QA Test No. 1919 +# +# Make sure that copy on write actually does the intended write-around when we +# stage a tiny modification to a large shared realtime extent. We should never +# end up with multiple rt extents mapped to the same region. +# +. ./common/preamble +_begin_fstest auto quick clone realtime + +# Import common functions. +. ./common/filter +. ./common/reflink + +# real QA test starts here +_supported_fs xfs +_require_xfs_io_command "fpunch" +_require_xfs_io_command "fzero" +_require_xfs_io_command "fcollapse" +_require_xfs_io_command "finsert" +_require_xfs_io_command "funshare" +_require_realtime +_require_scratch_reflink + +rtextsz=262144 +filesz=$((rtextsz * 3)) + +echo "Format filesystem and populate" +_scratch_mkfs -m reflink=1 -r extsize=$rtextsz > $seqres.full +_scratch_mount >> $seqres.full + +# Force all our files to be on the realtime device +_xfs_force_bdev realtime $SCRATCH_MNT + +check_file() { + $XFS_IO_PROG -c fsync -c 'bmap -elpv' $1 >> $seqres.full + md5sum $SCRATCH_MNT/a | _filter_scratch + md5sum $1 | _filter_scratch +} + +rtextsz_got=$(_xfs_get_rtextsize "$SCRATCH_MNT") +test $rtextsz_got -eq $rtextsz || \ + _notrun "got rtextsize $rtextsz_got, wanted $rtextsz" + +_pwrite_byte 0x59 0 $filesz $SCRATCH_MNT/a >> $seqres.full +sync +md5sum $SCRATCH_MNT/a | _filter_scratch +$XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/a >> $seqres.full + +echo "pwrite 1 byte in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/b +_pwrite_byte 0x00 345678 1 $SCRATCH_MNT/b >> $seqres.full +check_file $SCRATCH_MNT/b + +echo "mwrite 1 byte in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/c +$XFS_IO_PROG -c "mmap -rw 0 $filesz" -c "mwrite -S 0x00 345678 1" -c msync $SCRATCH_MNT/c +check_file $SCRATCH_MNT/c + +echo "fzero 1 byte in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/d +$XFS_IO_PROG -c "fzero 345678 1" $SCRATCH_MNT/d +check_file $SCRATCH_MNT/d + +echo "fpunch 1 byte in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/e +$XFS_IO_PROG -c "fpunch 345678 1" $SCRATCH_MNT/e +check_file $SCRATCH_MNT/e + +echo "funshare 1 byte in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/f +$XFS_IO_PROG -c "funshare 345678 1" $SCRATCH_MNT/f +check_file $SCRATCH_MNT/f + +echo "pwrite 1 block in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/g +_pwrite_byte 0x00 327680 65536 $SCRATCH_MNT/g >> $seqres.full +check_file $SCRATCH_MNT/g + +echo "mwrite 1 block in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/h +$XFS_IO_PROG -c "mmap -rw 0 $filesz" -c "mwrite -S 0x00 327680 65536" -c msync $SCRATCH_MNT/h +check_file $SCRATCH_MNT/h + +echo "fzero 1 block in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/i +$XFS_IO_PROG -c "fzero 327680 65536" $SCRATCH_MNT/i +check_file $SCRATCH_MNT/i + +echo "fpunch 1 block in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/j +$XFS_IO_PROG -c "fpunch 327680 65536" $SCRATCH_MNT/j +check_file $SCRATCH_MNT/j + +echo "funshare 1 block in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/k +$XFS_IO_PROG -c "funshare 327680 65536" $SCRATCH_MNT/k +check_file $SCRATCH_MNT/k + +echo "pwrite 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/l +_pwrite_byte 0x00 262144 262144 $SCRATCH_MNT/l >> $seqres.full +check_file $SCRATCH_MNT/l + +echo "mwrite 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/m +$XFS_IO_PROG -c "mmap -rw 0 $filesz" -c "mwrite -S 0x00 262144 262144" -c msync $SCRATCH_MNT/m +check_file $SCRATCH_MNT/m + +echo "fzero 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/n +$XFS_IO_PROG -c "fzero 262144 262144" $SCRATCH_MNT/n +check_file $SCRATCH_MNT/n + +echo "fpunch 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/o +$XFS_IO_PROG -c "fpunch 262144 262144" $SCRATCH_MNT/o +check_file $SCRATCH_MNT/o + +echo "funshare 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/p +$XFS_IO_PROG -c "funshare 262144 262144" $SCRATCH_MNT/p +check_file $SCRATCH_MNT/p + +echo "fcollapse 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/q +$XFS_IO_PROG -c "fcollapse 262144 262144" $SCRATCH_MNT/q +check_file $SCRATCH_MNT/q + +echo "finsert 1 extent in the middle" | tee -a $seqres.full +_cp_reflink $SCRATCH_MNT/a $SCRATCH_MNT/r +$XFS_IO_PROG -c "finsert 262144 262144" $SCRATCH_MNT/r +check_file $SCRATCH_MNT/r + +echo "copy unwritten blocks in large rtext" | tee -a $seqres.full +$XFS_IO_PROG -f -c "falloc 0 $filesz" -c 'pwrite -S 0x59 345678 1' $SCRATCH_MNT/s >> $seqres.full +$XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/s >> $seqres.full +_cp_reflink $SCRATCH_MNT/s $SCRATCH_MNT/t +$XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/s >> $seqres.full +$XFS_IO_PROG -f -c 'pwrite -S 0x59 1048576 1' $SCRATCH_MNT/s >> $seqres.full +$XFS_IO_PROG -f -c 'pwrite -S 0x59 1048576 1' $SCRATCH_MNT/t >> $seqres.full +check_file $SCRATCH_MNT/s +check_file $SCRATCH_MNT/t + +echo "test writing to shared unwritten extent" | tee -a $seqres.full +$XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/s >> $seqres.full +_cp_reflink $SCRATCH_MNT/s $SCRATCH_MNT/u +$XFS_IO_PROG -c 'bmap -elpv' $SCRATCH_MNT/s >> $seqres.full +$XFS_IO_PROG -f -c 'pwrite -S 0x59 345678 1' $SCRATCH_MNT/u >> $seqres.full +check_file $SCRATCH_MNT/u + +echo "Remount and recheck" | tee -a $seqres.full +md5sum $SCRATCH_MNT/a | _filter_scratch +for i in b c d e f g h i j k l m n o p q r s t u; do + check_file $SCRATCH_MNT/$i | grep -v SCRATCH_MNT.a +done + +# success, all done +status=0 +exit diff --git a/tests/xfs/1919.out b/tests/xfs/1919.out new file mode 100644 index 0000000000..40cf5092a5 --- /dev/null +++ b/tests/xfs/1919.out @@ -0,0 +1,84 @@ +QA output created by 1919 +Format filesystem and populate +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +pwrite 1 byte in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +ea0b05f13c8cce703accaffe56d59bd3 SCRATCH_MNT/b +mwrite 1 byte in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +ea0b05f13c8cce703accaffe56d59bd3 SCRATCH_MNT/c +fzero 1 byte in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +ea0b05f13c8cce703accaffe56d59bd3 SCRATCH_MNT/d +fpunch 1 byte in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +ea0b05f13c8cce703accaffe56d59bd3 SCRATCH_MNT/e +funshare 1 byte in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/f +pwrite 1 block in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +2a508e23efc80e468efa7004fd8a1839 SCRATCH_MNT/g +mwrite 1 block in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +2a508e23efc80e468efa7004fd8a1839 SCRATCH_MNT/h +fzero 1 block in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +2a508e23efc80e468efa7004fd8a1839 SCRATCH_MNT/i +fpunch 1 block in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +2a508e23efc80e468efa7004fd8a1839 SCRATCH_MNT/j +funshare 1 block in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/k +pwrite 1 extent in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +352abe71b0d40f194b9d701750b0d7f3 SCRATCH_MNT/l +mwrite 1 extent in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +352abe71b0d40f194b9d701750b0d7f3 SCRATCH_MNT/m +fzero 1 extent in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +352abe71b0d40f194b9d701750b0d7f3 SCRATCH_MNT/n +fpunch 1 extent in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +352abe71b0d40f194b9d701750b0d7f3 SCRATCH_MNT/o +funshare 1 extent in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/p +fcollapse 1 extent in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +b0581637c15320958874ef3f082111da SCRATCH_MNT/q +finsert 1 extent in the middle +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +a7359d0c100367c2cd430be334dffbd3 SCRATCH_MNT/r +copy unwritten blocks in large rtext +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +bff4e0a70430429c92d6139065e6949b SCRATCH_MNT/s +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +bff4e0a70430429c92d6139065e6949b SCRATCH_MNT/t +test writing to shared unwritten extent +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +bff4e0a70430429c92d6139065e6949b SCRATCH_MNT/u +Remount and recheck +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/a +ea0b05f13c8cce703accaffe56d59bd3 SCRATCH_MNT/b +ea0b05f13c8cce703accaffe56d59bd3 SCRATCH_MNT/c +ea0b05f13c8cce703accaffe56d59bd3 SCRATCH_MNT/d +ea0b05f13c8cce703accaffe56d59bd3 SCRATCH_MNT/e +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/f +2a508e23efc80e468efa7004fd8a1839 SCRATCH_MNT/g +2a508e23efc80e468efa7004fd8a1839 SCRATCH_MNT/h +2a508e23efc80e468efa7004fd8a1839 SCRATCH_MNT/i +2a508e23efc80e468efa7004fd8a1839 SCRATCH_MNT/j +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/k +352abe71b0d40f194b9d701750b0d7f3 SCRATCH_MNT/l +352abe71b0d40f194b9d701750b0d7f3 SCRATCH_MNT/m +352abe71b0d40f194b9d701750b0d7f3 SCRATCH_MNT/n +352abe71b0d40f194b9d701750b0d7f3 SCRATCH_MNT/o +924a97fdaa2ab30e2768081469e728a7 SCRATCH_MNT/p +b0581637c15320958874ef3f082111da SCRATCH_MNT/q +a7359d0c100367c2cd430be334dffbd3 SCRATCH_MNT/r +bff4e0a70430429c92d6139065e6949b SCRATCH_MNT/s +bff4e0a70430429c92d6139065e6949b SCRATCH_MNT/t +bff4e0a70430429c92d6139065e6949b SCRATCH_MNT/u From patchwork Wed Dec 27 14:04:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508587 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F06C7ED; Mon, 1 Jan 2024 01:04:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MuzddTKt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3467FC433C8; Mon, 1 Jan 2024 01:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704071071; bh=bGka8KkS5/SmPkedarS/6RMqBg6Hubd2jVw+iOePdAs=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=MuzddTKt67Zg/jk8DykfFdHMzzMxxHnsB8dA4ThhR8dhFre7/eOUWuYbveFm9w9eb xNdgMBn6GJCeZ71CqEBixIuv7+pIcLKlUQTuSVI4ObWCIP2khpwFCSkROmHTIgb9de qIMbZGHxd866uzUI3hPZ45xcrEgA8b6MYQMOZW2/PA61j993eQy0vz6s8MXof7vU3a eS238+Sq14o6KaH3MgMJgFSyNUpJW6AehdU74LV4DsDpKwFoiJs8k65YGBxLR+jg5V WcFqETHaOQsq3VeRbtZZYGiXN7TM4fK8sLs7WBNCQZqOF2iAk+xMqPD8yz+q3dd4nK CqesamKCIIQ/g== Date: Sun, 31 Dec 2023 17:04:30 +9900 Subject: [PATCH 2/5] xfs: skip cowextsize hint fragmentation tests on realtime volumes From: "Darrick J. Wong" To: djwong@kernel.org, zlang@redhat.com Cc: guan@eryu.me, linux-xfs@vger.kernel.org, fstests@vger.kernel.org Message-ID: <170405032762.1827706.12824926807769911075.stgit@frogsfrogsfrogs> In-Reply-To: <170405032733.1827706.12312180709769839153.stgit@frogsfrogsfrogs> References: <170405032733.1827706.12312180709769839153.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong The XFS CoW extent size hint is ignored on realtime filesystems when the rt extent size set to a unit larger than a single filesystem block because it is assumed that the larger allocation unit is the administrator's sole and mandatory anti-fragmentation strategy. As such, we can skip these tests. Signed-off-by: Darrick J. Wong --- common/reflink | 27 +++++++++++++++++++++++++++ tests/xfs/180 | 1 + tests/xfs/182 | 1 + tests/xfs/184 | 1 + tests/xfs/192 | 1 + tests/xfs/200 | 1 + tests/xfs/204 | 1 + tests/xfs/208 | 1 + tests/xfs/315 | 1 + tests/xfs/326 | 6 ++++++ 10 files changed, 41 insertions(+) diff --git a/common/reflink b/common/reflink index 22adc4449b..1082642e4e 100644 --- a/common/reflink +++ b/common/reflink @@ -521,3 +521,30 @@ _sweave_reflink_rainbow_delalloc() { _pwrite_byte 0x62 $((blksz * i)) $blksz $dfile.chk done } + +# Require that the COW extent size hint can actually be used to combat +# fragmentation on the scratch filesystem. This is (so far) true for any +# filesystem except for the ones where the realtime extent size is larger +# than one fs block, for it is assumed that setting a rt extent size is the +# preferred fragmentation avoidance strategy. +_require_scratch_cowextsize_useful() { + local testfile=$SCRATCH_MNT/hascowextsize + local param="${1:-1m}" + + rm -f $testfile + touch $testfile + local before="$($XFS_IO_PROG -c 'cowextsize' $testfile)" + + $XFS_IO_PROG -c "cowextsize $param" $testfile + local after="$($XFS_IO_PROG -c 'cowextsize' $testfile)" + rm -f $testfile + + test "$before" != "$after" || \ + _notrun "setting cowextsize to $param had no effect" + + local fileblocksize=$(_get_file_block_size $SCRATCH_MNT) + local fsblocksize=$(_get_block_size $SCRATCH_MNT) + + test $fsblocksize -eq $fileblocksize || \ + _notrun "XFS does not support cowextsize when rt extsize ($fileblocksize) > 1FSB ($fsblocksize)" +} diff --git a/tests/xfs/180 b/tests/xfs/180 index d2fac03a9e..e8e04062a8 100755 --- a/tests/xfs/180 +++ b/tests/xfs/180 @@ -38,6 +38,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_block_size $testdir) diff --git a/tests/xfs/182 b/tests/xfs/182 index 511aca6f2d..7c0713b248 100755 --- a/tests/xfs/182 +++ b/tests/xfs/182 @@ -39,6 +39,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_block_size $testdir) diff --git a/tests/xfs/184 b/tests/xfs/184 index 97f529f666..b2b4da6024 100755 --- a/tests/xfs/184 +++ b/tests/xfs/184 @@ -40,6 +40,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_block_size $testdir) diff --git a/tests/xfs/192 b/tests/xfs/192 index ef7da55be5..0017597280 100755 --- a/tests/xfs/192 +++ b/tests/xfs/192 @@ -42,6 +42,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_block_size $testdir) diff --git a/tests/xfs/200 b/tests/xfs/200 index a9d6ce1bb6..500564d9a8 100755 --- a/tests/xfs/200 +++ b/tests/xfs/200 @@ -42,6 +42,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_block_size $testdir) diff --git a/tests/xfs/204 b/tests/xfs/204 index 7dacfa2de7..8cbdd6513f 100755 --- a/tests/xfs/204 +++ b/tests/xfs/204 @@ -44,6 +44,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_block_size $testdir) diff --git a/tests/xfs/208 b/tests/xfs/208 index 1e7734b822..0d2401b908 100755 --- a/tests/xfs/208 +++ b/tests/xfs/208 @@ -41,6 +41,7 @@ nr=128 filesize=$((blksz * nr)) bufnr=16 bufsize=$((blksz * bufnr)) +_require_scratch_cowextsize_useful $bufsize _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4)) real_blksz=$(_get_file_block_size $testdir) diff --git a/tests/xfs/315 b/tests/xfs/315 index 9f6b39c8cc..3a618a3680 100755 --- a/tests/xfs/315 +++ b/tests/xfs/315 @@ -38,6 +38,7 @@ echo "Format filesystem" _scratch_mkfs >/dev/null 2>&1 _scratch_mount >> $seqres.full _require_congruent_file_oplen $SCRATCH_MNT $blksz +_require_scratch_cowextsize_useful $sz $XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT diff --git a/tests/xfs/326 b/tests/xfs/326 index ac620fc433..a3fed8b6ac 100755 --- a/tests/xfs/326 +++ b/tests/xfs/326 @@ -55,6 +55,12 @@ $XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT # staging extent for an unshared extent and trips over the injected error. _require_no_xfs_always_cow +# This test uses a very large cowextszhint to manipulate the COW fork to +# contain a large unwritten extent before injecting the error. XFS ignores +# cowextsize when the realtime extent size is greater than 1FSB, so this test +# cannot set up the preconditions for the test. +_require_scratch_cowextsize_useful $sz + echo "Create files" _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2 From patchwork Wed Dec 27 14:04:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508588 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 132FA7ED; Mon, 1 Jan 2024 01:04:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WpWmOV96" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0218C433C8; Mon, 1 Jan 2024 01:04:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704071086; bh=pEWxttbe7ZFy++6/xveUJs/muewSFpCu/5fWwGCCLFk=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=WpWmOV967nrn+gvaeSgs+uxl7qZL5BAVl+FKH2sFumKR6eTVlw5YBpVvpcO8ZjARg 2JC2vqNudi7MMotbf5EXIZttn1pjAsM+quB1Q9J8WKKIuU474jW/z5S3ch1mrfbjlz cEk2SObMxCf9sRxG9Mxksq2aLsPMyYPgou0QGyUk2wAXqOT4v9FEKV+djzD9ko6Rmi OlE94PD45du3weD2oV6VyefnVlcP+y1l1KzLo4U/f3Om0VjDdhxUhNvK7nFjk3avXl uoFcqqELau6gW4Qx4o2Y9IkWowjJxi7+Hi3rPSFxwrVPyB9kTTBNZnLgLaw1hEVAy0 Aelg9RXbcZ53Q== Date: Sun, 31 Dec 2023 17:04:46 +9900 Subject: [PATCH 3/5] misc: add more congruent oplen testing From: "Darrick J. Wong" To: djwong@kernel.org, zlang@redhat.com Cc: guan@eryu.me, linux-xfs@vger.kernel.org, fstests@vger.kernel.org Message-ID: <170405032776.1827706.12287719690033943992.stgit@frogsfrogsfrogs> In-Reply-To: <170405032733.1827706.12312180709769839153.stgit@frogsfrogsfrogs> References: <170405032733.1827706.12312180709769839153.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Do more checking for file allocation operation op length congruency. This prevents tests from failing with EINVAL when the realtime extent size is something weird like 28k or 1GB. Signed-off-by: Darrick J. Wong --- tests/generic/145 | 1 + tests/generic/147 | 1 + tests/generic/261 | 1 + tests/generic/262 | 1 + tests/generic/331 | 1 + tests/generic/353 | 2 +- tests/generic/517 | 1 + tests/generic/657 | 1 + tests/generic/658 | 1 + tests/generic/659 | 1 + tests/generic/660 | 1 + tests/generic/663 | 1 + tests/generic/664 | 1 + tests/generic/665 | 1 + tests/generic/670 | 1 + tests/generic/672 | 1 + tests/xfs/420 | 3 +++ tests/xfs/421 | 3 +++ tests/xfs/792 | 1 + 19 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/generic/145 b/tests/generic/145 index f213f53be8..81fc5f6c2f 100755 --- a/tests/generic/145 +++ b/tests/generic/145 @@ -36,6 +36,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $TEST_DIR $blksz _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full _pwrite_byte 0x62 $blksz $blksz $testdir/file1 >> $seqres.full _pwrite_byte 0x63 $((blksz * 2)) $blksz $testdir/file1 >> $seqres.full diff --git a/tests/generic/147 b/tests/generic/147 index 113800944b..bb17bb1c0b 100755 --- a/tests/generic/147 +++ b/tests/generic/147 @@ -35,6 +35,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $TEST_DIR $blksz _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full _pwrite_byte 0x62 $blksz $blksz $testdir/file1 >> $seqres.full _pwrite_byte 0x63 $((blksz * 2)) $blksz $testdir/file1 >> $seqres.full diff --git a/tests/generic/261 b/tests/generic/261 index 93c1c349b1..deb360288e 100755 --- a/tests/generic/261 +++ b/tests/generic/261 @@ -29,6 +29,7 @@ testdir=$SCRATCH_MNT/test-$seq mkdir $testdir blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=5 filesize=$((blksz * nr)) diff --git a/tests/generic/262 b/tests/generic/262 index 46e88f8731..f296e37e02 100755 --- a/tests/generic/262 +++ b/tests/generic/262 @@ -29,6 +29,7 @@ testdir=$SCRATCH_MNT/test-$seq mkdir $testdir blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=4 filesize=$((blksz * nr)) diff --git a/tests/generic/331 b/tests/generic/331 index 8c665ce4fc..9b6801e16f 100755 --- a/tests/generic/331 +++ b/tests/generic/331 @@ -38,6 +38,7 @@ testdir=$SCRATCH_MNT/test-$seq mkdir $testdir blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=640 bufnr=128 filesize=$((blksz * nr)) diff --git a/tests/generic/353 b/tests/generic/353 index c563972510..6dbb0d4c24 100755 --- a/tests/generic/353 +++ b/tests/generic/353 @@ -30,7 +30,7 @@ _scratch_mkfs > /dev/null 2>&1 _scratch_mount blocksize=$(_get_file_block_size $SCRATCH_MNT) - +_require_congruent_file_oplen $SCRATCH_MNT $blocksize file1="$SCRATCH_MNT/file1" file2="$SCRATCH_MNT/file2" extmap1="$SCRATCH_MNT/extmap1" diff --git a/tests/generic/517 b/tests/generic/517 index cf3031ed2d..229358d06b 100755 --- a/tests/generic/517 +++ b/tests/generic/517 @@ -21,6 +21,7 @@ _require_scratch_dedupe _scratch_mkfs >>$seqres.full 2>&1 _scratch_mount +_require_congruent_file_oplen $SCRATCH_MNT 65536 # The first byte with a value of 0xae starts at an offset (512Kb + 100) which is # not a multiple of the block size. diff --git a/tests/generic/657 b/tests/generic/657 index e0fecd544c..9f4673dda3 100755 --- a/tests/generic/657 +++ b/tests/generic/657 @@ -30,6 +30,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _pwrite_byte 0x61 0 $filesize $testdir/file1 >> $seqres.full diff --git a/tests/generic/658 b/tests/generic/658 index a5cbadaaa5..e9519c25e2 100755 --- a/tests/generic/658 +++ b/tests/generic/658 @@ -31,6 +31,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _weave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full diff --git a/tests/generic/659 b/tests/generic/659 index ccc2d7950d..05436edfab 100755 --- a/tests/generic/659 +++ b/tests/generic/659 @@ -31,6 +31,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _weave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full diff --git a/tests/generic/660 b/tests/generic/660 index bc17dc5e59..52b0d1ea9e 100755 --- a/tests/generic/660 +++ b/tests/generic/660 @@ -31,6 +31,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full diff --git a/tests/generic/663 b/tests/generic/663 index 658a5b7004..692c77b745 100755 --- a/tests/generic/663 +++ b/tests/generic/663 @@ -32,6 +32,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _sweave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full diff --git a/tests/generic/664 b/tests/generic/664 index 3009101fdc..40fb8c6d92 100755 --- a/tests/generic/664 +++ b/tests/generic/664 @@ -34,6 +34,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _sweave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full diff --git a/tests/generic/665 b/tests/generic/665 index 86ba578720..ee511755e6 100755 --- a/tests/generic/665 +++ b/tests/generic/665 @@ -34,6 +34,7 @@ mkdir $testdir echo "Create the original files" blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=64 filesize=$((blksz * nr)) _sweave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full diff --git a/tests/generic/670 b/tests/generic/670 index 67de167405..80f9fe6d4f 100755 --- a/tests/generic/670 +++ b/tests/generic/670 @@ -31,6 +31,7 @@ mkdir $testdir loops=512 nr_loops=$((loops - 1)) blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz echo "Initialize files" echo >> $seqres.full diff --git a/tests/generic/672 b/tests/generic/672 index 9e3a97ec5e..0710a04294 100755 --- a/tests/generic/672 +++ b/tests/generic/672 @@ -30,6 +30,7 @@ mkdir $testdir loops=1024 nr_loops=$((loops - 1)) blksz=65536 +_require_congruent_file_oplen $SCRATCH_MNT $blksz echo "Initialize files" echo >> $seqres.full diff --git a/tests/xfs/420 b/tests/xfs/420 index d38772c9d9..51f87bc304 100755 --- a/tests/xfs/420 +++ b/tests/xfs/420 @@ -69,6 +69,9 @@ exercise_lseek() { } blksz=65536 +# Golden output encodes SEEK_HOLE/DATA output, which depends on COW only +# happening on $blksz granularity +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=8 filesize=$((blksz * nr)) diff --git a/tests/xfs/421 b/tests/xfs/421 index 027ae47c21..429333e349 100755 --- a/tests/xfs/421 +++ b/tests/xfs/421 @@ -51,6 +51,9 @@ testdir=$SCRATCH_MNT/test-$seq mkdir $testdir blksz=65536 +# Golden output encodes SEEK_HOLE/DATA output, which depends on COW only +# happening on $blksz granularity +_require_congruent_file_oplen $SCRATCH_MNT $blksz nr=8 filesize=$((blksz * nr)) diff --git a/tests/xfs/792 b/tests/xfs/792 index bfbfbce4aa..bfbfd8bfbc 100755 --- a/tests/xfs/792 +++ b/tests/xfs/792 @@ -32,6 +32,7 @@ _require_xfs_io_error_injection "bmap_finish_one" _scratch_mkfs >> $seqres.full _scratch_mount +_require_congruent_file_oplen $SCRATCH_MNT 65536 # Create original file _pwrite_byte 0x58 0 1m $SCRATCH_MNT/a >> $seqres.full From patchwork Wed Dec 27 14:05:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508589 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B24D97EE; Mon, 1 Jan 2024 01:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mBe99lT4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82A69C433C7; Mon, 1 Jan 2024 01:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704071102; bh=zv8S0l/G5PKw7wGJ5ukwwq1b6jA613kbQsrFilB3qng=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=mBe99lT4vfgyRmxo/GtlPtSXJZENlGJe15V0BHCIytDX03tJlVWa4jOw5cmYTnB9G CEykQxVmjn8HkuhedCQRgaZZvEijYsUqBZmL3UiWfTdlJ2YYEhE5cWVVpvYqwGcVxi Si30WZaHL/UH0c3UnBmY91O3jL0Rms46Z85Vr9xjO5qGNbaS6wlhSvcY0MAKxer5IU jS13+g1AE75+GVwnOHhX4W6NMS9ehWnwfMn3gtzihLLYNyPkDqsKGIuzOr/vYu4WQg 9b2zA82ozrhCSWbkPZ99CCp/OvfJqaC5mvQ72AeaLT6yYWD1zfpfdBb1nAHQkt9BwQ IrVF9XWmOo6nw== Date: Sun, 31 Dec 2023 17:05:02 +9900 Subject: [PATCH 4/5] xfs: test COWing entire rt extents From: "Darrick J. Wong" To: djwong@kernel.org, zlang@redhat.com Cc: guan@eryu.me, linux-xfs@vger.kernel.org, fstests@vger.kernel.org Message-ID: <170405032789.1827706.9480080283762068776.stgit@frogsfrogsfrogs> In-Reply-To: <170405032733.1827706.12312180709769839153.stgit@frogsfrogsfrogs> References: <170405032733.1827706.12312180709769839153.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong For XFS filesystems with a realtime volume, an extent size larger than 1FSB, and reflink enabled, we use a "COW around" strategy that detects file writes that are not aligned to the rt extent size and enlarges those writes to dirty enough page cache so that the entire rt extent can be COWed all at once. This is a functional test to make sure that all works properly. Signed-off-by: Darrick J. Wong --- tests/xfs/1926 | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/1926.out | 2 + 2 files changed, 179 insertions(+) create mode 100755 tests/xfs/1926 create mode 100644 tests/xfs/1926.out diff --git a/tests/xfs/1926 b/tests/xfs/1926 new file mode 100755 index 0000000000..91b611f59d --- /dev/null +++ b/tests/xfs/1926 @@ -0,0 +1,177 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023-2024 Oracle. All Rights Reserved. +# +# FS QA Test No. 1926 +# +# Functional testing for COWing around realtime extents. +# +. ./common/preamble +_begin_fstest auto clone realtime rw + +_cleanup() +{ + cd / + rm -r -f $tmp.* $testdir +} + +. ./common/reflink + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_require_test +_require_test_reflink +_require_cp_reflink + +alloc_unit=$(_get_file_block_size $TEST_DIR) +blksz=$(_get_block_size $TEST_DIR) + +testdir="$TEST_DIR/test-$seq" +mkdir "$testdir" + +filesize="$(( (alloc_unit * 5 / 2) + 512))" +origfile="$testdir/a" +testfile0="$testdir/a0" +testfile1="$testdir/a1" +testfile2="$testdir/a2" +testfile3="$testdir/a3" +testfile4="$testdir/a4" +testfile5="$testdir/a5" +testfile6="$testdir/a6" +testfile7="$testdir/a7" +testfile8="$testdir/a8" +testfile9="$testdir/a9" +testfileA="$testdir/aA" +testfileB="$testdir/aB" + +goldfile0="$testdir/g0" +goldfile1="$testdir/g1" +goldfile2="$testdir/g2" +goldfile3="$testdir/g3" +goldfile4="$testdir/g4" +goldfile5="$testdir/g5" + +orig_cmd="pwrite -S 0x58 -b 1m 0 $filesize" +$XFS_IO_PROG -f -c "$orig_cmd" -c fsync "$origfile" >> $seqres.full + +_cp_reflink "$origfile" "$testfile0" +_cp_reflink "$origfile" "$testfile1" +_cp_reflink "$origfile" "$testfile2" +_cp_reflink "$origfile" "$testfile3" +_cp_reflink "$origfile" "$testfile4" +_cp_reflink "$origfile" "$testfile5" +_cp_reflink "$origfile" "$testfile6" +_cp_reflink "$origfile" "$testfile7" +_cp_reflink "$origfile" "$testfile8" +_cp_reflink "$origfile" "$testfile9" +_cp_reflink "$origfile" "$testfileA" +_cp_reflink "$origfile" "$testfileB" + +# First we try a partial ovewrite below EOF +cmd="pwrite -S 0x59 -b 1m -W 512 512" +_kernlog "********** buffered write below eof goldfile0" +$XFS_IO_PROG -c "$cmd" "$testfile0" >> $seqres.full +_kernlog "********** direct write below eof goldfile0" +$XFS_IO_PROG -d -c "$cmd" "$testfile1" >> $seqres.full +_kernlog "********** goldfile0" +$XFS_IO_PROG -f -c "$orig_cmd" -c "$cmd" -c fsync "$goldfile0" >> $seqres.full + +# Next we try an appending write at EOF +_kernlog "********** appending buffered write goldfile1" +cmd="pwrite -S 0x5a -b 1m -W $filesize 512" +$XFS_IO_PROG -c "$cmd" "$testfile2" >> $seqres.full +_kernlog "********** appending direct write goldfile1" +$XFS_IO_PROG -d -c "$cmd" "$testfile3" >> $seqres.full +_kernlog "********** goldfile1" +$XFS_IO_PROG -f -c "$orig_cmd" -c "$cmd" -c fsync "$goldfile1" >> $seqres.full + +# Third we try a pure overwrite of the second block +_kernlog "********** buffered overwrite second block goldfile2" +cmd="pwrite -S 0x5b -b 1m -W $alloc_unit $alloc_unit" +$XFS_IO_PROG -c "$cmd" "$testfile4" >> $seqres.full +_kernlog "********** direct overwrite second block goldfile2" +$XFS_IO_PROG -d -c "$cmd" "$testfile5" >> $seqres.full +_kernlog "********** goldfile2" +$XFS_IO_PROG -f -c "$orig_cmd" -c "$cmd" -c fsync "$goldfile2" >> $seqres.full + +# Fourth we try a small write well beyond EOF +_kernlog "********** buffered write beyond eof block goldfile3" +cmd="pwrite -S 0x5c -b 1m -W $(( (filesize * 2) + 512)) 512" +$XFS_IO_PROG -c "$cmd" "$testfile6" >> $seqres.full +_kernlog "********** direct write beyond eof block goldfile3" +$XFS_IO_PROG -d -c "$cmd" "$testfile7" >> $seqres.full +_kernlog "********** goldfile3" +$XFS_IO_PROG -f -c "$orig_cmd" -c "$cmd" -c fsync "$goldfile3" >> $seqres.full + +# Fifth we try a large write well beyond EOF +_kernlog "********** buffered write beyond eof block goldfile4" +cmd="pwrite -S 0x5d -b 1m -W $(( ((filesize * 2) + 512) & ~(alloc_unit - 1) )) $alloc_unit" +$XFS_IO_PROG -c "$cmd" "$testfile8" >> $seqres.full +_kernlog "********** direct write beyond eof block goldfile4" +$XFS_IO_PROG -d -c "$cmd" "$testfile9" >> $seqres.full +_kernlog "********** goldfile3" +$XFS_IO_PROG -f -c "$orig_cmd" -c "$cmd" -c fsync "$goldfile4" >> $seqres.full + +# Sixth we try a pure overwrite of the second fsblock +_kernlog "********** buffered overwrite second fsblock goldfile5" +cmd="pwrite -S 0x5b -b 1m -W $blksz $alloc_unit" +$XFS_IO_PROG -c "$cmd" "$testfileA" >> $seqres.full +_kernlog "********** direct overwrite second fsblock goldfile5" +$XFS_IO_PROG -d -c "$cmd" "$testfileB" >> $seqres.full +_kernlog "********** goldfile5" +$XFS_IO_PROG -f -c "$orig_cmd" -c "$cmd" -c fsync "$goldfile5" >> $seqres.full + +_kernlog "********** done" + +corruption_noted= + +note_corruption() { + local fname="$1" + + echo "$fname is bad" + + if [ -z "$corruption_noted" ]; then + corruption_noted=1 + echo "origfile" >> $seqres.full + od -tx1 -Ad -c "$origfile" >> $seqres.full + fi + + echo "$fname" >> $seqres.full + od -tx1 -Ad -c "$testfile1" >> $seqres.full +} + +echo "before remount" >> $seqres.full +cmp -s "$goldfile0" "$testfile0" || note_corruption "$testfile0" +cmp -s "$goldfile0" "$testfile1" || note_corruption "$testfile1" +cmp -s "$goldfile1" "$testfile2" || note_corruption "$testfile2" +cmp -s "$goldfile1" "$testfile3" || note_corruption "$testfile3" +cmp -s "$goldfile2" "$testfile4" || note_corruption "$testfile4" +cmp -s "$goldfile2" "$testfile5" || note_corruption "$testfile5" +cmp -s "$goldfile3" "$testfile6" || note_corruption "$testfile6" +cmp -s "$goldfile3" "$testfile7" || note_corruption "$testfile7" +cmp -s "$goldfile4" "$testfile8" || note_corruption "$testfile8" +cmp -s "$goldfile4" "$testfile9" || note_corruption "$testfile9" +cmp -s "$goldfile5" "$testfileA" || note_corruption "$testfileA" +cmp -s "$goldfile5" "$testfileB" || note_corruption "$testfileB" + +_test_cycle_mount + +echo "after remount" >> $seqres.full +cmp -s "$goldfile0" "$testfile0" || note_corruption "$testfile0" +cmp -s "$goldfile0" "$testfile1" || note_corruption "$testfile1" +cmp -s "$goldfile1" "$testfile2" || note_corruption "$testfile2" +cmp -s "$goldfile1" "$testfile3" || note_corruption "$testfile3" +cmp -s "$goldfile2" "$testfile4" || note_corruption "$testfile4" +cmp -s "$goldfile2" "$testfile5" || note_corruption "$testfile5" +cmp -s "$goldfile3" "$testfile6" || note_corruption "$testfile6" +cmp -s "$goldfile3" "$testfile7" || note_corruption "$testfile7" +cmp -s "$goldfile4" "$testfile8" || note_corruption "$testfile8" +cmp -s "$goldfile4" "$testfile9" || note_corruption "$testfile9" +cmp -s "$goldfile5" "$testfileA" || note_corruption "$testfileA" +cmp -s "$goldfile5" "$testfileB" || note_corruption "$testfileB" + +echo Silence is golden +status=0 +exit diff --git a/tests/xfs/1926.out b/tests/xfs/1926.out new file mode 100644 index 0000000000..a56601b969 --- /dev/null +++ b/tests/xfs/1926.out @@ -0,0 +1,2 @@ +QA output created by 1926 +Silence is golden From patchwork Wed Dec 27 14:05:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13508590 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E9987FD; Mon, 1 Jan 2024 01:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kSSyqdKD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37D2AC433C7; Mon, 1 Jan 2024 01:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704071118; bh=pByeGkhsCivrIbR+n9n+uAAy1d+FpUiap/CXwMYVGYo=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=kSSyqdKDBx+SCL9o3jDRuP6ubc48M9imfQONCdG55S2ac8Uc5Oqn8XsFr+mCwUIub xYVt+Q8oTO4F87bR/1bigCXrmuaHC9VgvyZ73nZl4IooSUQY0YbhzNDOTqvYAgfKyS unEyQVjsiis1wAmUVMP9+d+44FwZ4x6XSDBDc9YXuT/IfL9dkZAyXFIqZKAdBlq+kk jVO1UFtk0t6JdqScfFQKeoQ5PShBfihMa+5015OnS4fLGq57FH+CS5KjwGdGRh8zyM wyTojkkhSK2pLzwmp66XJSc4/PvHwueEqSoZniANrCxlcOpk+awLxysVDNqA/Bi25h Oc2az/EN0mMQQ== Date: Sun, 31 Dec 2023 17:05:17 +9900 Subject: [PATCH 5/5] generic/303: avoid test failures on weird rt extent sizes From: "Darrick J. Wong" To: djwong@kernel.org, zlang@redhat.com Cc: guan@eryu.me, linux-xfs@vger.kernel.org, fstests@vger.kernel.org Message-ID: <170405032802.1827706.17351355710375259350.stgit@frogsfrogsfrogs> In-Reply-To: <170405032733.1827706.12312180709769839153.stgit@frogsfrogsfrogs> References: <170405032733.1827706.12312180709769839153.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Fix this test to skip the high offset reflink test if (on XFS) the rt extent size isn't congruent with the chosen target offset. Signed-off-by: Darrick J. Wong --- common/rc | 23 +++++++++++++++++++++++ tests/generic/303 | 8 +++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/common/rc b/common/rc index f760eedc26..2d67f7dff1 100644 --- a/common/rc +++ b/common/rc @@ -4690,6 +4690,29 @@ _get_file_block_size() esac } +_test_congruent_file_oplen() +{ + local file="$1" + local alloc_unit=$(_get_file_block_size "$file") + local oplen="$2" + + case $FSTYP in + nfs*|cifs|9p|virtiofs|ceph|glusterfs|overlay|pvfs2) + # Network filesystems don't know about (or tell the client + # about) the underlying file allocation unit and they generally + # pass the file IO request to the underlying filesystem, so we + # don't have anything to check here. + return + ;; + esac + + if [ $alloc_unit -gt $oplen ]; then + return 1 + fi + test $((oplen % alloc_unit)) -eq 0 || return 1 + return 0 +} + # Given a file path and a byte length of a file operation under test, ensure # that the length is an integer multiple of the file's allocation unit size. # In other words, skip the test unless (oplen ≡ alloc_unit mod 0). This is diff --git a/tests/generic/303 b/tests/generic/303 index 95679569e4..ef88d2357b 100755 --- a/tests/generic/303 +++ b/tests/generic/303 @@ -48,7 +48,13 @@ echo "Reflink past maximum file size in dest file (should fail)" _reflink_range $testdir/file1 0 $testdir/file5 4611686018427322368 $len >> $seqres.full echo "Reflink high offset to low offset" -_reflink_range $testdir/file1 $bigoff_64k $testdir/file6 1048576 65535 >> $seqres.full +oplen=1048576 +if _test_congruent_file_oplen $testdir $oplen; then + _reflink_range $testdir/file1 $bigoff_64k $testdir/file6 $oplen 65535 >> $seqres.full +else + # If we can't do the ficlonerange test, fake it in the output file + $XFS_IO_PROG -f -c 'pwrite -S 0x61 1114110 1' $testdir/file6 >> $seqres.full +fi echo "Reflink past source file EOF (should fail)" _reflink_range $testdir/file2 524288 $testdir/file7 0 1048576 >> $seqres.full