Message ID | 377e9a27befd2d4b7f771f082ffafe57876d7cce.1709162170.git.anand.jain@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: functional test cases for tempfsid | expand |
On Thu, Feb 29, 2024 at 1:50 AM Anand Jain <anand.jain@oracle.com> wrote: > > If another device with the same fsid and uuid would mount then verify if > it mounts with a temporary fsid. > > Signed-off-by: Anand Jain <anand.jain@oracle.com> > --- > tests/btrfs/312 | 78 +++++++++++++++++++++++++++++++++++++++++++++ > tests/btrfs/312.out | 19 +++++++++++ > 2 files changed, 97 insertions(+) > create mode 100755 tests/btrfs/312 > create mode 100644 tests/btrfs/312.out > > diff --git a/tests/btrfs/312 b/tests/btrfs/312 > new file mode 100755 > index 000000000000..eedcf11a2308 > --- /dev/null > +++ b/tests/btrfs/312 > @@ -0,0 +1,78 @@ > +#! /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 I believe I have commented this before, or maybe it was another test that did the same, but there's no point in placing the test code in a function if it's only called once and the test only exercises this scenario. It's unnecessary indentation... But, I won't make you send yet another patch version for that. Reviewed-by: Filipe Manana <fdmanana@suse.com> Thanks. > + > +_scratch_dev_pool_put > + > +# success, all done > +status=0 > +exit > diff --git a/tests/btrfs/312.out b/tests/btrfs/312.out > new file mode 100644 > index 000000000000..b7de6ce3cc6e > --- /dev/null > +++ b/tests/btrfs/312.out > @@ -0,0 +1,19 @@ > +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 > -- > 2.39.3 >
diff --git a/tests/btrfs/312 b/tests/btrfs/312 new file mode 100755 index 000000000000..eedcf11a2308 --- /dev/null +++ b/tests/btrfs/312 @@ -0,0 +1,78 @@ +#! /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 new file mode 100644 index 000000000000..b7de6ce3cc6e --- /dev/null +++ b/tests/btrfs/312.out @@ -0,0 +1,19 @@ +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
If another device with the same fsid and uuid would mount then verify if it mounts with a temporary fsid. Signed-off-by: Anand Jain <anand.jain@oracle.com> --- tests/btrfs/312 | 78 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/312.out | 19 +++++++++++ 2 files changed, 97 insertions(+) create mode 100755 tests/btrfs/312 create mode 100644 tests/btrfs/312.out