* [PATCH v2 01/10] assign SCRATCH_DEV_POOL to an array
2024-02-19 19:48 [PATCH v2 00/10] btrfs: functional test cases for tempfsid Anand Jain
@ 2024-02-19 19:48 ` Anand Jain
2024-02-20 16:17 ` Filipe Manana
2024-02-19 19:48 ` [PATCH v2 02/10] btrfs: introduce tempfsid test group Anand Jain
` (8 subsequent siblings)
9 siblings, 1 reply; 26+ messages in thread
From: Anand Jain @ 2024-02-19 19:48 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, zlang, fdmanana
Many test cases use local variables to manage the names of each device in
SCRATCH_DEV_POOL. Let _scratch_dev_pool_get set an array, SCRATCH_DEV_NAME,
for it.
Usage:
_scratch_dev_pool_get <n>
# device names are in the array SCRATCH_DEV_NAME.
${SCRATCH_DEV_NAME[0]} ${SCRATCH_DEV_NAME[1]} ...
_scratch_dev_pool_put
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2:
Fix typo in the commit log.
Fix array SCRATCH_DEV_POOL_SAVED handling.
common/rc | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/common/rc b/common/rc
index 524ffa02aa6a..5d249af3df37 100644
--- a/common/rc
+++ b/common/rc
@@ -830,6 +830,8 @@ _spare_dev_put()
# required number of scratch devices by a-test-case excluding
# the replace-target and spare device. So this function will
# set SCRATCH_DEV_POOL to the specified number of devices.
+# Also, this functions assigns array SCRATCH_DEV_NAME to the
+# array SCRATCH_DEV_POOL.
#
# Usage:
# _scratch_dev_pool_get() <ndevs>
@@ -860,19 +862,28 @@ _scratch_dev_pool_get()
export SCRATCH_DEV_POOL_SAVED
SCRATCH_DEV_POOL=${devs[@]:0:$test_ndevs}
export SCRATCH_DEV_POOL
+ SCRATCH_DEV_NAME=( $SCRATCH_DEV_POOL )
+ export SCRATCH_DEV_NAME
}
_scratch_dev_pool_put()
{
+ local ret1
+ local ret2
+
typeset -p SCRATCH_DEV_POOL_SAVED >/dev/null 2>&1
- if [ $? -ne 0 ]; then
+ ret1=$?
+ typeset -p SCRATCH_DEV_NAME >/dev/null 2>&1
+ ret2=$?
+ if [[ $ret1 -ne 0 || $ret2 -ne 0 ]]; then
_fail "Bug: unset val, must call _scratch_dev_pool_get before _scratch_dev_pool_put"
fi
- if [ -z "$SCRATCH_DEV_POOL_SAVED" ]; then
+ if [[ -z "$SCRATCH_DEV_POOL_SAVED" || -z "${SCRATCH_DEV_NAME[@]}" ]]; then
_fail "Bug: str empty, must call _scratch_dev_pool_get before _scratch_dev_pool_put"
fi
+ export SCRATCH_DEV_NAME=()
export SCRATCH_DEV_POOL=$SCRATCH_DEV_POOL_SAVED
export SCRATCH_DEV_POOL_SAVED=""
}
--
2.39.3
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v2 01/10] assign SCRATCH_DEV_POOL to an array
2024-02-19 19:48 ` [PATCH v2 01/10] assign SCRATCH_DEV_POOL to an array Anand Jain
@ 2024-02-20 16:17 ` Filipe Manana
0 siblings, 0 replies; 26+ messages in thread
From: Filipe Manana @ 2024-02-20 16:17 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs, zlang
On Mon, Feb 19, 2024 at 7:49 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> Many test cases use local variables to manage the names of each device in
> SCRATCH_DEV_POOL. Let _scratch_dev_pool_get set an array, SCRATCH_DEV_NAME,
> for it.
>
> Usage:
>
> _scratch_dev_pool_get <n>
>
> # device names are in the array SCRATCH_DEV_NAME.
> ${SCRATCH_DEV_NAME[0]} ${SCRATCH_DEV_NAME[1]} ...
>
> _scratch_dev_pool_put
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v2:
> Fix typo in the commit log.
> Fix array SCRATCH_DEV_POOL_SAVED handling.
>
> common/rc | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/common/rc b/common/rc
> index 524ffa02aa6a..5d249af3df37 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -830,6 +830,8 @@ _spare_dev_put()
> # required number of scratch devices by a-test-case excluding
> # the replace-target and spare device. So this function will
> # set SCRATCH_DEV_POOL to the specified number of devices.
> +# Also, this functions assigns array SCRATCH_DEV_NAME to the
> +# array SCRATCH_DEV_POOL.
I'm not a native English speaker, but when it's phrased like that it
gives the idea of:
SCRATCH_DEV_POOL = SCRATCH_DEV_NAME
Maybe a "Sets a SCRATCH_DEV_NAME array with the names of the devices."
But anyway:
Reviewed-by: Filipe Manana <fdmanana@suse.com>
> #
> # Usage:
> # _scratch_dev_pool_get() <ndevs>
> @@ -860,19 +862,28 @@ _scratch_dev_pool_get()
> export SCRATCH_DEV_POOL_SAVED
> SCRATCH_DEV_POOL=${devs[@]:0:$test_ndevs}
> export SCRATCH_DEV_POOL
> + SCRATCH_DEV_NAME=( $SCRATCH_DEV_POOL )
> + export SCRATCH_DEV_NAME
> }
>
> _scratch_dev_pool_put()
> {
> + local ret1
> + local ret2
> +
> typeset -p SCRATCH_DEV_POOL_SAVED >/dev/null 2>&1
> - if [ $? -ne 0 ]; then
> + ret1=$?
> + typeset -p SCRATCH_DEV_NAME >/dev/null 2>&1
> + ret2=$?
> + if [[ $ret1 -ne 0 || $ret2 -ne 0 ]]; then
> _fail "Bug: unset val, must call _scratch_dev_pool_get before _scratch_dev_pool_put"
> fi
>
> - if [ -z "$SCRATCH_DEV_POOL_SAVED" ]; then
> + if [[ -z "$SCRATCH_DEV_POOL_SAVED" || -z "${SCRATCH_DEV_NAME[@]}" ]]; then
> _fail "Bug: str empty, must call _scratch_dev_pool_get before _scratch_dev_pool_put"
> fi
>
> + export SCRATCH_DEV_NAME=()
> export SCRATCH_DEV_POOL=$SCRATCH_DEV_POOL_SAVED
> export SCRATCH_DEV_POOL_SAVED=""
> }
> --
> 2.39.3
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v2 02/10] btrfs: introduce tempfsid test group
2024-02-19 19:48 [PATCH v2 00/10] btrfs: functional test cases for tempfsid Anand Jain
2024-02-19 19:48 ` [PATCH v2 01/10] assign SCRATCH_DEV_POOL to an array Anand Jain
@ 2024-02-19 19:48 ` Anand Jain
2024-02-19 19:48 ` [PATCH v2 03/10] btrfs: create a helper function, check_fsid(), to verify the tempfsid Anand Jain
` (7 subsequent siblings)
9 siblings, 0 replies; 26+ messages in thread
From: Anand Jain @ 2024-02-19 19:48 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, zlang, fdmanana
Introducing a new test group named tempfsid.
Tempfsid is a feature of the Btrfs filesystem. When encountering another
device with the same fsid as one already mounted, the system will mount
the new device with a temporary, randomly generated in-memory fsid.
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2: Add rb.
doc/group-names.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/doc/group-names.txt b/doc/group-names.txt
index 2ac95ac83a79..50262e02f681 100644
--- a/doc/group-names.txt
+++ b/doc/group-names.txt
@@ -131,6 +131,7 @@ swap swap files
swapext XFS_IOC_SWAPEXT ioctl
symlink symbolic links
tape dump and restore with a tape
+tempfsid temporary fsid
thin thin provisioning
trim FITRIM ioctl
udf UDF functionality tests
--
2.39.3
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH v2 03/10] btrfs: create a helper function, check_fsid(), to verify the tempfsid
2024-02-19 19:48 [PATCH v2 00/10] btrfs: functional test cases for tempfsid Anand Jain
2024-02-19 19:48 ` [PATCH v2 01/10] assign SCRATCH_DEV_POOL to an array Anand Jain
2024-02-19 19:48 ` [PATCH v2 02/10] btrfs: introduce tempfsid test group Anand Jain
@ 2024-02-19 19:48 ` Anand Jain
2024-02-20 16:24 ` Filipe Manana
2024-02-19 19:48 ` [PATCH v2 04/10] btrfs: verify that subvolume mounts are unaffected by tempfsid Anand Jain
` (6 subsequent siblings)
9 siblings, 1 reply; 26+ messages in thread
From: Anand Jain @ 2024-02-19 19:48 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, zlang, fdmanana
check_fsid() provides a method to verify if the given device is mounted
with the tempfsid in the kernel. Function sb() is an internal only
function.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2:
Drop the function sb()
Use $AWK_PROG instead of awk.
egrep -> grep -E
common/btrfs | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/common/btrfs b/common/btrfs
index e1b29c613767..797f6a794dfc 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -792,3 +792,38 @@ _has_btrfs_sysfs_feature_attr()
test -e /sys/fs/btrfs/features/$feature_attr
}
+
+# Print the fsid and metadata uuid replaced with constant strings FSID and
+# METADATA_UUID. Compare temp_fsid with fsid and metadata_uuid, then echo what
+# it matches to or TEMP_FSID. This helps in comparing with the golden output.
+check_fsid()
+{
+ local dev1=$1
+ local fsid
+ local metadata_uuid
+
+ # on disk fsid
+ fsid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
+ grep ^fsid | $AWK_PROG -d" " '{print $2}')
+ echo -e "On disk fsid:\t\t$fsid" | sed -e "s/$fsid/FSID/g"
+
+ # Print FSID even if it is not the same as metadata_uuid because it has
+ # to match in the golden output.
+ metadata_uuid=$(cat /sys/fs/btrfs/$fsid/metadata_uuid)
+ echo -e "Metadata uuid:\t\tFSID"
+
+ # This returns the temp_fsid if set
+ tempfsid=$(_btrfs_get_fsid $dev1)
+ if [[ $tempfsid == $fsid ]]; then
+ echo -e "Temp fsid:\t\tFSID"
+ elif [[ $tempfsid == $metadata_uuid ]]; then
+ # If we are here, it means there is a bug; let it not match with
+ # the golden output.
+ echo -e "Temp fsid:\t\t$metadata_uuid"
+ else
+ echo -e "Temp fsid:\t\tTEMPFSID"
+ fi
+
+ echo -e -n "Tempfsid status:\t"
+ cat /sys/fs/btrfs/$tempfsid/temp_fsid
+}
--
2.39.3
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v2 03/10] btrfs: create a helper function, check_fsid(), to verify the tempfsid
2024-02-19 19:48 ` [PATCH v2 03/10] btrfs: create a helper function, check_fsid(), to verify the tempfsid Anand Jain
@ 2024-02-20 16:24 ` Filipe Manana
0 siblings, 0 replies; 26+ messages in thread
From: Filipe Manana @ 2024-02-20 16:24 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs, zlang
On Mon, Feb 19, 2024 at 7:49 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> check_fsid() provides a method to verify if the given device is mounted
> with the tempfsid in the kernel. Function sb() is an internal only
> function.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Looks good, thanks.
> ---
> v2:
> Drop the function sb()
> Use $AWK_PROG instead of awk.
> egrep -> grep -E
>
> common/btrfs | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/common/btrfs b/common/btrfs
> index e1b29c613767..797f6a794dfc 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -792,3 +792,38 @@ _has_btrfs_sysfs_feature_attr()
>
> test -e /sys/fs/btrfs/features/$feature_attr
> }
> +
> +# Print the fsid and metadata uuid replaced with constant strings FSID and
> +# METADATA_UUID. Compare temp_fsid with fsid and metadata_uuid, then echo what
> +# it matches to or TEMP_FSID. This helps in comparing with the golden output.
> +check_fsid()
> +{
> + local dev1=$1
> + local fsid
> + local metadata_uuid
> +
> + # on disk fsid
> + fsid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
> + grep ^fsid | $AWK_PROG -d" " '{print $2}')
> + echo -e "On disk fsid:\t\t$fsid" | sed -e "s/$fsid/FSID/g"
> +
> + # Print FSID even if it is not the same as metadata_uuid because it has
> + # to match in the golden output.
> + metadata_uuid=$(cat /sys/fs/btrfs/$fsid/metadata_uuid)
> + echo -e "Metadata uuid:\t\tFSID"
> +
> + # This returns the temp_fsid if set
> + tempfsid=$(_btrfs_get_fsid $dev1)
> + if [[ $tempfsid == $fsid ]]; then
> + echo -e "Temp fsid:\t\tFSID"
> + elif [[ $tempfsid == $metadata_uuid ]]; then
> + # If we are here, it means there is a bug; let it not match with
> + # the golden output.
> + echo -e "Temp fsid:\t\t$metadata_uuid"
> + else
> + echo -e "Temp fsid:\t\tTEMPFSID"
> + fi
> +
> + echo -e -n "Tempfsid status:\t"
> + cat /sys/fs/btrfs/$tempfsid/temp_fsid
> +}
> --
> 2.39.3
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v2 04/10] btrfs: verify that subvolume mounts are unaffected by tempfsid
2024-02-19 19:48 [PATCH v2 00/10] btrfs: functional test cases for tempfsid Anand Jain
` (2 preceding siblings ...)
2024-02-19 19:48 ` [PATCH v2 03/10] btrfs: create a helper function, check_fsid(), to verify the tempfsid Anand Jain
@ 2024-02-19 19:48 ` Anand Jain
2024-02-20 16:30 ` Filipe Manana
2024-02-19 19:48 ` [PATCH v2 05/10] btrfs: check if cloned device mounts with tempfsid Anand Jain
` (5 subsequent siblings)
9 siblings, 1 reply; 26+ messages in thread
From: Anand Jain @ 2024-02-19 19:48 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, zlang, fdmanana
The tempfsid logic must determine whether the incoming mount request
is for a device already mounted or a new device mount. Verify that it
recognizes the device already mounted well by creating reflink across
the subvolume mount points.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2:
add subvol group
use $UMOUNT_PROG
remove _fail for _cp_reflink
tests/btrfs/311 | 89 +++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/311.out | 24 ++++++++++++
2 files changed, 113 insertions(+)
create mode 100755 tests/btrfs/311
create mode 100644 tests/btrfs/311.out
diff --git a/tests/btrfs/311 b/tests/btrfs/311
new file mode 100755
index 000000000000..cebbc3a59e6a
--- /dev/null
+++ b/tests/btrfs/311
@@ -0,0 +1,89 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oracle. All Rights Reserved.
+#
+# FS QA Test 311
+#
+# Mount the device twice check if the reflink works, this helps to
+# ensure device is mounted as the same device.
+#
+. ./common/preamble
+_begin_fstest auto quick subvol tempfsid
+
+# Override the default cleanup function.
+_cleanup()
+{
+ cd /
+ $UMOUNT_PROG $mnt1 > /dev/null 2>&1
+ rm -r -f $tmp.*
+ rm -r -f $mnt1
+}
+
+. ./common/filter.btrfs
+. ./common/reflink
+
+# Modify as appropriate.
+_supported_fs btrfs
+_require_cp_reflink
+_require_btrfs_sysfs_fsid
+_require_btrfs_fs_feature temp_fsid
+_require_btrfs_command inspect-internal dump-super
+_require_scratch
+
+mnt1=$TEST_DIR/$seq/mnt1
+mkdir -p $mnt1
+
+same_dev_mount()
+{
+ echo ---- $FUNCNAME ----
+
+ _scratch_mkfs >> $seqres.full 2>&1
+
+ _scratch_mount
+ $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | \
+ _filter_xfs_io
+
+ echo Mount the device again to a different mount point
+ _mount $SCRATCH_DEV $mnt1
+
+ _cp_reflink $SCRATCH_MNT/foo $mnt1/bar
+ echo Checksum of reflinked files
+ md5sum $SCRATCH_MNT/foo | _filter_scratch
+ md5sum $mnt1/bar | _filter_test_dir
+
+ check_fsid $SCRATCH_DEV
+}
+
+same_dev_subvol_mount()
+{
+ echo ---- $FUNCNAME ----
+ _scratch_mkfs >> $seqres.full 2>&1
+
+ _scratch_mount
+ $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol
+
+ $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/subvol/foo | \
+ _filter_xfs_io
+
+ echo Mounting a subvol
+ _mount -o subvol=subvol $SCRATCH_DEV $mnt1
+
+ _cp_reflink $SCRATCH_MNT/subvol/foo $mnt1/bar
+ echo Checksum of reflinked files
+ md5sum $SCRATCH_MNT/subvol/foo | _filter_scratch
+ md5sum $mnt1/bar | _filter_test_dir
+
+ check_fsid $SCRATCH_DEV
+}
+
+same_dev_mount
+
+_scratch_unmount
+_cleanup
+mkdir -p $mnt1
+
+same_dev_subvol_mount
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/311.out b/tests/btrfs/311.out
new file mode 100644
index 000000000000..8787f24ab867
--- /dev/null
+++ b/tests/btrfs/311.out
@@ -0,0 +1,24 @@
+QA output created by 311
+---- same_dev_mount ----
+wrote 9000/9000 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Mount the device again to a different mount point
+Checksum of reflinked files
+42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/foo
+42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/311/mnt1/bar
+On disk fsid: FSID
+Metadata uuid: FSID
+Temp fsid: FSID
+Tempfsid status: 0
+---- same_dev_subvol_mount ----
+Create subvolume '/mnt/scratch/subvol'
+wrote 9000/9000 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Mounting a subvol
+Checksum of reflinked files
+42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/subvol/foo
+42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/311/mnt1/bar
+On disk fsid: FSID
+Metadata uuid: FSID
+Temp fsid: FSID
+Tempfsid status: 0
--
2.39.3
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v2 04/10] btrfs: verify that subvolume mounts are unaffected by tempfsid
2024-02-19 19:48 ` [PATCH v2 04/10] btrfs: verify that subvolume mounts are unaffected by tempfsid Anand Jain
@ 2024-02-20 16:30 ` Filipe Manana
2024-02-23 17:22 ` Anand Jain
0 siblings, 1 reply; 26+ messages in thread
From: Filipe Manana @ 2024-02-20 16:30 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs, zlang
On Mon, Feb 19, 2024 at 7:49 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> The tempfsid logic must determine whether the incoming mount request
> is for a device already mounted or a new device mount. Verify that it
> recognizes the device already mounted well by creating reflink across
> the subvolume mount points.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v2:
> add subvol group
> use $UMOUNT_PROG
> remove _fail for _cp_reflink
>
> tests/btrfs/311 | 89 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/311.out | 24 ++++++++++++
> 2 files changed, 113 insertions(+)
> create mode 100755 tests/btrfs/311
> create mode 100644 tests/btrfs/311.out
>
> diff --git a/tests/btrfs/311 b/tests/btrfs/311
> new file mode 100755
> index 000000000000..cebbc3a59e6a
> --- /dev/null
> +++ b/tests/btrfs/311
> @@ -0,0 +1,89 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2024 Oracle. All Rights Reserved.
> +#
> +# FS QA Test 311
> +#
> +# Mount the device twice check if the reflink works, this helps to
> +# ensure device is mounted as the same device.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick subvol tempfsid
> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> + cd /
> + $UMOUNT_PROG $mnt1 > /dev/null 2>&1
> + rm -r -f $tmp.*
> + rm -r -f $mnt1
> +}
> +
> +. ./common/filter.btrfs
> +. ./common/reflink
> +
> +# Modify as appropriate.
> +_supported_fs btrfs
> +_require_cp_reflink
> +_require_btrfs_sysfs_fsid
> +_require_btrfs_fs_feature temp_fsid
> +_require_btrfs_command inspect-internal dump-super
> +_require_scratch
> +
> +mnt1=$TEST_DIR/$seq/mnt1
> +mkdir -p $mnt1
> +
> +same_dev_mount()
> +{
> + echo ---- $FUNCNAME ----
> +
> + _scratch_mkfs >> $seqres.full 2>&1
> +
> + _scratch_mount
> + $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | \
> + _filter_xfs_io
> +
> + echo Mount the device again to a different mount point
> + _mount $SCRATCH_DEV $mnt1
> +
> + _cp_reflink $SCRATCH_MNT/foo $mnt1/bar
> + echo Checksum of reflinked files
> + md5sum $SCRATCH_MNT/foo | _filter_scratch
> + md5sum $mnt1/bar | _filter_test_dir
> +
> + check_fsid $SCRATCH_DEV
> +}
> +
> +same_dev_subvol_mount()
> +{
> + echo ---- $FUNCNAME ----
> + _scratch_mkfs >> $seqres.full 2>&1
> +
> + _scratch_mount
> + $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol
Need to use: | _filter_scratch
See the golden output below.
> +
> + $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/subvol/foo | \
> + _filter_xfs_io
> +
> + echo Mounting a subvol
> + _mount -o subvol=subvol $SCRATCH_DEV $mnt1
> +
> + _cp_reflink $SCRATCH_MNT/subvol/foo $mnt1/bar
> + echo Checksum of reflinked files
> + md5sum $SCRATCH_MNT/subvol/foo | _filter_scratch
> + md5sum $mnt1/bar | _filter_test_dir
> +
> + check_fsid $SCRATCH_DEV
> +}
> +
> +same_dev_mount
> +
> +_scratch_unmount
> +_cleanup
> +mkdir -p $mnt1
> +
> +same_dev_subvol_mount
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/btrfs/311.out b/tests/btrfs/311.out
> new file mode 100644
> index 000000000000..8787f24ab867
> --- /dev/null
> +++ b/tests/btrfs/311.out
> @@ -0,0 +1,24 @@
> +QA output created by 311
> +---- same_dev_mount ----
> +wrote 9000/9000 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +Mount the device again to a different mount point
> +Checksum of reflinked files
> +42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/foo
> +42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/311/mnt1/bar
> +On disk fsid: FSID
> +Metadata uuid: FSID
> +Temp fsid: FSID
> +Tempfsid status: 0
> +---- same_dev_subvol_mount ----
> +Create subvolume '/mnt/scratch/subvol'
Because of this...
Otherwise it looks fine.
With that corrected:
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Thanks.
> +wrote 9000/9000 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +Mounting a subvol
> +Checksum of reflinked files
> +42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/subvol/foo
> +42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/311/mnt1/bar
> +On disk fsid: FSID
> +Metadata uuid: FSID
> +Temp fsid: FSID
> +Tempfsid status: 0
> --
> 2.39.3
>
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [PATCH v2 04/10] btrfs: verify that subvolume mounts are unaffected by tempfsid
2024-02-20 16:30 ` Filipe Manana
@ 2024-02-23 17:22 ` Anand Jain
0 siblings, 0 replies; 26+ messages in thread
From: Anand Jain @ 2024-02-23 17:22 UTC (permalink / raw)
To: Filipe Manana; +Cc: fstests, linux-btrfs, zlang
On 2/20/24 22:00, Filipe Manana wrote:
> On Mon, Feb 19, 2024 at 7:49 PM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> The tempfsid logic must determine whether the incoming mount request
>> is for a device already mounted or a new device mount. Verify that it
>> recognizes the device already mounted well by creating reflink across
>> the subvolume mount points.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> v2:
>> add subvol group
>> use $UMOUNT_PROG
>> remove _fail for _cp_reflink
>>
>> tests/btrfs/311 | 89 +++++++++++++++++++++++++++++++++++++++++++++
>> tests/btrfs/311.out | 24 ++++++++++++
>> 2 files changed, 113 insertions(+)
>> create mode 100755 tests/btrfs/311
>> create mode 100644 tests/btrfs/311.out
>>
>> diff --git a/tests/btrfs/311 b/tests/btrfs/311
>> new file mode 100755
>> index 000000000000..cebbc3a59e6a
>> --- /dev/null
>> +++ b/tests/btrfs/311
>> @@ -0,0 +1,89 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2024 Oracle. All Rights Reserved.
>> +#
>> +# FS QA Test 311
>> +#
>> +# Mount the device twice check if the reflink works, this helps to
>> +# ensure device is mounted as the same device.
>> +#
>> +. ./common/preamble
>> +_begin_fstest auto quick subvol tempfsid
>> +
>> +# Override the default cleanup function.
>> +_cleanup()
>> +{
>> + cd /
>> + $UMOUNT_PROG $mnt1 > /dev/null 2>&1
>> + rm -r -f $tmp.*
>> + rm -r -f $mnt1
>> +}
>> +
>> +. ./common/filter.btrfs
>> +. ./common/reflink
>> +
>> +# Modify as appropriate.
>> +_supported_fs btrfs
>> +_require_cp_reflink
>> +_require_btrfs_sysfs_fsid
>> +_require_btrfs_fs_feature temp_fsid
>> +_require_btrfs_command inspect-internal dump-super
>> +_require_scratch
>> +
>> +mnt1=$TEST_DIR/$seq/mnt1
>> +mkdir -p $mnt1
>> +
>> +same_dev_mount()
>> +{
>> + echo ---- $FUNCNAME ----
>> +
>> + _scratch_mkfs >> $seqres.full 2>&1
>> +
>> + _scratch_mount
>> + $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | \
>> + _filter_xfs_io
>> +
>> + echo Mount the device again to a different mount point
>> + _mount $SCRATCH_DEV $mnt1
>> +
>> + _cp_reflink $SCRATCH_MNT/foo $mnt1/bar
>> + echo Checksum of reflinked files
>> + md5sum $SCRATCH_MNT/foo | _filter_scratch
>> + md5sum $mnt1/bar | _filter_test_dir
>> +
>> + check_fsid $SCRATCH_DEV
>> +}
>> +
>> +same_dev_subvol_mount()
>> +{
>> + echo ---- $FUNCNAME ----
>> + _scratch_mkfs >> $seqres.full 2>&1
>> +
>> + _scratch_mount
>> + $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol
>
> Need to use: | _filter_scratch
> See the golden output below.
>
>> +
>> + $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/subvol/foo | \
>> + _filter_xfs_io
>> +
>> + echo Mounting a subvol
>> + _mount -o subvol=subvol $SCRATCH_DEV $mnt1
>> +
>> + _cp_reflink $SCRATCH_MNT/subvol/foo $mnt1/bar
>> + echo Checksum of reflinked files
>> + md5sum $SCRATCH_MNT/subvol/foo | _filter_scratch
>> + md5sum $mnt1/bar | _filter_test_dir
>> +
>> + check_fsid $SCRATCH_DEV
>> +}
>> +
>> +same_dev_mount
>> +
>> +_scratch_unmount
>> +_cleanup
>> +mkdir -p $mnt1
>> +
>> +same_dev_subvol_mount
>> +
>> +# success, all done
>> +status=0
>> +exit
>> diff --git a/tests/btrfs/311.out b/tests/btrfs/311.out
>> new file mode 100644
>> index 000000000000..8787f24ab867
>> --- /dev/null
>> +++ b/tests/btrfs/311.out
>> @@ -0,0 +1,24 @@
>> +QA output created by 311
>> +---- same_dev_mount ----
>> +wrote 9000/9000 bytes at offset 0
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +Mount the device again to a different mount point
>> +Checksum of reflinked files
>> +42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/foo
>> +42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/311/mnt1/bar
>> +On disk fsid: FSID
>> +Metadata uuid: FSID
>> +Temp fsid: FSID
>> +Tempfsid status: 0
>> +---- same_dev_subvol_mount ----
>> +Create subvolume '/mnt/scratch/subvol'
>
> Because of this...
>
> Otherwise it looks fine.
>
> With that corrected:
>
> Reviewed-by: Filipe Manana <fdmanana@suse.com>
>
Fixed this locally. Thanks, Anand
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v2 05/10] btrfs: check if cloned device mounts with tempfsid
2024-02-19 19:48 [PATCH v2 00/10] btrfs: functional test cases for tempfsid Anand Jain
` (3 preceding siblings ...)
2024-02-19 19:48 ` [PATCH v2 04/10] btrfs: verify that subvolume mounts are unaffected by tempfsid Anand Jain
@ 2024-02-19 19:48 ` Anand Jain
2024-02-20 16:44 ` Filipe Manana
2024-02-19 19:48 ` [PATCH v2 06/10] btrfs: test case prerequisite _require_btrfs_mkfs_uuid_option Anand Jain
` (4 subsequent siblings)
9 siblings, 1 reply; 26+ messages in thread
From: Anand Jain @ 2024-02-19 19:48 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, zlang, fdmanana
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>
---
v2:
Bring create_cloned_devices() into the testcase.
Just use _cp_reflink output to match with golden output.
tests/btrfs/312 | 85 +++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/312.out | 19 ++++++++++
2 files changed, 104 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..6dd5811ddaa5
--- /dev/null
+++ b/tests/btrfs/312
@@ -0,0 +1,85 @@
+#! /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 tempfsid
+
+_cleanup()
+{
+ cd /
+ umount $mnt1 > /dev/null 2>&1
+ rm -r -f $tmp.*
+ rm -r -f $mnt1
+}
+
+. ./common/filter.btrfs
+. ./common/reflink
+
+_supported_fs btrfs
+_require_btrfs_sysfs_fsid
+_require_btrfs_fs_feature temp_fsid
+_require_btrfs_command inspect-internal dump-super
+_require_scratch_dev_pool 2
+_scratch_dev_pool_get 2
+
+mnt1=$TEST_DIR/$seq/mnt1
+mkdir -p $mnt1
+
+create_cloned_devices()
+{
+ local dev1=$1
+ local dev2=$2
+
+ [[ -z $dev1 || -z $dev2 ]] && \
+ _fail "create_cloned_devices() requires two devices as arguments"
+
+ 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()
+{
+ local ret
+
+ 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
--
2.39.3
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v2 05/10] btrfs: check if cloned device mounts with tempfsid
2024-02-19 19:48 ` [PATCH v2 05/10] btrfs: check if cloned device mounts with tempfsid Anand Jain
@ 2024-02-20 16:44 ` Filipe Manana
2024-02-23 17:35 ` Anand Jain
0 siblings, 1 reply; 26+ messages in thread
From: Filipe Manana @ 2024-02-20 16:44 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs, zlang
On Mon, Feb 19, 2024 at 7:49 PM 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>
> ---
> v2:
> Bring create_cloned_devices() into the testcase.
> Just use _cp_reflink output to match with golden output.
>
> tests/btrfs/312 | 85 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/312.out | 19 ++++++++++
> 2 files changed, 104 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..6dd5811ddaa5
> --- /dev/null
> +++ b/tests/btrfs/312
> @@ -0,0 +1,85 @@
> +#! /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 tempfsid
This exercises reflinks, so it should have the 'clone' group as well.
> +
> +_cleanup()
> +{
> + cd /
> + umount $mnt1 > /dev/null 2>&1
Same as mentioned before, use $UMOUNT_PROG
> + rm -r -f $tmp.*
> + rm -r -f $mnt1
> +}
> +
> +. ./common/filter.btrfs
> +. ./common/reflink
> +
> +_supported_fs btrfs
> +_require_btrfs_sysfs_fsid
> +_require_btrfs_fs_feature temp_fsid
> +_require_btrfs_command inspect-internal dump-super
Instead of requiring here the inspect-internal command, it should be
inside check_fsid()
That's the pattern we usually do, common functions have the _require_*
calls, avoiding the caller test to have to know each dependency and
copy-paste it.
Other than that, it looks fine.
Thanks.
> +_require_scratch_dev_pool 2
> +_scratch_dev_pool_get 2
> +
> +mnt1=$TEST_DIR/$seq/mnt1
> +mkdir -p $mnt1
> +
> +create_cloned_devices()
> +{
> + local dev1=$1
> + local dev2=$2
> +
> + [[ -z $dev1 || -z $dev2 ]] && \
> + _fail "create_cloned_devices() requires two devices as arguments"
> +
> + 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()
> +{
> + local ret
> +
> + 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
> --
> 2.39.3
>
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [PATCH v2 05/10] btrfs: check if cloned device mounts with tempfsid
2024-02-20 16:44 ` Filipe Manana
@ 2024-02-23 17:35 ` Anand Jain
0 siblings, 0 replies; 26+ messages in thread
From: Anand Jain @ 2024-02-23 17:35 UTC (permalink / raw)
To: Filipe Manana; +Cc: fstests, linux-btrfs, zlang
>> +_begin_fstest auto quick tempfsid
>
> This exercises reflinks, so it should have the 'clone' group as well.
Ok. I've added to the clone group now.
>
>> +
>> +_cleanup()
>> +{
>> + cd /
>> + umount $mnt1 > /dev/null 2>&1
>
> Same as mentioned before, use $UMOUNT_PROG
Thx. Fixed it.
>
>> + rm -r -f $tmp.*
>> + rm -r -f $mnt1
>> +}
>> +
>> +. ./common/filter.btrfs
>> +. ./common/reflink
>> +
>> +_supported_fs btrfs
>> +_require_btrfs_sysfs_fsid
>> +_require_btrfs_fs_feature temp_fsid
>> +_require_btrfs_command inspect-internal dump-super
>
> Instead of requiring here the inspect-internal command, it should be
> inside check_fsid()
>
> That's the pattern we usually do, common functions have the _require_*
> calls, avoiding the caller test to have to know each dependency and
> copy-paste it.
>
Sure, I'll moved the prerequisite check to the function check_fsid().
Thx Anand
> Other than that, it looks fine.
> Thanks.
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v2 06/10] btrfs: test case prerequisite _require_btrfs_mkfs_uuid_option
2024-02-19 19:48 [PATCH v2 00/10] btrfs: functional test cases for tempfsid Anand Jain
` (4 preceding siblings ...)
2024-02-19 19:48 ` [PATCH v2 05/10] btrfs: check if cloned device mounts with tempfsid Anand Jain
@ 2024-02-19 19:48 ` Anand Jain
2024-02-20 16:47 ` Filipe Manana
2024-02-19 19:48 ` [PATCH v2 07/10] btrfs: introduce helper for creating cloned devices with mkfs Anand Jain
` (3 subsequent siblings)
9 siblings, 1 reply; 26+ messages in thread
From: Anand Jain @ 2024-02-19 19:48 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, zlang, fdmanana
For easier and more effective testing of btrfs tempfsid, newer versions
of mkfs.btrfs contain options such as --device-uuid. Check if the
currently running mkfs.btrfs contains this option.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2:
Fix coding style, add space before grep
Fix typp option -> options
common/btrfs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/common/btrfs b/common/btrfs
index 797f6a794dfc..f694afac3d13 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -88,6 +88,17 @@ _require_btrfs_mkfs_feature()
_notrun "Feature $feat not supported in the available version of mkfs.btrfs"
}
+_require_btrfs_mkfs_uuid_option()
+{
+ local cnt
+
+ cnt=$($MKFS_BTRFS_PROG --help 2>&1 | \
+ grep -E --count "\-\-uuid|\-\-device-uuid")
+ if [ $cnt != 2 ]; then
+ _notrun "Require $MKFS_BTRFS_PROG with --uuid and --device-uuid options"
+ fi
+}
+
_require_btrfs_fs_feature()
{
if [ -z $1 ]; then
--
2.39.3
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v2 06/10] btrfs: test case prerequisite _require_btrfs_mkfs_uuid_option
2024-02-19 19:48 ` [PATCH v2 06/10] btrfs: test case prerequisite _require_btrfs_mkfs_uuid_option Anand Jain
@ 2024-02-20 16:47 ` Filipe Manana
0 siblings, 0 replies; 26+ messages in thread
From: Filipe Manana @ 2024-02-20 16:47 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs, zlang
On Mon, Feb 19, 2024 at 7:49 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> For easier and more effective testing of btrfs tempfsid, newer versions
> of mkfs.btrfs contain options such as --device-uuid. Check if the
> currently running mkfs.btrfs contains this option.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Looks good, thanks.
> ---
> v2:
> Fix coding style, add space before grep
> Fix typp option -> options
>
> common/btrfs | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/common/btrfs b/common/btrfs
> index 797f6a794dfc..f694afac3d13 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -88,6 +88,17 @@ _require_btrfs_mkfs_feature()
> _notrun "Feature $feat not supported in the available version of mkfs.btrfs"
> }
>
> +_require_btrfs_mkfs_uuid_option()
> +{
> + local cnt
> +
> + cnt=$($MKFS_BTRFS_PROG --help 2>&1 | \
> + grep -E --count "\-\-uuid|\-\-device-uuid")
> + if [ $cnt != 2 ]; then
> + _notrun "Require $MKFS_BTRFS_PROG with --uuid and --device-uuid options"
> + fi
> +}
> +
> _require_btrfs_fs_feature()
> {
> if [ -z $1 ]; then
> --
> 2.39.3
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v2 07/10] btrfs: introduce helper for creating cloned devices with mkfs
2024-02-19 19:48 [PATCH v2 00/10] btrfs: functional test cases for tempfsid Anand Jain
` (5 preceding siblings ...)
2024-02-19 19:48 ` [PATCH v2 06/10] btrfs: test case prerequisite _require_btrfs_mkfs_uuid_option Anand Jain
@ 2024-02-19 19:48 ` Anand Jain
2024-02-20 16:51 ` Filipe Manana
2024-02-19 19:48 ` [PATCH v2 08/10] btrfs: verify tempfsid clones using mkfs Anand Jain
` (2 subsequent siblings)
9 siblings, 1 reply; 26+ messages in thread
From: Anand Jain @ 2024-02-19 19:48 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, zlang, fdmanana
Use newer mkfs.btrfs option to generate two cloned devices,
used in test cases.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2:
Organize changes to its right patch.
Fix _fail erorr message.
Declare local variables for fsid and uuid.
common/btrfs | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/common/btrfs b/common/btrfs
index f694afac3d13..c3e5827562d6 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -838,3 +838,24 @@ check_fsid()
echo -e -n "Tempfsid status:\t"
cat /sys/fs/btrfs/$tempfsid/temp_fsid
}
+
+mkfs_clone()
+{
+ local fsid
+ local uuid
+ local dev1=$1
+ local dev2=$2
+
+ [[ -z $dev1 || -z $dev2 ]] && \
+ _fail "mkfs_clone requires two devices as arguments"
+
+ _mkfs_dev -fq $dev1
+
+ fsid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
+ grep -E ^fsid | $AWK_PROG '{print $2}')
+ uuid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
+ grep -E ^dev_item.uuid | $AWK_PROG '{print $2}')
+
+ _mkfs_dev -fq --uuid $fsid --device-uuid $uuid $dev2
+}
+>>>>>>> e22bb3c816c1 (btrfs: introduce helper for creating cloned devices with mkfs)
--
2.39.3
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v2 07/10] btrfs: introduce helper for creating cloned devices with mkfs
2024-02-19 19:48 ` [PATCH v2 07/10] btrfs: introduce helper for creating cloned devices with mkfs Anand Jain
@ 2024-02-20 16:51 ` Filipe Manana
2024-02-23 17:44 ` Anand Jain
0 siblings, 1 reply; 26+ messages in thread
From: Filipe Manana @ 2024-02-20 16:51 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs, zlang
On Mon, Feb 19, 2024 at 7:49 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> Use newer mkfs.btrfs option to generate two cloned devices,
> used in test cases.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v2:
> Organize changes to its right patch.
> Fix _fail erorr message.
> Declare local variables for fsid and uuid.
>
> common/btrfs | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/common/btrfs b/common/btrfs
> index f694afac3d13..c3e5827562d6 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -838,3 +838,24 @@ check_fsid()
> echo -e -n "Tempfsid status:\t"
> cat /sys/fs/btrfs/$tempfsid/temp_fsid
> }
> +
> +mkfs_clone()
> +{
> + local fsid
> + local uuid
> + local dev1=$1
> + local dev2=$2
> +
> + [[ -z $dev1 || -z $dev2 ]] && \
> + _fail "mkfs_clone requires two devices as arguments"
> +
> + _mkfs_dev -fq $dev1
> +
> + fsid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
> + grep -E ^fsid | $AWK_PROG '{print $2}')
> + uuid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
> + grep -E ^dev_item.uuid | $AWK_PROG '{print $2}')
> +
> + _mkfs_dev -fq --uuid $fsid --device-uuid $uuid $dev2
So this function should call:
_require_btrfs_command inspect-internal dump-super
_require_btrfs_mkfs_uuid_option
Instead of having all the test cases that use it to do those calls, as
mentioned in a previous patch.
> +}
> +>>>>>>> e22bb3c816c1 (btrfs: introduce helper for creating cloned devices with mkfs)
This isn't supposed to be here...
Thanks.
> --
> 2.39.3
>
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [PATCH v2 07/10] btrfs: introduce helper for creating cloned devices with mkfs
2024-02-20 16:51 ` Filipe Manana
@ 2024-02-23 17:44 ` Anand Jain
0 siblings, 0 replies; 26+ messages in thread
From: Anand Jain @ 2024-02-23 17:44 UTC (permalink / raw)
To: Filipe Manana; +Cc: fstests, linux-btrfs, zlang
On 2/20/24 22:21, Filipe Manana wrote:
> On Mon, Feb 19, 2024 at 7:49 PM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> Use newer mkfs.btrfs option to generate two cloned devices,
>> used in test cases.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> v2:
>> Organize changes to its right patch.
>> Fix _fail erorr message.
>> Declare local variables for fsid and uuid.
>>
>> common/btrfs | 21 +++++++++++++++++++++
>> 1 file changed, 21 insertions(+)
>>
>> diff --git a/common/btrfs b/common/btrfs
>> index f694afac3d13..c3e5827562d6 100644
>> --- a/common/btrfs
>> +++ b/common/btrfs
>> @@ -838,3 +838,24 @@ check_fsid()
>> echo -e -n "Tempfsid status:\t"
>> cat /sys/fs/btrfs/$tempfsid/temp_fsid
>> }
>> +
>> +mkfs_clone()
>> +{
>> + local fsid
>> + local uuid
>> + local dev1=$1
>> + local dev2=$2
>> +
>> + [[ -z $dev1 || -z $dev2 ]] && \
>> + _fail "mkfs_clone requires two devices as arguments"
>> +
>> + _mkfs_dev -fq $dev1
>> +
>> + fsid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
>> + grep -E ^fsid | $AWK_PROG '{print $2}')
>> + uuid=$($BTRFS_UTIL_PROG inspect-internal dump-super $dev1 | \
>> + grep -E ^dev_item.uuid | $AWK_PROG '{print $2}')
>> +
>> + _mkfs_dev -fq --uuid $fsid --device-uuid $uuid $dev2
>
> So this function should call:
>
> _require_btrfs_command inspect-internal dump-super
> _require_btrfs_mkfs_uuid_option
>
Added these two perreq to the helper function.
> Instead of having all the test cases that use it to do those calls, as
> mentioned in a previous patch.
>
>> +}
>> +>>>>>>> e22bb3c816c1 (btrfs: introduce helper for creating cloned devices with mkfs)
>
> This isn't supposed to be here...
Oops. Now removed.
Thanks for the review.
-Anand
>
> Thanks.
>
>> --
>> 2.39.3
>>
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v2 08/10] btrfs: verify tempfsid clones using mkfs
2024-02-19 19:48 [PATCH v2 00/10] btrfs: functional test cases for tempfsid Anand Jain
` (6 preceding siblings ...)
2024-02-19 19:48 ` [PATCH v2 07/10] btrfs: introduce helper for creating cloned devices with mkfs Anand Jain
@ 2024-02-19 19:48 ` Anand Jain
2024-02-20 16:55 ` Filipe Manana
2024-02-19 19:48 ` [PATCH v2 09/10] btrfs: validate send-receive operation with tempfsid Anand Jain
2024-02-19 19:48 ` [PATCH v2 10/10] btrfs: test tempfsid with device add, seed, and balance Anand Jain
9 siblings, 1 reply; 26+ messages in thread
From: Anand Jain @ 2024-02-19 19:48 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, zlang, fdmanana
Create appearing to be a clone using the mkfs.btrfs option and test if
the tempfsid is active.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2:
Remove unnecessary function.
Add clone group
use $UMOUNT_PROG
Let _cp_reflink fail on the stdout.
tests/btrfs/313 | 55 +++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/313.out | 16 +++++++++++++
2 files changed, 71 insertions(+)
create mode 100755 tests/btrfs/313
create mode 100644 tests/btrfs/313.out
diff --git a/tests/btrfs/313 b/tests/btrfs/313
new file mode 100755
index 000000000000..c495a770c212
--- /dev/null
+++ b/tests/btrfs/313
@@ -0,0 +1,55 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oracle. All Rights Reserved.
+#
+# FS QA Test 313
+#
+# Functional test for the tempfsid, clone devices created using the mkfs option.
+#
+. ./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_cp_reflink
+_require_btrfs_sysfs_fsid
+_require_scratch_dev_pool 2
+_require_btrfs_fs_feature temp_fsid
+_require_btrfs_command inspect-internal dump-super
+_require_btrfs_mkfs_uuid_option
+
+_scratch_dev_pool_get 2
+
+mnt1=$TEST_DIR/$seq/mnt1
+mkdir -p $mnt1
+
+echo ---- clone_uuids_verify_tempfsid ----
+mkfs_clone ${SCRATCH_DEV_NAME[0]} ${SCRATCH_DEV_NAME[1]}
+
+echo Mounting original device
+_mount ${SCRATCH_DEV_NAME[0]} $SCRATCH_MNT
+check_fsid ${SCRATCH_DEV_NAME[0]}
+
+echo Mounting cloned device
+_mount ${SCRATCH_DEV_NAME[1]} $mnt1
+check_fsid ${SCRATCH_DEV_NAME[1]}
+
+$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | _filter_xfs_io
+echo cp reflink must fail
+_cp_reflink $SCRATCH_MNT/foo $mnt1/bar 2>&1 | _filter_testdir_and_scratch
+
+_scratch_dev_pool_put
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/313.out b/tests/btrfs/313.out
new file mode 100644
index 000000000000..7a089d2c29c5
--- /dev/null
+++ b/tests/btrfs/313.out
@@ -0,0 +1,16 @@
+QA output created by 313
+---- clone_uuids_verify_tempfsid ----
+Mounting original device
+On disk fsid: FSID
+Metadata uuid: FSID
+Temp fsid: FSID
+Tempfsid status: 0
+Mounting cloned device
+On disk fsid: FSID
+Metadata uuid: FSID
+Temp fsid: TEMPFSID
+Tempfsid status: 1
+wrote 9000/9000 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+cp reflink must fail
+cp: failed to clone 'TEST_DIR/313/mnt1/bar' from 'SCRATCH_MNT/foo': Invalid cross-device link
--
2.39.3
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v2 08/10] btrfs: verify tempfsid clones using mkfs
2024-02-19 19:48 ` [PATCH v2 08/10] btrfs: verify tempfsid clones using mkfs Anand Jain
@ 2024-02-20 16:55 ` Filipe Manana
2024-02-24 11:41 ` Anand Jain
0 siblings, 1 reply; 26+ messages in thread
From: Filipe Manana @ 2024-02-20 16:55 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs, zlang
On Mon, Feb 19, 2024 at 7:50 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> Create appearing to be a clone using the mkfs.btrfs option and test if
> the tempfsid is active.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v2:
> Remove unnecessary function.
> Add clone group
> use $UMOUNT_PROG
> Let _cp_reflink fail on the stdout.
>
> tests/btrfs/313 | 55 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/313.out | 16 +++++++++++++
> 2 files changed, 71 insertions(+)
> create mode 100755 tests/btrfs/313
> create mode 100644 tests/btrfs/313.out
>
> diff --git a/tests/btrfs/313 b/tests/btrfs/313
> new file mode 100755
> index 000000000000..c495a770c212
> --- /dev/null
> +++ b/tests/btrfs/313
> @@ -0,0 +1,55 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2024 Oracle. All Rights Reserved.
> +#
> +# FS QA Test 313
> +#
> +# Functional test for the tempfsid, clone devices created using the mkfs option.
> +#
> +. ./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_cp_reflink
> +_require_btrfs_sysfs_fsid
> +_require_scratch_dev_pool 2
> +_require_btrfs_fs_feature temp_fsid
> +_require_btrfs_command inspect-internal dump-super
> +_require_btrfs_mkfs_uuid_option
So same as before, these last 2 _require_* are because of the
check_fsid() function,
defined at common/btrfs, so they should be in the function and not
spread over every test case that calls it.
Thanks.
> +
> +_scratch_dev_pool_get 2
> +
> +mnt1=$TEST_DIR/$seq/mnt1
> +mkdir -p $mnt1
> +
> +echo ---- clone_uuids_verify_tempfsid ----
> +mkfs_clone ${SCRATCH_DEV_NAME[0]} ${SCRATCH_DEV_NAME[1]}
> +
> +echo Mounting original device
> +_mount ${SCRATCH_DEV_NAME[0]} $SCRATCH_MNT
> +check_fsid ${SCRATCH_DEV_NAME[0]}
> +
> +echo Mounting cloned device
> +_mount ${SCRATCH_DEV_NAME[1]} $mnt1
> +check_fsid ${SCRATCH_DEV_NAME[1]}
> +
> +$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | _filter_xfs_io
> +echo cp reflink must fail
> +_cp_reflink $SCRATCH_MNT/foo $mnt1/bar 2>&1 | _filter_testdir_and_scratch
> +
> +_scratch_dev_pool_put
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/btrfs/313.out b/tests/btrfs/313.out
> new file mode 100644
> index 000000000000..7a089d2c29c5
> --- /dev/null
> +++ b/tests/btrfs/313.out
> @@ -0,0 +1,16 @@
> +QA output created by 313
> +---- clone_uuids_verify_tempfsid ----
> +Mounting original device
> +On disk fsid: FSID
> +Metadata uuid: FSID
> +Temp fsid: FSID
> +Tempfsid status: 0
> +Mounting cloned device
> +On disk fsid: FSID
> +Metadata uuid: FSID
> +Temp fsid: TEMPFSID
> +Tempfsid status: 1
> +wrote 9000/9000 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +cp reflink must fail
> +cp: failed to clone 'TEST_DIR/313/mnt1/bar' from 'SCRATCH_MNT/foo': Invalid cross-device link
> --
> 2.39.3
>
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [PATCH v2 08/10] btrfs: verify tempfsid clones using mkfs
2024-02-20 16:55 ` Filipe Manana
@ 2024-02-24 11:41 ` Anand Jain
0 siblings, 0 replies; 26+ messages in thread
From: Anand Jain @ 2024-02-24 11:41 UTC (permalink / raw)
To: Filipe Manana; +Cc: fstests, linux-btrfs, zlang
On 2/20/24 22:25, Filipe Manana wrote:
> On Mon, Feb 19, 2024 at 7:50 PM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> Create appearing to be a clone using the mkfs.btrfs option and test if
>> the tempfsid is active.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> v2:
>> Remove unnecessary function.
>> Add clone group
>> use $UMOUNT_PROG
>> Let _cp_reflink fail on the stdout.
>>
>> tests/btrfs/313 | 55 +++++++++++++++++++++++++++++++++++++++++++++
>> tests/btrfs/313.out | 16 +++++++++++++
>> 2 files changed, 71 insertions(+)
>> create mode 100755 tests/btrfs/313
>> create mode 100644 tests/btrfs/313.out
>>
>> diff --git a/tests/btrfs/313 b/tests/btrfs/313
>> new file mode 100755
>> index 000000000000..c495a770c212
>> --- /dev/null
>> +++ b/tests/btrfs/313
>> @@ -0,0 +1,55 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2024 Oracle. All Rights Reserved.
>> +#
>> +# FS QA Test 313
>> +#
>> +# Functional test for the tempfsid, clone devices created using the mkfs option.
>> +#
>> +. ./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_cp_reflink
>> +_require_btrfs_sysfs_fsid
>> +_require_scratch_dev_pool 2
>> +_require_btrfs_fs_feature temp_fsid
>> +_require_btrfs_command inspect-internal dump-super
>> +_require_btrfs_mkfs_uuid_option
>
> So same as before, these last 2 _require_* are because of the
> check_fsid() function,
Yes, they have already been checked in mkfs_clone(),
so they have been removed here.
Thanks.
> defined at common/btrfs, so they should be in the function and not
> spread over every test case that calls it.
>
> Thanks.
>
>> +
>> +_scratch_dev_pool_get 2
>> +
>> +mnt1=$TEST_DIR/$seq/mnt1
>> +mkdir -p $mnt1
>> +
>> +echo ---- clone_uuids_verify_tempfsid ----
>> +mkfs_clone ${SCRATCH_DEV_NAME[0]} ${SCRATCH_DEV_NAME[1]}
>> +
>> +echo Mounting original device
>> +_mount ${SCRATCH_DEV_NAME[0]} $SCRATCH_MNT
>> +check_fsid ${SCRATCH_DEV_NAME[0]}
>> +
>> +echo Mounting cloned device
>> +_mount ${SCRATCH_DEV_NAME[1]} $mnt1
>> +check_fsid ${SCRATCH_DEV_NAME[1]}
>> +
>> +$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | _filter_xfs_io
>> +echo cp reflink must fail
>> +_cp_reflink $SCRATCH_MNT/foo $mnt1/bar 2>&1 | _filter_testdir_and_scratch
>> +
>> +_scratch_dev_pool_put
>> +
>> +# success, all done
>> +status=0
>> +exit
>> diff --git a/tests/btrfs/313.out b/tests/btrfs/313.out
>> new file mode 100644
>> index 000000000000..7a089d2c29c5
>> --- /dev/null
>> +++ b/tests/btrfs/313.out
>> @@ -0,0 +1,16 @@
>> +QA output created by 313
>> +---- clone_uuids_verify_tempfsid ----
>> +Mounting original device
>> +On disk fsid: FSID
>> +Metadata uuid: FSID
>> +Temp fsid: FSID
>> +Tempfsid status: 0
>> +Mounting cloned device
>> +On disk fsid: FSID
>> +Metadata uuid: FSID
>> +Temp fsid: TEMPFSID
>> +Tempfsid status: 1
>> +wrote 9000/9000 bytes at offset 0
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +cp reflink must fail
>> +cp: failed to clone 'TEST_DIR/313/mnt1/bar' from 'SCRATCH_MNT/foo': Invalid cross-device link
>> --
>> 2.39.3
>>
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v2 09/10] btrfs: validate send-receive operation with tempfsid.
2024-02-19 19:48 [PATCH v2 00/10] btrfs: functional test cases for tempfsid Anand Jain
` (7 preceding siblings ...)
2024-02-19 19:48 ` [PATCH v2 08/10] btrfs: verify tempfsid clones using mkfs Anand Jain
@ 2024-02-19 19:48 ` Anand Jain
2024-02-20 16:57 ` Filipe Manana
2024-02-19 19:48 ` [PATCH v2 10/10] btrfs: test tempfsid with device add, seed, and balance Anand Jain
9 siblings, 1 reply; 26+ messages in thread
From: Anand Jain @ 2024-02-19 19:48 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, zlang, fdmanana
Given concurrent mounting of both the original and its clone device on
the same system, this test confirms the integrity of send and receive
operations in the presence of active tempfsid.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2:
Organize changes to its right patch.
Fix _fail erorr message.
Declare local variables for fsid and uuid.
tests/btrfs/314 | 81 +++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/314.out | 23 +++++++++++++
2 files changed, 104 insertions(+)
create mode 100755 tests/btrfs/314
create mode 100644 tests/btrfs/314.out
diff --git a/tests/btrfs/314 b/tests/btrfs/314
new file mode 100755
index 000000000000..59c6359a2ad8
--- /dev/null
+++ b/tests/btrfs/314
@@ -0,0 +1,81 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oracle. All Rights Reserved.
+#
+# FS QA Test 314
+#
+# Send and receive functionality test between a normal and
+# tempfsid filesystem.
+#
+. ./common/preamble
+_begin_fstest auto quick snapshot send tempfsid
+
+_cleanup()
+{
+ cd /
+ $UMOUNT_PROG $tempfsid_mnt 2>/dev/null
+ rm -r -f $tmp.*
+ rm -r -f $sendfile
+ rm -r -f $tempfsid_mnt
+}
+
+. ./common/filter.btrfs
+
+_supported_fs btrfs
+_require_btrfs_sysfs_fsid
+_require_scratch_dev_pool 2
+_require_btrfs_fs_feature temp_fsid
+_require_btrfs_command inspect-internal dump-super
+_require_btrfs_mkfs_uuid_option
+
+_scratch_dev_pool_get 2
+
+# mount point for the tempfsid device
+tempfsid_mnt=$TEST_DIR/$seq/tempfsid_mnt
+sendfile=$TEST_DIR/$seq/replicate.send
+
+send_receive_tempfsid()
+{
+ local src=$1
+ local dst=$2
+
+ # Use first 2 devices from the SCRATCH_DEV_POOL
+ mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]}
+ _scratch_mount
+ _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
+
+ $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io
+ $BTRFS_UTIL_PROG subvolume snapshot -r ${src} ${src}/snap1 | \
+ _filter_testdir_and_scratch
+
+ echo Send ${src} | _filter_testdir_and_scratch
+ $BTRFS_UTIL_PROG send -f ${sendfile} ${src}/snap1 2>&1 | \
+ _filter_testdir_and_scratch
+ echo Receive ${dst} | _filter_testdir_and_scratch
+ $BTRFS_UTIL_PROG receive -f ${sendfile} ${dst} | \
+ _filter_testdir_and_scratch
+ echo -e -n "Send:\t"
+ md5sum ${src}/foo | _filter_testdir_and_scratch
+ echo -e -n "Recv:\t"
+ md5sum ${dst}/snap1/foo | _filter_testdir_and_scratch
+}
+
+mkdir -p $tempfsid_mnt
+
+echo -e \\nFrom non-tempfsid ${SCRATCH_MNT} to tempfsid ${tempfsid_mnt} | \
+ _filter_testdir_and_scratch
+send_receive_tempfsid $SCRATCH_MNT $tempfsid_mnt
+
+_scratch_unmount
+_cleanup
+mkdir -p $tempfsid_mnt
+
+echo -e \\nFrom tempfsid ${tempfsid_mnt} to non-tempfsid ${SCRATCH_MNT} | \
+ _filter_testdir_and_scratch
+send_receive_tempfsid $tempfsid_mnt $SCRATCH_MNT
+
+_scratch_dev_pool_put
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/314.out b/tests/btrfs/314.out
new file mode 100644
index 000000000000..21963899c2b2
--- /dev/null
+++ b/tests/btrfs/314.out
@@ -0,0 +1,23 @@
+QA output created by 314
+
+From non-tempfsid SCRATCH_MNT to tempfsid TEST_DIR/314/tempfsid_mnt
+wrote 9000/9000 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Create a readonly snapshot of 'SCRATCH_MNT' in 'SCRATCH_MNT/snap1'
+Send SCRATCH_MNT
+At subvol SCRATCH_MNT/snap1
+Receive TEST_DIR/314/tempfsid_mnt
+At subvol snap1
+Send: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/foo
+Recv: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/snap1/foo
+
+From tempfsid TEST_DIR/314/tempfsid_mnt to non-tempfsid SCRATCH_MNT
+wrote 9000/9000 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Create a readonly snapshot of 'TEST_DIR/314/tempfsid_mnt' in 'TEST_DIR/314/tempfsid_mnt/snap1'
+Send TEST_DIR/314/tempfsid_mnt
+At subvol TEST_DIR/314/tempfsid_mnt/snap1
+Receive SCRATCH_MNT
+At subvol snap1
+Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo
+Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo
--
2.39.3
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v2 09/10] btrfs: validate send-receive operation with tempfsid.
2024-02-19 19:48 ` [PATCH v2 09/10] btrfs: validate send-receive operation with tempfsid Anand Jain
@ 2024-02-20 16:57 ` Filipe Manana
2024-02-24 0:53 ` Anand Jain
0 siblings, 1 reply; 26+ messages in thread
From: Filipe Manana @ 2024-02-20 16:57 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs, zlang
On Mon, Feb 19, 2024 at 7:50 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> Given concurrent mounting of both the original and its clone device on
> the same system, this test confirms the integrity of send and receive
> operations in the presence of active tempfsid.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v2:
> Organize changes to its right patch.
> Fix _fail erorr message.
> Declare local variables for fsid and uuid.
>
> tests/btrfs/314 | 81 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/314.out | 23 +++++++++++++
> 2 files changed, 104 insertions(+)
> create mode 100755 tests/btrfs/314
> create mode 100644 tests/btrfs/314.out
>
> diff --git a/tests/btrfs/314 b/tests/btrfs/314
> new file mode 100755
> index 000000000000..59c6359a2ad8
> --- /dev/null
> +++ b/tests/btrfs/314
> @@ -0,0 +1,81 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2024 Oracle. All Rights Reserved.
> +#
> +# FS QA Test 314
> +#
> +# Send and receive functionality test between a normal and
> +# tempfsid filesystem.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick snapshot send tempfsid
> +
> +_cleanup()
> +{
> + cd /
> + $UMOUNT_PROG $tempfsid_mnt 2>/dev/null
> + rm -r -f $tmp.*
> + rm -r -f $sendfile
> + rm -r -f $tempfsid_mnt
> +}
> +
> +. ./common/filter.btrfs
> +
> +_supported_fs btrfs
> +_require_btrfs_sysfs_fsid
> +_require_scratch_dev_pool 2
> +_require_btrfs_fs_feature temp_fsid
> +_require_btrfs_command inspect-internal dump-super
> +_require_btrfs_mkfs_uuid_option
So same as before, these last 2 _require_* are because of the
mkfs_clone() function,
defined at common/btrfs, so they should be in the function and not
spread over every test case that calls it.
Thanks.
> +
> +_scratch_dev_pool_get 2
> +
> +# mount point for the tempfsid device
> +tempfsid_mnt=$TEST_DIR/$seq/tempfsid_mnt
> +sendfile=$TEST_DIR/$seq/replicate.send
> +
> +send_receive_tempfsid()
> +{
> + local src=$1
> + local dst=$2
> +
> + # Use first 2 devices from the SCRATCH_DEV_POOL
> + mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]}
> + _scratch_mount
> + _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
> +
> + $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io
> + $BTRFS_UTIL_PROG subvolume snapshot -r ${src} ${src}/snap1 | \
> + _filter_testdir_and_scratch
> +
> + echo Send ${src} | _filter_testdir_and_scratch
> + $BTRFS_UTIL_PROG send -f ${sendfile} ${src}/snap1 2>&1 | \
> + _filter_testdir_and_scratch
> + echo Receive ${dst} | _filter_testdir_and_scratch
> + $BTRFS_UTIL_PROG receive -f ${sendfile} ${dst} | \
> + _filter_testdir_and_scratch
> + echo -e -n "Send:\t"
> + md5sum ${src}/foo | _filter_testdir_and_scratch
> + echo -e -n "Recv:\t"
> + md5sum ${dst}/snap1/foo | _filter_testdir_and_scratch
> +}
> +
> +mkdir -p $tempfsid_mnt
> +
> +echo -e \\nFrom non-tempfsid ${SCRATCH_MNT} to tempfsid ${tempfsid_mnt} | \
> + _filter_testdir_and_scratch
> +send_receive_tempfsid $SCRATCH_MNT $tempfsid_mnt
> +
> +_scratch_unmount
> +_cleanup
> +mkdir -p $tempfsid_mnt
> +
> +echo -e \\nFrom tempfsid ${tempfsid_mnt} to non-tempfsid ${SCRATCH_MNT} | \
> + _filter_testdir_and_scratch
> +send_receive_tempfsid $tempfsid_mnt $SCRATCH_MNT
> +
> +_scratch_dev_pool_put
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/btrfs/314.out b/tests/btrfs/314.out
> new file mode 100644
> index 000000000000..21963899c2b2
> --- /dev/null
> +++ b/tests/btrfs/314.out
> @@ -0,0 +1,23 @@
> +QA output created by 314
> +
> +From non-tempfsid SCRATCH_MNT to tempfsid TEST_DIR/314/tempfsid_mnt
> +wrote 9000/9000 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +Create a readonly snapshot of 'SCRATCH_MNT' in 'SCRATCH_MNT/snap1'
> +Send SCRATCH_MNT
> +At subvol SCRATCH_MNT/snap1
> +Receive TEST_DIR/314/tempfsid_mnt
> +At subvol snap1
> +Send: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/foo
> +Recv: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/snap1/foo
> +
> +From tempfsid TEST_DIR/314/tempfsid_mnt to non-tempfsid SCRATCH_MNT
> +wrote 9000/9000 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +Create a readonly snapshot of 'TEST_DIR/314/tempfsid_mnt' in 'TEST_DIR/314/tempfsid_mnt/snap1'
> +Send TEST_DIR/314/tempfsid_mnt
> +At subvol TEST_DIR/314/tempfsid_mnt/snap1
> +Receive SCRATCH_MNT
> +At subvol snap1
> +Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo
> +Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo
> --
> 2.39.3
>
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [PATCH v2 09/10] btrfs: validate send-receive operation with tempfsid.
2024-02-20 16:57 ` Filipe Manana
@ 2024-02-24 0:53 ` Anand Jain
0 siblings, 0 replies; 26+ messages in thread
From: Anand Jain @ 2024-02-24 0:53 UTC (permalink / raw)
To: Filipe Manana; +Cc: fstests, linux-btrfs, zlang
On 2/20/24 22:27, Filipe Manana wrote:
> On Mon, Feb 19, 2024 at 7:50 PM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> Given concurrent mounting of both the original and its clone device on
>> the same system, this test confirms the integrity of send and receive
>> operations in the presence of active tempfsid.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> v2:
>> Organize changes to its right patch.
>> Fix _fail erorr message.
>> Declare local variables for fsid and uuid.
>>
>> tests/btrfs/314 | 81 +++++++++++++++++++++++++++++++++++++++++++++
>> tests/btrfs/314.out | 23 +++++++++++++
>> 2 files changed, 104 insertions(+)
>> create mode 100755 tests/btrfs/314
>> create mode 100644 tests/btrfs/314.out
>>
>> diff --git a/tests/btrfs/314 b/tests/btrfs/314
>> new file mode 100755
>> index 000000000000..59c6359a2ad8
>> --- /dev/null
>> +++ b/tests/btrfs/314
>> @@ -0,0 +1,81 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2024 Oracle. All Rights Reserved.
>> +#
>> +# FS QA Test 314
>> +#
>> +# Send and receive functionality test between a normal and
>> +# tempfsid filesystem.
>> +#
>> +. ./common/preamble
>> +_begin_fstest auto quick snapshot send tempfsid
>> +
>> +_cleanup()
>> +{
>> + cd /
>> + $UMOUNT_PROG $tempfsid_mnt 2>/dev/null
>> + rm -r -f $tmp.*
>> + rm -r -f $sendfile
>> + rm -r -f $tempfsid_mnt
>> +}
>> +
>> +. ./common/filter.btrfs
>> +
>> +_supported_fs btrfs
>> +_require_btrfs_sysfs_fsid
>> +_require_scratch_dev_pool 2
>> +_require_btrfs_fs_feature temp_fsid
>> +_require_btrfs_command inspect-internal dump-super
>> +_require_btrfs_mkfs_uuid_option
>
> So same as before, these last 2 _require_* are because of the
> mkfs_clone() function,
> defined at common/btrfs, so they should be in the function and not
> spread over every test case that calls it.
>
Yep. Fixed it.
Thanks, Anand
> Thanks.
>
>> +
>> +_scratch_dev_pool_get 2
>> +
>> +# mount point for the tempfsid device
>> +tempfsid_mnt=$TEST_DIR/$seq/tempfsid_mnt
>> +sendfile=$TEST_DIR/$seq/replicate.send
>> +
>> +send_receive_tempfsid()
>> +{
>> + local src=$1
>> + local dst=$2
>> +
>> + # Use first 2 devices from the SCRATCH_DEV_POOL
>> + mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]}
>> + _scratch_mount
>> + _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
>> +
>> + $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' ${src}/foo | _filter_xfs_io
>> + $BTRFS_UTIL_PROG subvolume snapshot -r ${src} ${src}/snap1 | \
>> + _filter_testdir_and_scratch
>> +
>> + echo Send ${src} | _filter_testdir_and_scratch
>> + $BTRFS_UTIL_PROG send -f ${sendfile} ${src}/snap1 2>&1 | \
>> + _filter_testdir_and_scratch
>> + echo Receive ${dst} | _filter_testdir_and_scratch
>> + $BTRFS_UTIL_PROG receive -f ${sendfile} ${dst} | \
>> + _filter_testdir_and_scratch
>> + echo -e -n "Send:\t"
>> + md5sum ${src}/foo | _filter_testdir_and_scratch
>> + echo -e -n "Recv:\t"
>> + md5sum ${dst}/snap1/foo | _filter_testdir_and_scratch
>> +}
>> +
>> +mkdir -p $tempfsid_mnt
>> +
>> +echo -e \\nFrom non-tempfsid ${SCRATCH_MNT} to tempfsid ${tempfsid_mnt} | \
>> + _filter_testdir_and_scratch
>> +send_receive_tempfsid $SCRATCH_MNT $tempfsid_mnt
>> +
>> +_scratch_unmount
>> +_cleanup
>> +mkdir -p $tempfsid_mnt
>> +
>> +echo -e \\nFrom tempfsid ${tempfsid_mnt} to non-tempfsid ${SCRATCH_MNT} | \
>> + _filter_testdir_and_scratch
>> +send_receive_tempfsid $tempfsid_mnt $SCRATCH_MNT
>> +
>> +_scratch_dev_pool_put
>> +
>> +# success, all done
>> +status=0
>> +exit
>> diff --git a/tests/btrfs/314.out b/tests/btrfs/314.out
>> new file mode 100644
>> index 000000000000..21963899c2b2
>> --- /dev/null
>> +++ b/tests/btrfs/314.out
>> @@ -0,0 +1,23 @@
>> +QA output created by 314
>> +
>> +From non-tempfsid SCRATCH_MNT to tempfsid TEST_DIR/314/tempfsid_mnt
>> +wrote 9000/9000 bytes at offset 0
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +Create a readonly snapshot of 'SCRATCH_MNT' in 'SCRATCH_MNT/snap1'
>> +Send SCRATCH_MNT
>> +At subvol SCRATCH_MNT/snap1
>> +Receive TEST_DIR/314/tempfsid_mnt
>> +At subvol snap1
>> +Send: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/foo
>> +Recv: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/snap1/foo
>> +
>> +From tempfsid TEST_DIR/314/tempfsid_mnt to non-tempfsid SCRATCH_MNT
>> +wrote 9000/9000 bytes at offset 0
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +Create a readonly snapshot of 'TEST_DIR/314/tempfsid_mnt' in 'TEST_DIR/314/tempfsid_mnt/snap1'
>> +Send TEST_DIR/314/tempfsid_mnt
>> +At subvol TEST_DIR/314/tempfsid_mnt/snap1
>> +Receive SCRATCH_MNT
>> +At subvol snap1
>> +Send: 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/314/tempfsid_mnt/foo
>> +Recv: 42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/snap1/foo
>> --
>> 2.39.3
>>
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v2 10/10] btrfs: test tempfsid with device add, seed, and balance
2024-02-19 19:48 [PATCH v2 00/10] btrfs: functional test cases for tempfsid Anand Jain
` (8 preceding siblings ...)
2024-02-19 19:48 ` [PATCH v2 09/10] btrfs: validate send-receive operation with tempfsid Anand Jain
@ 2024-02-19 19:48 ` Anand Jain
2024-02-20 17:05 ` Filipe Manana
9 siblings, 1 reply; 26+ messages in thread
From: Anand Jain @ 2024-02-19 19:48 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, zlang, fdmanana
Make sure that basic functions such as seeding and device add fail,
while balance runs successfully with tempfsid.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2:
Remove unnecessary function.
Add clone group
use $UMOUNT_PROG
Let _cp_reflink fail on the stdout.
tests/btrfs/315 | 79 +++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/315.out | 9 ++++++
2 files changed, 88 insertions(+)
create mode 100755 tests/btrfs/315
create mode 100644 tests/btrfs/315.out
diff --git a/tests/btrfs/315 b/tests/btrfs/315
new file mode 100755
index 000000000000..4376c7f1849c
--- /dev/null
+++ b/tests/btrfs/315
@@ -0,0 +1,79 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 YOUR NAME HERE. All Rights Reserved.
+#
+# FS QA Test 315
+#
+# Verify if the seed and device add to a tempfsid filesystem fails.
+#
+. ./common/preamble
+_begin_fstest auto quick volume seed tempfsid
+
+_cleanup()
+{
+ cd /
+ $UMOUNT_PROG $tempfsid_mnt 2>/dev/null
+ rm -r -f $tmp.*
+ rm -r -f $tempfsid_mnt
+}
+
+. ./common/filter.btrfs
+
+_supported_fs btrfs
+_require_btrfs_sysfs_fsid
+_require_scratch_dev_pool 3
+_require_btrfs_fs_feature temp_fsid
+_require_btrfs_command inspect-internal dump-super
+_require_btrfs_mkfs_uuid_option
+
+_scratch_dev_pool_get 3
+
+# mount point for the tempfsid device
+tempfsid_mnt=$TEST_DIR/$seq/tempfsid_mnt
+
+seed_device_must_fail()
+{
+ echo ---- $FUNCNAME ----
+
+ mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]}
+
+ $BTRFS_TUNE_PROG -S 1 ${SCRATCH_DEV}
+ $BTRFS_TUNE_PROG -S 1 ${SCRATCH_DEV_NAME[1]}
+
+ _scratch_mount 2>&1 | _filter_scratch
+ _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} 2>&1 | _filter_test_dir
+}
+
+device_add_must_fail()
+{
+ echo ---- $FUNCNAME ----
+
+ mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]}
+ _scratch_mount
+ _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
+
+ $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | \
+ _filter_xfs_io
+
+$BTRFS_UTIL_PROG device add -f ${SCRATCH_DEV_NAME[2]} ${tempfsid_mnt} >> \
+ $seqres.full 2>&1 && _fail "Failed to file device add"
+
+ echo Balance must be successful
+ _run_btrfs_balance_start ${tempfsid_mnt}
+}
+
+mkdir -p $tempfsid_mnt
+
+seed_device_must_fail
+
+_scratch_unmount
+_cleanup
+mkdir -p $tempfsid_mnt
+
+device_add_must_fail
+
+_scratch_dev_pool_put
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/315.out b/tests/btrfs/315.out
new file mode 100644
index 000000000000..e882fe41146d
--- /dev/null
+++ b/tests/btrfs/315.out
@@ -0,0 +1,9 @@
+QA output created by 315
+---- seed_device_must_fail ----
+mount: SCRATCH_MNT: WARNING: source write-protected, mounted read-only.
+mount: TEST_DIR/315/tempfsid_mnt: mount(2) system call failed: File exists.
+---- device_add_must_fail ----
+wrote 9000/9000 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Balance must be successful
+Done, had to relocate 3 out of 3 chunks
--
2.39.3
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v2 10/10] btrfs: test tempfsid with device add, seed, and balance
2024-02-19 19:48 ` [PATCH v2 10/10] btrfs: test tempfsid with device add, seed, and balance Anand Jain
@ 2024-02-20 17:05 ` Filipe Manana
2024-02-24 11:29 ` Anand Jain
0 siblings, 1 reply; 26+ messages in thread
From: Filipe Manana @ 2024-02-20 17:05 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs, zlang
On Mon, Feb 19, 2024 at 7:50 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> Make sure that basic functions such as seeding and device add fail,
> while balance runs successfully with tempfsid.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v2:
> Remove unnecessary function.
> Add clone group
> use $UMOUNT_PROG
> Let _cp_reflink fail on the stdout.
>
> tests/btrfs/315 | 79 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/315.out | 9 ++++++
> 2 files changed, 88 insertions(+)
> create mode 100755 tests/btrfs/315
> create mode 100644 tests/btrfs/315.out
>
> diff --git a/tests/btrfs/315 b/tests/btrfs/315
> new file mode 100755
> index 000000000000..4376c7f1849c
> --- /dev/null
> +++ b/tests/btrfs/315
> @@ -0,0 +1,79 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2024 YOUR NAME HERE. All Rights Reserved.
Your name here...
> +#
> +# FS QA Test 315
> +#
> +# Verify if the seed and device add to a tempfsid filesystem fails.
And balance too...
> +#
> +. ./common/preamble
> +_begin_fstest auto quick volume seed tempfsid
Missing 'balance' group.
> +
> +_cleanup()
> +{
> + cd /
> + $UMOUNT_PROG $tempfsid_mnt 2>/dev/null
> + rm -r -f $tmp.*
> + rm -r -f $tempfsid_mnt
> +}
> +
> +. ./common/filter.btrfs
> +
> +_supported_fs btrfs
> +_require_btrfs_sysfs_fsid
> +_require_scratch_dev_pool 3
> +_require_btrfs_fs_feature temp_fsid
> +_require_btrfs_command inspect-internal dump-super
> +_require_btrfs_mkfs_uuid_option
So same as before, these last 2 _require_* are because of the
mkfs_clone() function,
defined at common/btrfs, so they should be in the function and not
spread over every test case that calls it.
> +
> +_scratch_dev_pool_get 3
> +
> +# mount point for the tempfsid device
> +tempfsid_mnt=$TEST_DIR/$seq/tempfsid_mnt
> +
> +seed_device_must_fail()
> +{
> + echo ---- $FUNCNAME ----
> +
> + mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]}
> +
> + $BTRFS_TUNE_PROG -S 1 ${SCRATCH_DEV}
> + $BTRFS_TUNE_PROG -S 1 ${SCRATCH_DEV_NAME[1]}
> +
> + _scratch_mount 2>&1 | _filter_scratch
> + _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} 2>&1 | _filter_test_dir
> +}
> +
> +device_add_must_fail()
> +{
> + echo ---- $FUNCNAME ----
> +
> + mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]}
> + _scratch_mount
> + _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
> +
> + $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | \
> + _filter_xfs_io
> +
> +$BTRFS_UTIL_PROG device add -f ${SCRATCH_DEV_NAME[2]} ${tempfsid_mnt} >> \
> + $seqres.full 2>&1 && _fail "Failed to file device add"
Can't we do without the && _fail?
Just call device add and put the expected error message in the golden output.
It's the preferred pattern in fstests in general, and makes everything
shorter and easier to read.
Thanks.
> +
> + echo Balance must be successful
> + _run_btrfs_balance_start ${tempfsid_mnt}
> +}
> +
> +mkdir -p $tempfsid_mnt
> +
> +seed_device_must_fail
> +
> +_scratch_unmount
> +_cleanup
> +mkdir -p $tempfsid_mnt
> +
> +device_add_must_fail
> +
> +_scratch_dev_pool_put
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/btrfs/315.out b/tests/btrfs/315.out
> new file mode 100644
> index 000000000000..e882fe41146d
> --- /dev/null
> +++ b/tests/btrfs/315.out
> @@ -0,0 +1,9 @@
> +QA output created by 315
> +---- seed_device_must_fail ----
> +mount: SCRATCH_MNT: WARNING: source write-protected, mounted read-only.
> +mount: TEST_DIR/315/tempfsid_mnt: mount(2) system call failed: File exists.
> +---- device_add_must_fail ----
> +wrote 9000/9000 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +Balance must be successful
> +Done, had to relocate 3 out of 3 chunks
> --
> 2.39.3
>
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [PATCH v2 10/10] btrfs: test tempfsid with device add, seed, and balance
2024-02-20 17:05 ` Filipe Manana
@ 2024-02-24 11:29 ` Anand Jain
0 siblings, 0 replies; 26+ messages in thread
From: Anand Jain @ 2024-02-24 11:29 UTC (permalink / raw)
To: Filipe Manana; +Cc: fstests, linux-btrfs, zlang
On 2/20/24 22:35, Filipe Manana wrote:
> On Mon, Feb 19, 2024 at 7:50 PM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> Make sure that basic functions such as seeding and device add fail,
>> while balance runs successfully with tempfsid.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> v2:
>> Remove unnecessary function.
>> Add clone group
>> use $UMOUNT_PROG
>> Let _cp_reflink fail on the stdout.
>>
>> tests/btrfs/315 | 79 +++++++++++++++++++++++++++++++++++++++++++++
>> tests/btrfs/315.out | 9 ++++++
>> 2 files changed, 88 insertions(+)
>> create mode 100755 tests/btrfs/315
>> create mode 100644 tests/btrfs/315.out
>>
>> diff --git a/tests/btrfs/315 b/tests/btrfs/315
>> new file mode 100755
>> index 000000000000..4376c7f1849c
>> --- /dev/null
>> +++ b/tests/btrfs/315
>> @@ -0,0 +1,79 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2024 YOUR NAME HERE. All Rights Reserved.
>
> Your name here...
>
>> +#
>> +# FS QA Test 315
>> +#
>> +# Verify if the seed and device add to a tempfsid filesystem fails.
>
> And balance too...
>
>> +#
>> +. ./common/preamble
>> +_begin_fstest auto quick volume seed tempfsid
>
> Missing 'balance' group.
>
Now added.
>> +
>> +_cleanup()
>> +{
>> + cd /
>> + $UMOUNT_PROG $tempfsid_mnt 2>/dev/null
>> + rm -r -f $tmp.*
>> + rm -r -f $tempfsid_mnt
>> +}
>> +
>> +. ./common/filter.btrfs
>> +
>> +_supported_fs btrfs
>> +_require_btrfs_sysfs_fsid
>> +_require_scratch_dev_pool 3
>> +_require_btrfs_fs_feature temp_fsid
>> +_require_btrfs_command inspect-internal dump-super
>> +_require_btrfs_mkfs_uuid_option
>
> So same as before, these last 2 _require_* are because of the
> mkfs_clone() function,
> defined at common/btrfs, so they should be in the function and not
> spread over every test case that calls it.
The last two _require have now been removed because mkfs_clone()
includes those checks.
>> +
>> +_scratch_dev_pool_get 3
>> +
>> +# mount point for the tempfsid device
>> +tempfsid_mnt=$TEST_DIR/$seq/tempfsid_mnt
>> +
>> +seed_device_must_fail()
>> +{
>> + echo ---- $FUNCNAME ----
>> +
>> + mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]}
>> +
>> + $BTRFS_TUNE_PROG -S 1 ${SCRATCH_DEV}
>> + $BTRFS_TUNE_PROG -S 1 ${SCRATCH_DEV_NAME[1]}
>> +
>> + _scratch_mount 2>&1 | _filter_scratch
>> + _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt} 2>&1 | _filter_test_dir
>> +}
>> +
>> +device_add_must_fail()
>> +{
>> + echo ---- $FUNCNAME ----
>> +
>> + mkfs_clone ${SCRATCH_DEV} ${SCRATCH_DEV_NAME[1]}
>> + _scratch_mount
>> + _mount ${SCRATCH_DEV_NAME[1]} ${tempfsid_mnt}
>> +
>> + $XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo | \
>> + _filter_xfs_io
>> +
>> +$BTRFS_UTIL_PROG device add -f ${SCRATCH_DEV_NAME[2]} ${tempfsid_mnt} >> \
>> + $seqres.full 2>&1 && _fail "Failed to file device add"
>
> Can't we do without the && _fail?
> Just call device add and put the expected error message in the golden output.
> It's the preferred pattern in fstests in general, and makes everything
> shorter and easier to read.
Upon rethinking, it can be done as outlined below, also updated
the golden output accordingly.
$BTRFS_UTIL_PROG device add -f ${SCRATCH_DEV_NAME[2]} ${tempfsid_mnt}
2>&1 | \
grep -v "Performing full device TRIM" |
_filter_scratch_pool
Thanks.
^ permalink raw reply [flat|nested] 26+ messages in thread