* [PATCH 0/2] fstests: new test cases for generic group @ 2024-03-09 10:10 Anand Jain 2024-03-09 10:10 ` [PATCH 1/2] generic: move btrfs clone device testcase to the " Anand Jain 2024-03-09 10:10 ` [PATCH 2/2] generic: test mount fails on physical device with configured dm volume Anand Jain 0 siblings, 2 replies; 5+ messages in thread From: Anand Jain @ 2024-03-09 10:10 UTC (permalink / raw) To: fstests; +Cc: linux-btrfs Patch 1/2 relocates a tempfsid (clone device) test case from btrfs group to the generic group. Patch 2/2 validates a recently discovered and resolved bug in Btrfs; however, the test case can be made generic. Anand Jain (2): generic: move btrfs clone device testcase to the generic group generic: test mount fails on physical device with configured dm volume tests/btrfs/312 | 78 -------------------------------------- tests/btrfs/312.out | 19 ---------- tests/generic/740 | 88 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/740.out | 4 ++ tests/generic/741 | 60 +++++++++++++++++++++++++++++ tests/generic/741.out | 3 ++ 6 files changed, 155 insertions(+), 97 deletions(-) delete mode 100755 tests/btrfs/312 delete mode 100644 tests/btrfs/312.out create mode 100755 tests/generic/740 create mode 100644 tests/generic/740.out create mode 100755 tests/generic/741 create mode 100644 tests/generic/741.out -- 2.39.3 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] generic: move btrfs clone device testcase to the generic group 2024-03-09 10:10 [PATCH 0/2] fstests: new test cases for generic group Anand Jain @ 2024-03-09 10:10 ` Anand Jain 2024-03-12 4:46 ` Zorro Lang 2024-03-09 10:10 ` [PATCH 2/2] generic: test mount fails on physical device with configured dm volume Anand Jain 1 sibling, 1 reply; 5+ messages in thread From: Anand Jain @ 2024-03-09 10:10 UTC (permalink / raw) To: fstests; +Cc: linux-btrfs Given that ext4 also allows mounting of a cloned filesystem, the btrfs test case btrfs/312, which assesses the functionality of cloned filesystem support, can be refactored to be under the generic group. Signed-off-by: Anand Jain <anand.jain@oracle.com> --- tests/btrfs/312 | 78 -------------------------------------- tests/btrfs/312.out | 19 ---------- tests/generic/740 | 88 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/740.out | 4 ++ 4 files changed, 92 insertions(+), 97 deletions(-) delete mode 100755 tests/btrfs/312 delete mode 100644 tests/btrfs/312.out create mode 100755 tests/generic/740 create mode 100644 tests/generic/740.out diff --git a/tests/btrfs/312 b/tests/btrfs/312 deleted file mode 100755 index eedcf11a2308..000000000000 --- a/tests/btrfs/312 +++ /dev/null @@ -1,78 +0,0 @@ -#! /bin/bash -# SPDX-License-Identifier: GPL-2.0 -# Copyright (c) 2024 Oracle. All Rights Reserved. -# -# FS QA Test 312 -# -# On a clone a device check to see if tempfsid is activated. -# -. ./common/preamble -_begin_fstest auto quick clone tempfsid - -_cleanup() -{ - cd / - $UMOUNT_PROG $mnt1 > /dev/null 2>&1 - rm -r -f $tmp.* - rm -r -f $mnt1 -} - -. ./common/filter.btrfs -. ./common/reflink - -_supported_fs btrfs -_require_scratch_dev_pool 2 -_scratch_dev_pool_get 2 -_require_btrfs_fs_feature temp_fsid - -mnt1=$TEST_DIR/$seq/mnt1 -mkdir -p $mnt1 - -create_cloned_devices() -{ - local dev1=$1 - local dev2=$2 - - echo -n Creating cloned device... - _mkfs_dev -fq -b $((1024 * 1024 * 300)) $dev1 - - _mount $dev1 $SCRATCH_MNT - - $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | \ - _filter_xfs_io - $UMOUNT_PROG $SCRATCH_MNT - # device dump of $dev1 to $dev2 - dd if=$dev1 of=$dev2 bs=300M count=1 conv=fsync status=none || \ - _fail "dd failed: $?" - echo done -} - -mount_cloned_device() -{ - echo ---- $FUNCNAME ---- - create_cloned_devices ${SCRATCH_DEV_NAME[0]} ${SCRATCH_DEV_NAME[1]} - - echo Mounting original device - _mount ${SCRATCH_DEV_NAME[0]} $SCRATCH_MNT - $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | \ - _filter_xfs_io - check_fsid ${SCRATCH_DEV_NAME[0]} - - echo Mounting cloned device - _mount ${SCRATCH_DEV_NAME[1]} $mnt1 || \ - _fail "mount failed, tempfsid didn't work" - - echo cp reflink must fail - _cp_reflink $SCRATCH_MNT/foo $mnt1/bar 2>&1 | \ - _filter_testdir_and_scratch - - check_fsid ${SCRATCH_DEV_NAME[1]} -} - -mount_cloned_device - -_scratch_dev_pool_put - -# success, all done -status=0 -exit diff --git a/tests/btrfs/312.out b/tests/btrfs/312.out deleted file mode 100644 index b7de6ce3cc6e..000000000000 --- a/tests/btrfs/312.out +++ /dev/null @@ -1,19 +0,0 @@ -QA output created by 312 ----- mount_cloned_device ---- -Creating cloned device...wrote 9000/9000 bytes at offset 0 -XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -done -Mounting original device -wrote 9000/9000 bytes at offset 0 -XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -On disk fsid: FSID -Metadata uuid: FSID -Temp fsid: FSID -Tempfsid status: 0 -Mounting cloned device -cp reflink must fail -cp: failed to clone 'TEST_DIR/312/mnt1/bar' from 'SCRATCH_MNT/foo': Invalid cross-device link -On disk fsid: FSID -Metadata uuid: FSID -Temp fsid: TEMPFSID -Tempfsid status: 1 diff --git a/tests/generic/740 b/tests/generic/740 new file mode 100755 index 000000000000..2b2bff96b8ec --- /dev/null +++ b/tests/generic/740 @@ -0,0 +1,88 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oracle. All Rights Reserved. +# +# FS QA Test 740 +# +# Set up a filesystem, create a clone, mount both, and verify if the cp reflink +# operation between these two mounts fails. +# +. ./common/preamble +_begin_fstest auto quick clone volume tempfsid + +_cleanup() +{ + cd / + rm -r -f $tmp.* + + $UMOUNT_PROG $mnt2 &> /dev/null + rm -r -f $mnt2 + _destroy_loop_device $loop_dev2 &> /dev/null + rm -r -f $loop_file2 + + $UMOUNT_PROG $mnt1 &> /dev/null + rm -r -f $mnt1 + _destroy_loop_device $loop_dev1 &> /dev/null + rm -r -f $loop_file1 + +} + +. ./common/filter +. ./common/reflink + +# Modify as appropriate. +_supported_fs btrfs ext4 +_require_cp_reflink +_require_test +_require_loop + +[[ $FSTYP == "btrfs" ]] && _require_btrfs_fs_feature temp_fsid + +clone_filesystem() +{ + local dev1=$1 + local dev2=$2 + + _mkfs_dev $dev1 + + _mount $dev1 $mnt1 + $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $mnt1/foo >> $seqres.full + $UMOUNT_PROG $mnt1 + + # device dump of $dev1 to $dev2 + dd if=$dev1 of=$dev2 conv=fsync status=none || _fail "dd failed: $?" +} + +mnt1=$TEST_DIR/$seq/mnt1 +rm -r -f $mnt1 +mkdir -p $mnt1 + +mnt2=$TEST_DIR/$seq/mnt2 +rm -r -f $mnt2 +mkdir -p $mnt2 + +loop_file1="$TEST_DIR/$seq/image1" +rm -r -f $loop_file1 +truncate -s 300m "$loop_file1" +loop_dev1=$(_create_loop_device "$loop_file1") + +loop_file2="$TEST_DIR/$seq/image2" +rm -r -f $loop_file2 +truncate -s 300m "$loop_file2" +loop_dev2=$(_create_loop_device "$loop_file2") + +clone_filesystem ${loop_dev1} ${loop_dev2} + +# Mounting original device +_mount $loop_dev1 $mnt1 +$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $mnt1/foo | _filter_xfs_io + +# Mounting cloned device +_mount $loop_dev2 $mnt2 || _fail "mount of cloned device failed" + +# cp reflink across two different filesystems must fail +_cp_reflink $mnt1/foo $mnt2/bar 2>&1 | _filter_test_dir + +# success, all done +status=0 +exit diff --git a/tests/generic/740.out b/tests/generic/740.out new file mode 100644 index 000000000000..6ca8bb7e1b21 --- /dev/null +++ b/tests/generic/740.out @@ -0,0 +1,4 @@ +QA output created by 740 +wrote 9000/9000 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +cp: failed to clone 'TEST_DIR/740/mnt2/bar' from 'TEST_DIR/740/mnt1/foo': Invalid cross-device link -- 2.39.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] generic: move btrfs clone device testcase to the generic group 2024-03-09 10:10 ` [PATCH 1/2] generic: move btrfs clone device testcase to the " Anand Jain @ 2024-03-12 4:46 ` Zorro Lang 2024-03-12 13:35 ` Anand Jain 0 siblings, 1 reply; 5+ messages in thread From: Zorro Lang @ 2024-03-12 4:46 UTC (permalink / raw) To: Anand Jain; +Cc: fstests, linux-btrfs, linux-xfs On Sat, Mar 09, 2024 at 03:40:34PM +0530, Anand Jain wrote: > Given that ext4 also allows mounting of a cloned filesystem, the btrfs > test case btrfs/312, which assesses the functionality of cloned filesystem > support, can be refactored to be under the generic group. > > Signed-off-by: Anand Jain <anand.jain@oracle.com> > --- > tests/btrfs/312 | 78 -------------------------------------- > tests/btrfs/312.out | 19 ---------- > tests/generic/740 | 88 +++++++++++++++++++++++++++++++++++++++++++ > tests/generic/740.out | 4 ++ > 4 files changed, 92 insertions(+), 97 deletions(-) > delete mode 100755 tests/btrfs/312 > delete mode 100644 tests/btrfs/312.out > create mode 100755 tests/generic/740 > create mode 100644 tests/generic/740.out > > diff --git a/tests/btrfs/312 b/tests/btrfs/312 > deleted file mode 100755 > index eedcf11a2308..000000000000 > --- a/tests/btrfs/312 > +++ /dev/null > @@ -1,78 +0,0 @@ > -#! /bin/bash > -# SPDX-License-Identifier: GPL-2.0 > -# Copyright (c) 2024 Oracle. All Rights Reserved. > -# > -# FS QA Test 312 > -# > -# On a clone a device check to see if tempfsid is activated. > -# > -. ./common/preamble > -_begin_fstest auto quick clone tempfsid > - > -_cleanup() > -{ > - cd / > - $UMOUNT_PROG $mnt1 > /dev/null 2>&1 > - rm -r -f $tmp.* > - rm -r -f $mnt1 > -} > - > -. ./common/filter.btrfs > -. ./common/reflink > - > -_supported_fs btrfs > -_require_scratch_dev_pool 2 > -_scratch_dev_pool_get 2 > -_require_btrfs_fs_feature temp_fsid > - > -mnt1=$TEST_DIR/$seq/mnt1 > -mkdir -p $mnt1 > - > -create_cloned_devices() > -{ > - local dev1=$1 > - local dev2=$2 > - > - echo -n Creating cloned device... > - _mkfs_dev -fq -b $((1024 * 1024 * 300)) $dev1 > - > - _mount $dev1 $SCRATCH_MNT > - > - $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | \ > - _filter_xfs_io > - $UMOUNT_PROG $SCRATCH_MNT > - # device dump of $dev1 to $dev2 > - dd if=$dev1 of=$dev2 bs=300M count=1 conv=fsync status=none || \ > - _fail "dd failed: $?" > - echo done > -} > - > -mount_cloned_device() > -{ > - echo ---- $FUNCNAME ---- > - create_cloned_devices ${SCRATCH_DEV_NAME[0]} ${SCRATCH_DEV_NAME[1]} > - > - echo Mounting original device > - _mount ${SCRATCH_DEV_NAME[0]} $SCRATCH_MNT > - $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | \ > - _filter_xfs_io > - check_fsid ${SCRATCH_DEV_NAME[0]} > - > - echo Mounting cloned device > - _mount ${SCRATCH_DEV_NAME[1]} $mnt1 || \ > - _fail "mount failed, tempfsid didn't work" > - > - echo cp reflink must fail > - _cp_reflink $SCRATCH_MNT/foo $mnt1/bar 2>&1 | \ > - _filter_testdir_and_scratch > - > - check_fsid ${SCRATCH_DEV_NAME[1]} > -} > - > -mount_cloned_device > - > -_scratch_dev_pool_put > - > -# success, all done > -status=0 > -exit > diff --git a/tests/btrfs/312.out b/tests/btrfs/312.out > deleted file mode 100644 > index b7de6ce3cc6e..000000000000 > --- a/tests/btrfs/312.out > +++ /dev/null > @@ -1,19 +0,0 @@ > -QA output created by 312 > ----- mount_cloned_device ---- > -Creating cloned device...wrote 9000/9000 bytes at offset 0 > -XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > -done > -Mounting original device > -wrote 9000/9000 bytes at offset 0 > -XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > -On disk fsid: FSID > -Metadata uuid: FSID > -Temp fsid: FSID > -Tempfsid status: 0 > -Mounting cloned device > -cp reflink must fail > -cp: failed to clone 'TEST_DIR/312/mnt1/bar' from 'SCRATCH_MNT/foo': Invalid cross-device link > -On disk fsid: FSID > -Metadata uuid: FSID > -Temp fsid: TEMPFSID > -Tempfsid status: 1 > diff --git a/tests/generic/740 b/tests/generic/740 > new file mode 100755 > index 000000000000..2b2bff96b8ec > --- /dev/null > +++ b/tests/generic/740 > @@ -0,0 +1,88 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (c) 2024 Oracle. All Rights Reserved. > +# > +# FS QA Test 740 > +# > +# Set up a filesystem, create a clone, mount both, and verify if the cp reflink > +# operation between these two mounts fails. > +# > +. ./common/preamble > +_begin_fstest auto quick clone volume tempfsid > + > +_cleanup() > +{ > + cd / > + rm -r -f $tmp.* > + > + $UMOUNT_PROG $mnt2 &> /dev/null > + rm -r -f $mnt2 > + _destroy_loop_device $loop_dev2 &> /dev/null > + rm -r -f $loop_file2 > + > + $UMOUNT_PROG $mnt1 &> /dev/null > + rm -r -f $mnt1 > + _destroy_loop_device $loop_dev1 &> /dev/null > + rm -r -f $loop_file1 > + > +} > + > +. ./common/filter > +. ./common/reflink > + > +# Modify as appropriate. > +_supported_fs btrfs ext4 If it only supports btrfs and ext4, then it's a "shared" case. Generally we use "_require_xxxx" to _notrun on fs which isn't supported, except a fs totally not be supported, we use "^$that_fs_name". As this test need loop device, so you might need the FSTYP is a local filesystem, so: _require_block_device $TEST_DEV And... > +_require_cp_reflink > +_require_test > +_require_loop > + > +[[ $FSTYP == "btrfs" ]] && _require_btrfs_fs_feature temp_fsid I'm wondering if we can have a common function likes _require_duplicated_fsid ? Then this function helps to avoid running this test on those fs which doesn't support (e.g. xfs can't mount duplicate UUID now?) e.g. _require_duplicate_fsid() { case $FSTYP: btrfs) _require_btrfs_fs_feature temp_fsid ;; ext4) # not sure, does it always supports that? ;; *) _notrun "$FSTYP can't be mounted with duplicate fsid" # not sure if need a real testing at here, likes mkfs # on an image file, copy it, then try to mount them? ;; esac } Any thoughts about this? Thanks, Zorro > + > +clone_filesystem() > +{ > + local dev1=$1 > + local dev2=$2 > + > + _mkfs_dev $dev1 > + > + _mount $dev1 $mnt1 > + $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $mnt1/foo >> $seqres.full > + $UMOUNT_PROG $mnt1 > + > + # device dump of $dev1 to $dev2 > + dd if=$dev1 of=$dev2 conv=fsync status=none || _fail "dd failed: $?" > +} > + > +mnt1=$TEST_DIR/$seq/mnt1 > +rm -r -f $mnt1 > +mkdir -p $mnt1 > + > +mnt2=$TEST_DIR/$seq/mnt2 > +rm -r -f $mnt2 > +mkdir -p $mnt2 > + > +loop_file1="$TEST_DIR/$seq/image1" > +rm -r -f $loop_file1 > +truncate -s 300m "$loop_file1" > +loop_dev1=$(_create_loop_device "$loop_file1") > + > +loop_file2="$TEST_DIR/$seq/image2" > +rm -r -f $loop_file2 > +truncate -s 300m "$loop_file2" > +loop_dev2=$(_create_loop_device "$loop_file2") > + > +clone_filesystem ${loop_dev1} ${loop_dev2} > + > +# Mounting original device > +_mount $loop_dev1 $mnt1 > +$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $mnt1/foo | _filter_xfs_io > + > +# Mounting cloned device > +_mount $loop_dev2 $mnt2 || _fail "mount of cloned device failed" > + > +# cp reflink across two different filesystems must fail > +_cp_reflink $mnt1/foo $mnt2/bar 2>&1 | _filter_test_dir > + > +# success, all done > +status=0 > +exit > diff --git a/tests/generic/740.out b/tests/generic/740.out > new file mode 100644 > index 000000000000..6ca8bb7e1b21 > --- /dev/null > +++ b/tests/generic/740.out > @@ -0,0 +1,4 @@ > +QA output created by 740 > +wrote 9000/9000 bytes at offset 0 > +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > +cp: failed to clone 'TEST_DIR/740/mnt2/bar' from 'TEST_DIR/740/mnt1/foo': Invalid cross-device link > -- > 2.39.3 > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] generic: move btrfs clone device testcase to the generic group 2024-03-12 4:46 ` Zorro Lang @ 2024-03-12 13:35 ` Anand Jain 0 siblings, 0 replies; 5+ messages in thread From: Anand Jain @ 2024-03-12 13:35 UTC (permalink / raw) To: Zorro Lang; +Cc: fstests, linux-btrfs, linux-xfs On 3/12/24 10:16, Zorro Lang wrote: > On Sat, Mar 09, 2024 at 03:40:34PM +0530, Anand Jain wrote: >> Given that ext4 also allows mounting of a cloned filesystem, the btrfs >> test case btrfs/312, which assesses the functionality of cloned filesystem >> support, can be refactored to be under the generic group. >> >> Signed-off-by: Anand Jain <anand.jain@oracle.com> >> --- >> tests/btrfs/312 | 78 -------------------------------------- >> tests/btrfs/312.out | 19 ---------- >> tests/generic/740 | 88 +++++++++++++++++++++++++++++++++++++++++++ >> tests/generic/740.out | 4 ++ >> 4 files changed, 92 insertions(+), 97 deletions(-) >> delete mode 100755 tests/btrfs/312 >> delete mode 100644 tests/btrfs/312.out >> create mode 100755 tests/generic/740 >> create mode 100644 tests/generic/740.out >> >> diff --git a/tests/btrfs/312 b/tests/btrfs/312 >> deleted file mode 100755 >> index eedcf11a2308..000000000000 >> --- a/tests/btrfs/312 >> +++ /dev/null >> @@ -1,78 +0,0 @@ >> -#! /bin/bash >> -# SPDX-License-Identifier: GPL-2.0 >> -# Copyright (c) 2024 Oracle. All Rights Reserved. >> -# >> -# FS QA Test 312 >> -# >> -# On a clone a device check to see if tempfsid is activated. >> -# >> -. ./common/preamble >> -_begin_fstest auto quick clone tempfsid >> - >> -_cleanup() >> -{ >> - cd / >> - $UMOUNT_PROG $mnt1 > /dev/null 2>&1 >> - rm -r -f $tmp.* >> - rm -r -f $mnt1 >> -} >> - >> -. ./common/filter.btrfs >> -. ./common/reflink >> - >> -_supported_fs btrfs >> -_require_scratch_dev_pool 2 >> -_scratch_dev_pool_get 2 >> -_require_btrfs_fs_feature temp_fsid >> - >> -mnt1=$TEST_DIR/$seq/mnt1 >> -mkdir -p $mnt1 >> - >> -create_cloned_devices() >> -{ >> - local dev1=$1 >> - local dev2=$2 >> - >> - echo -n Creating cloned device... >> - _mkfs_dev -fq -b $((1024 * 1024 * 300)) $dev1 >> - >> - _mount $dev1 $SCRATCH_MNT >> - >> - $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | \ >> - _filter_xfs_io >> - $UMOUNT_PROG $SCRATCH_MNT >> - # device dump of $dev1 to $dev2 >> - dd if=$dev1 of=$dev2 bs=300M count=1 conv=fsync status=none || \ >> - _fail "dd failed: $?" >> - echo done >> -} >> - >> -mount_cloned_device() >> -{ >> - echo ---- $FUNCNAME ---- >> - create_cloned_devices ${SCRATCH_DEV_NAME[0]} ${SCRATCH_DEV_NAME[1]} >> - >> - echo Mounting original device >> - _mount ${SCRATCH_DEV_NAME[0]} $SCRATCH_MNT >> - $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | \ >> - _filter_xfs_io >> - check_fsid ${SCRATCH_DEV_NAME[0]} >> - >> - echo Mounting cloned device >> - _mount ${SCRATCH_DEV_NAME[1]} $mnt1 || \ >> - _fail "mount failed, tempfsid didn't work" >> - >> - echo cp reflink must fail >> - _cp_reflink $SCRATCH_MNT/foo $mnt1/bar 2>&1 | \ >> - _filter_testdir_and_scratch >> - >> - check_fsid ${SCRATCH_DEV_NAME[1]} >> -} >> - >> -mount_cloned_device >> - >> -_scratch_dev_pool_put >> - >> -# success, all done >> -status=0 >> -exit >> diff --git a/tests/btrfs/312.out b/tests/btrfs/312.out >> deleted file mode 100644 >> index b7de6ce3cc6e..000000000000 >> --- a/tests/btrfs/312.out >> +++ /dev/null >> @@ -1,19 +0,0 @@ >> -QA output created by 312 >> ----- mount_cloned_device ---- >> -Creating cloned device...wrote 9000/9000 bytes at offset 0 >> -XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) >> -done >> -Mounting original device >> -wrote 9000/9000 bytes at offset 0 >> -XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) >> -On disk fsid: FSID >> -Metadata uuid: FSID >> -Temp fsid: FSID >> -Tempfsid status: 0 >> -Mounting cloned device >> -cp reflink must fail >> -cp: failed to clone 'TEST_DIR/312/mnt1/bar' from 'SCRATCH_MNT/foo': Invalid cross-device link >> -On disk fsid: FSID >> -Metadata uuid: FSID >> -Temp fsid: TEMPFSID >> -Tempfsid status: 1 >> diff --git a/tests/generic/740 b/tests/generic/740 >> new file mode 100755 >> index 000000000000..2b2bff96b8ec >> --- /dev/null >> +++ b/tests/generic/740 >> @@ -0,0 +1,88 @@ >> +#! /bin/bash >> +# SPDX-License-Identifier: GPL-2.0 >> +# Copyright (c) 2024 Oracle. All Rights Reserved. >> +# >> +# FS QA Test 740 >> +# >> +# Set up a filesystem, create a clone, mount both, and verify if the cp reflink >> +# operation between these two mounts fails. >> +# >> +. ./common/preamble >> +_begin_fstest auto quick clone volume tempfsid >> + >> +_cleanup() >> +{ >> + cd / >> + rm -r -f $tmp.* >> + >> + $UMOUNT_PROG $mnt2 &> /dev/null >> + rm -r -f $mnt2 >> + _destroy_loop_device $loop_dev2 &> /dev/null >> + rm -r -f $loop_file2 >> + >> + $UMOUNT_PROG $mnt1 &> /dev/null >> + rm -r -f $mnt1 >> + _destroy_loop_device $loop_dev1 &> /dev/null >> + rm -r -f $loop_file1 >> + >> +} >> + >> +. ./common/filter >> +. ./common/reflink >> + >> +# Modify as appropriate. >> +_supported_fs btrfs ext4 > > If it only supports btrfs and ext4, then it's a "shared" case. Generally > we use "_require_xxxx" to _notrun on fs which isn't supported, except > a fs totally not be supported, we use "^$that_fs_name". Moving the test case to tests/shared. Rest, I'm not entirely sure if I understood what you said. However, upon looking at shared/002 test, it appears to use _supported_fs xx to filter out unsupported file system types. > > As this test need loop device, so you might need the FSTYP is a local > filesystem, so: > _require_block_device $TEST_DEV > I got it. > And... > >> +_require_cp_reflink >> +_require_test >> +_require_loop >> + >> +[[ $FSTYP == "btrfs" ]] && _require_btrfs_fs_feature temp_fsid > > I'm wondering if we can have a common function likes _require_duplicated_fsid ? > Then this function helps to avoid running this test on those fs which doesn't > support (e.g. xfs can't mount duplicate UUID now?) > > e.g. > > _require_duplicate_fsid() > { > case $FSTYP: > btrfs) > _require_btrfs_fs_feature temp_fsid > ;; > ext4) > # not sure, does it always supports that? > ;; > *) > _notrun "$FSTYP can't be mounted with duplicate fsid" > # not sure if need a real testing at here, likes mkfs > # on an image file, copy it, then try to mount them? As of now, for other file systems, I think we can maintain static checking. > ;; > esac > } > > Any thoughts about this? It makes sense to me. I will use this. Thanks ,Anand > > Thanks, > Zorro > >> + >> +clone_filesystem() >> +{ >> + local dev1=$1 >> + local dev2=$2 >> + >> + _mkfs_dev $dev1 >> + >> + _mount $dev1 $mnt1 >> + $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $mnt1/foo >> $seqres.full >> + $UMOUNT_PROG $mnt1 >> + >> + # device dump of $dev1 to $dev2 >> + dd if=$dev1 of=$dev2 conv=fsync status=none || _fail "dd failed: $?" >> +} >> + >> +mnt1=$TEST_DIR/$seq/mnt1 >> +rm -r -f $mnt1 >> +mkdir -p $mnt1 >> + >> +mnt2=$TEST_DIR/$seq/mnt2 >> +rm -r -f $mnt2 >> +mkdir -p $mnt2 >> + >> +loop_file1="$TEST_DIR/$seq/image1" >> +rm -r -f $loop_file1 >> +truncate -s 300m "$loop_file1" >> +loop_dev1=$(_create_loop_device "$loop_file1") >> + >> +loop_file2="$TEST_DIR/$seq/image2" >> +rm -r -f $loop_file2 >> +truncate -s 300m "$loop_file2" >> +loop_dev2=$(_create_loop_device "$loop_file2") >> + >> +clone_filesystem ${loop_dev1} ${loop_dev2} >> + >> +# Mounting original device >> +_mount $loop_dev1 $mnt1 >> +$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $mnt1/foo | _filter_xfs_io >> + >> +# Mounting cloned device >> +_mount $loop_dev2 $mnt2 || _fail "mount of cloned device failed" >> + >> +# cp reflink across two different filesystems must fail >> +_cp_reflink $mnt1/foo $mnt2/bar 2>&1 | _filter_test_dir >> + >> +# success, all done >> +status=0 >> +exit >> diff --git a/tests/generic/740.out b/tests/generic/740.out >> new file mode 100644 >> index 000000000000..6ca8bb7e1b21 >> --- /dev/null >> +++ b/tests/generic/740.out >> @@ -0,0 +1,4 @@ >> +QA output created by 740 >> +wrote 9000/9000 bytes at offset 0 >> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) >> +cp: failed to clone 'TEST_DIR/740/mnt2/bar' from 'TEST_DIR/740/mnt1/foo': Invalid cross-device link >> -- >> 2.39.3 >> >> > ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] generic: test mount fails on physical device with configured dm volume 2024-03-09 10:10 [PATCH 0/2] fstests: new test cases for generic group Anand Jain 2024-03-09 10:10 ` [PATCH 1/2] generic: move btrfs clone device testcase to the " Anand Jain @ 2024-03-09 10:10 ` Anand Jain 1 sibling, 0 replies; 5+ messages in thread From: Anand Jain @ 2024-03-09 10:10 UTC (permalink / raw) To: fstests; +Cc: linux-btrfs When a dm Flakey device is configured, we have access to both the physical device and the dm flakey device, ensure that the physical device mount fails. Signed-off-by: Anand Jain <anand.jain@oracle.com> --- tests/generic/741 | 60 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/741.out | 3 +++ 2 files changed, 63 insertions(+) create mode 100755 tests/generic/741 create mode 100644 tests/generic/741.out diff --git a/tests/generic/741 b/tests/generic/741 new file mode 100755 index 000000000000..f8f9a7be7619 --- /dev/null +++ b/tests/generic/741 @@ -0,0 +1,60 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oracle. All Rights Reserved. +# +# FS QA Test 741 +# +# Attempt to mount both the DM physical device and the DM flakey device. +# Verify the returned error message. +# +. ./common/preamble +_begin_fstest auto quick volume tempfsid + +# Override the default cleanup function. +_cleanup() +{ + umount $extra_mnt &> /dev/null + rm -rf $extra_mnt + _unmount_flakey + _cleanup_flakey + cd / + rm -r -f $tmp.* +} + +# Import common functions. +. ./common/filter +. ./common/dmflakey + +# real QA test starts here +_supported_fs generic +_require_test +_require_scratch +_require_dm_target flakey + +[ "$FSTYP" = "btrfs" ] && _fixed_by_kernel_commit XXXXXXXXXXXX \ + "btrfs: return accurate error code on open failure" + +_scratch_mkfs >> $seqres.full +_init_flakey +_mount_flakey + +extra_mnt=$TEST_DIR/extra_mnt +rm -rf $extra_mnt +mkdir -p $extra_mnt + +# Mount must fail because the physical device has a dm created on it. +# Filters alter the return code of the mount. +_mount $SCRATCH_DEV $extra_mnt 2>&1 | \ + _filter_testdir_and_scratch | _filter_error_mount + +# Try again with flakey unmounted, must fail. +_unmount_flakey +_mount $SCRATCH_DEV $extra_mnt 2>&1 | \ + _filter_testdir_and_scratch | _filter_error_mount + +# Removing dm should make mount successful. +_cleanup_flakey +_scratch_mount + +status=0 +exit diff --git a/tests/generic/741.out b/tests/generic/741.out new file mode 100644 index 000000000000..b694f5fad6b8 --- /dev/null +++ b/tests/generic/741.out @@ -0,0 +1,3 @@ +QA output created by 741 +mount: TEST_DIR/extra_mnt: SCRATCH_DEV already mounted or mount point busy +mount: TEST_DIR/extra_mnt: SCRATCH_DEV already mounted or mount point busy -- 2.39.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-03-12 13:35 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-03-09 10:10 [PATCH 0/2] fstests: new test cases for generic group Anand Jain 2024-03-09 10:10 ` [PATCH 1/2] generic: move btrfs clone device testcase to the " Anand Jain 2024-03-12 4:46 ` Zorro Lang 2024-03-12 13:35 ` Anand Jain 2024-03-09 10:10 ` [PATCH 2/2] generic: test mount fails on physical device with configured dm volume Anand Jain
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.