aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Jain <anand.jain@oracle.com>2024-02-20 03:48:45 +0800
committerZorro Lang <zlang@kernel.org>2024-03-01 19:22:36 +0800
commit408376708514bedd64c3e0acfbf00e3d383e2dda (patch)
tree40b9d94fbe96c91c8b4d61f80c19c2892ab225da
parente6c1d2ab76a90c151a72694456b608e6e9f927c5 (diff)
downloadxfstests-dev-408376708514bedd64c3e0acfbf00e3d383e2dda.tar.gz
btrfs: check if cloned device mounts with tempfsid
If another device with the same fsid and uuid would mount then verify if it mounts with a temporary fsid. Reviewed-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Anand Jain <anand.jain@oracle.com>
-rwxr-xr-xtests/btrfs/31278
-rw-r--r--tests/btrfs/312.out19
2 files changed, 97 insertions, 0 deletions
diff --git a/tests/btrfs/312 b/tests/btrfs/312
new file mode 100755
index 0000000000..eedcf11a23
--- /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 0000000000..b7de6ce3cc
--- /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