From: Darrick J. Wong Date: Mon, 20 Nov 2023 19:35:14 +0000 (-0800) Subject: xfs/601: move this to tests/generic X-Git-Tag: v2023.12.10~16 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=65e59370567a48762c98e080c3e06dc8145acbba;p=xfstests-dev.git xfs/601: move this to tests/generic As per last week's discussion, xfs/601 doesn't have any xfs-specific functionality in it. Turn it into a generic test. Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Signed-off-by: Zorro Lang --- diff --git a/tests/generic/734 b/tests/generic/734 new file mode 100755 index 00000000..93c2ad90 --- /dev/null +++ b/tests/generic/734 @@ -0,0 +1,88 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2023 Oracle. All Rights Reserved. +# +# FS QA Test No. 734 +# +# This is a regression test for the kernel commit noted below. The stale +# memory exposure can be exploited by creating a file with shared blocks, +# evicting the page cache for that file, and then funshareing at least one +# memory page's worth of data. iomap will mark the page uptodate and dirty +# without ever reading the ondisk contents. +# +. ./common/preamble +_begin_fstest auto quick unshare clone + +_cleanup() +{ + cd / + rm -r -f $tmp.* $testdir +} + +# real QA test starts here + +# Import common functions. +. ./common/filter +. ./common/reflink + +_fixed_by_git_commit kernel 35d30c9cf127 \ + "iomap: don't skip reading in !uptodate folios when unsharing a range" + +# real QA test starts here +_supported_fs generic +_require_test_reflink +_require_cp_reflink +_require_xfs_io_command "funshare" + +testdir=$TEST_DIR/test-$seq +rm -rf $testdir +mkdir $testdir + +# Create a file that is at least four pages in size and aligned to the +# file allocation unit size so that we don't trigger any unnecessary zeroing. +pagesz=$(_get_page_size) +alloc_unit=$(_get_file_block_size $TEST_DIR) +filesz=$(( ( (4 * pagesz) + alloc_unit - 1) / alloc_unit * alloc_unit)) + +echo "Create the original file and a clone" +_pwrite_byte 0x61 0 $filesz $testdir/file2.chk >> $seqres.full +_pwrite_byte 0x61 0 $filesz $testdir/file1 >> $seqres.full +_cp_reflink $testdir/file1 $testdir/file2 +_cp_reflink $testdir/file1 $testdir/file3 + +_test_cycle_mount + +cat $testdir/file3 > /dev/null + +echo "Funshare at least one pagecache page" +$XFS_IO_PROG -c "funshare 0 $filesz" $testdir/file2 +$XFS_IO_PROG -c "funshare 0 $filesz" $testdir/file3 +_pwrite_byte 0x61 0 $filesz $testdir/file2.chk >> $seqres.full + +echo "Check contents" + +# file2 wasn't cached when it was unshared, but it should match +if ! cmp -s $testdir/file2.chk $testdir/file2; then + echo "file2.chk does not match file2" + + echo "file2.chk contents" >> $seqres.full + od -tx1 -Ad -c $testdir/file2.chk >> $seqres.full + echo "file2 contents" >> $seqres.full + od -tx1 -Ad -c $testdir/file2 >> $seqres.full + echo "end bad contents" >> $seqres.full +fi + +# file3 was cached when it was unshared, and it should match +if ! cmp -s $testdir/file2.chk $testdir/file3; then + echo "file2.chk does not match file3" + + echo "file2.chk contents" >> $seqres.full + od -tx1 -Ad -c $testdir/file2.chk >> $seqres.full + echo "file3 contents" >> $seqres.full + od -tx1 -Ad -c $testdir/file3 >> $seqres.full + echo "end bad contents" >> $seqres.full +fi + +# success, all done +status=0 +exit diff --git a/tests/generic/734.out b/tests/generic/734.out new file mode 100644 index 00000000..174c3f82 --- /dev/null +++ b/tests/generic/734.out @@ -0,0 +1,4 @@ +QA output created by 734 +Create the original file and a clone +Funshare at least one pagecache page +Check contents diff --git a/tests/xfs/601 b/tests/xfs/601 deleted file mode 100755 index 9df46e5e..00000000 --- a/tests/xfs/601 +++ /dev/null @@ -1,87 +0,0 @@ -#! /bin/bash -# SPDX-License-Identifier: GPL-2.0 -# Copyright (c) 2023 Oracle. All Rights Reserved. -# -# FS QA Test No. 601 -# -# This is a regression test for the kernel commit noted below. The stale -# memory exposure can be exploited by creating a file with shared blocks, -# evicting the page cache for that file, and then funshareing at least one -# memory page's worth of data. iomap will mark the page uptodate and dirty -# without ever reading the ondisk contents. -# -. ./common/preamble -_begin_fstest auto quick unshare clone - -_cleanup() -{ - cd / - rm -r -f $tmp.* $testdir -} - -# real QA test starts here - -# Import common functions. -. ./common/filter -. ./common/reflink - -_fixed_by_git_commit kernel 35d30c9cf127 \ - "iomap: don't skip reading in !uptodate folios when unsharing a range" - -# real QA test starts here -_require_test_reflink -_require_cp_reflink -_require_xfs_io_command "funshare" - -testdir=$TEST_DIR/test-$seq -rm -rf $testdir -mkdir $testdir - -# Create a file that is at least four pages in size and aligned to the -# file allocation unit size so that we don't trigger any unnecessary zeroing. -pagesz=$(_get_page_size) -alloc_unit=$(_get_file_block_size $TEST_DIR) -filesz=$(( ( (4 * pagesz) + alloc_unit - 1) / alloc_unit * alloc_unit)) - -echo "Create the original file and a clone" -_pwrite_byte 0x61 0 $filesz $testdir/file2.chk >> $seqres.full -_pwrite_byte 0x61 0 $filesz $testdir/file1 >> $seqres.full -_cp_reflink $testdir/file1 $testdir/file2 -_cp_reflink $testdir/file1 $testdir/file3 - -_test_cycle_mount - -cat $testdir/file3 > /dev/null - -echo "Funshare at least one pagecache page" -$XFS_IO_PROG -c "funshare 0 $filesz" $testdir/file2 -$XFS_IO_PROG -c "funshare 0 $filesz" $testdir/file3 -_pwrite_byte 0x61 0 $filesz $testdir/file2.chk >> $seqres.full - -echo "Check contents" - -# file2 wasn't cached when it was unshared, but it should match -if ! cmp -s $testdir/file2.chk $testdir/file2; then - echo "file2.chk does not match file2" - - echo "file2.chk contents" >> $seqres.full - od -tx1 -Ad -c $testdir/file2.chk >> $seqres.full - echo "file2 contents" >> $seqres.full - od -tx1 -Ad -c $testdir/file2 >> $seqres.full - echo "end bad contents" >> $seqres.full -fi - -# file3 was cached when it was unshared, and it should match -if ! cmp -s $testdir/file2.chk $testdir/file3; then - echo "file2.chk does not match file3" - - echo "file2.chk contents" >> $seqres.full - od -tx1 -Ad -c $testdir/file2.chk >> $seqres.full - echo "file3 contents" >> $seqres.full - od -tx1 -Ad -c $testdir/file3 >> $seqres.full - echo "end bad contents" >> $seqres.full -fi - -# success, all done -status=0 -exit diff --git a/tests/xfs/601.out b/tests/xfs/601.out deleted file mode 100644 index 34d519ca..00000000 --- a/tests/xfs/601.out +++ /dev/null @@ -1,4 +0,0 @@ -QA output created by 601 -Create the original file and a clone -Funshare at least one pagecache page -Check contents