common/rc: _fs_sysfs_dname fetch fsid using btrfs tool
Quoted 18 lines · Anand Jain
Currently
_fs_sysfs_dnamegets fsid from the findmnt command however this command provides themetadata_uuidin the context device is mounted with temp-fsid. So instead, use btrfs filesystem show command to know the temp-fsid.Signed-off-by Anand Jain <[email protected]>---
v2: new.common/rc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)common/rc +0
-0
common/rc _fs_sysfs_dname() · line 4732
Quoted 6 lines
common/rc +2
-1@@ -4728,7 +4728,9 @@ _fs_sysfs_dname() case "$FSTYP" in btrfs) - findmnt -n -o UUID ${dev} ;; + fsid=$($BTRFS_UTIL_PROG filesystem show ${dev} | grep uuid: | \ + awk '{print $NF}')
Please make the variable local.
Thanks.
Quoted 7 lines
common/rc +1
-1+ echo $fsid ;; *) _short_dev $dev ;; esac --2.39.3
Re: [PATCH 2/2 v2] fstests: btrfs/219 cloned-device mount capability update
In reply to a message not in the archiveQuoted 38 lines · Anand Jain
This test case originally checked for failed cloned device mounts, which is no longer relevant after the commit
a5b8a5f9f835("btrfs: support cloned-device mount capability"). So removing the obsolete part.Additionally, add this test case back to the auto group which reverts the commit
e2e7b549380a("fstests: btrfs/219: remove it from auto group") since the previously missing kernel commit5f58d783fd78("btrfs: free device inbtrfs_close_devicesfor a single device filesystem") has already been integrated.Add cleanups of the local variables and the
_cleanup()function.Reported-by kernel test robot <[email protected]>Signed-off-by Anand Jain <[email protected]>---
v2: Restores the code where it tests clone-devices.tests/btrfs/219 | 79 ++++++++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 30 deletions(-)tests/btrfs/219 +1
-1@@ -12,21 +12,27 @@ # . ./common/preamble -_begin_fstest quick volume +_begin_fstest auto quick volume # Override the default cleanup function. _cleanup() { cd / rm -f $tmp.*
tests/btrfs/219 line 23
Quoted 10 lines
tests/btrfs/219 +2
-8- if [ ! -z "$loop_mnt" ]; then - $UMOUNT_PROG $loop_mnt - rm -rf $loop_mnt - fi - [ ! -z "$loop_mnt1" ] && rm -rf $loop_mnt1 - [ ! -z "$fs_img1" ] && rm -rf $fs_img1 - [ ! -z "$fs_img2" ] && rm -rf $fs_img2 - [ ! -z "$loop_dev" ] && _destroy_loop_device $loop_dev + + # The variables are set before the test case can fail.
What if the _require_* statements fail?
Then the variables won't be defined...
tests/btrfs/219 line 34
Quoted 11 lines
tests/btrfs/219 +11
-0+ $UMOUNT_PROG ${loop_mnt1} &> /dev/null + $UMOUNT_PROG ${loop_mnt2} &> /dev/null + + _destroy_loop_device $loop_dev1 &> /dev/null + _destroy_loop_device $loop_dev2 &> /dev/null + + rm -rf $fs_img1 &> /dev/null + rm -rf $fs_img2 &> /dev/null + + rm -rf $loop_mnt1 &> /dev/null + rm -rf $loop_mnt2 &> /dev/null
Also please for simplicity and clarity don't mix this type of change with the actual purpose of the patch,
to make the test succeed on a kernel with the temp-fsid feature.
You're mixing 3 different changes in the same patch...
Quoted 11 lines
tests/btrfs/219 +2
-0+ _btrfs_rescan_devices }@@ -38,55 +44,68 @@ _cleanup() _supported_fs btrfs _require_test _require_loop +_require_btrfs_fs_sysfs _require_btrfs_forget_or_module_loadable _fixed_by_kernel_commit 5f58d783fd78 \
tests/btrfs/219 _cleanup() · line 55
Quoted 10 lines
tests/btrfs/219 +4
-4"btrfs: free device in btrfs_close_devices for a single device filesystem" -loop_mnt=$TEST_DIR/$seq.mnt -loop_mnt1=$TEST_DIR/$seq.mnt1 -fs_img1=$TEST_DIR/$seq.img1 -fs_img2=$TEST_DIR/$seq.img2 +loop_mnt1=$TEST_DIR/$seq/mnt1 +loop_mnt2=$TEST_DIR/$seq/mnt2 +fs_img1=$TEST_DIR/$seq/img1 +fs_img2=$TEST_DIR/$seq/img2
So this is the other unrelated change, renaming all these variables... This is making the diff larger to follow as this has nothing to do with the goal of making the test succeed on a kernel with the temp-fsid feature.
Quoted 56 lines
tests/btrfs/219 +16
-16-mkdir $loop_mnt -mkdir $loop_mnt1 +mkdir -p $loop_mnt1 +mkdir -p $loop_mnt2 $XFS_IO_PROG -f -c "truncate 256m" $fs_img1 >>$seqres.full 2>&1 _mkfs_dev $fs_img1 >>$seqres.full 2>&1 cp $fs_img1 $fs_img2 +loop_dev1=`_create_loop_device $fs_img1` +loop_dev2=`_create_loop_device $fs_img2` + # Normal single device case, should pass just fine -_mount -o loop $fs_img1 $loop_mnt > /dev/null 2>&1 || \ +_mount $loop_dev1 $loop_mnt1 > /dev/null 2>&1 || \ _fail "Couldn't do initial mount" -$UMOUNT_PROG $loop_mnt +$UMOUNT_PROG $loop_mnt1 _btrfs_forget_or_module_reload # Now mount the new version again to get the higher generation cached, umount # and try to mount the old version. Mount the new version again just for good # measure. -loop_dev=`_create_loop_device $fs_img1` - -_mount $loop_dev $loop_mnt > /dev/null 2>&1 || \ +_mount $loop_dev1 $loop_mnt1 > /dev/null 2>&1 || \ _fail "Failed to mount the second time" -$UMOUNT_PROG $loop_mnt +$UMOUNT_PROG $loop_mnt1 -_mount -o loop $fs_img2 $loop_mnt > /dev/null 2>&1 || \ +_mount $loop_dev2 $loop_mnt2 > /dev/null 2>&1 || \ _fail "We couldn't mount the old generation" -$UMOUNT_PROG $loop_mnt +$UMOUNT_PROG $loop_mnt2 -_mount $loop_dev $loop_mnt > /dev/null 2>&1 || \ +_mount $loop_dev1 $loop_mnt1 > /dev/null 2>&1 || \ _fail "Failed to mount the second time" -$UMOUNT_PROG $loop_mnt +$UMOUNT_PROG $loop_mnt1 -# Now we definitely can't mount them at the same time, because we're still tied -# to the limitation of one fs_devices per fsid. +# Now try mount them at the same time, if kernel does not support +# temp-fsid feature then mount should fail. _btrfs_forget_or_module_reload -_mount $loop_dev $loop_mnt > /dev/null 2>&1 || \ +_mount $loop_dev1 $loop_mnt1 > /dev/null 2>&1 || \ _fail "Failed to mount the third time" -_mount -o loop $fs_img2 $loop_mnt1 > /dev/null 2>&1 && \
tests/btrfs/219 _cleanup() · line 103
Quoted 10 lines
tests/btrfs/219 +9
-1- _fail "We were allowed to mount when we should have failed" +_mount $loop_dev2 $loop_mnt2 > /dev/null 2>&1 + +if [ $? == 0 ]; then + # On temp-fsid supported kernels, mounting cloned device will be successfull. + if _has_fs_sysfs_attr $loop_dev2 temp_fsid; then + temp_fsid=$(_get_fs_sysfs_attr ${loop_dev2} temp_fsid) + if [ $temp_fsid == 0 ]; then + _fail "Cloned devices mounted without temp_fsid" + fi
This is too complex. Why not just surround the existing code in an if statement like this:
if "sysfs-file-for-temp-fsid does not exist" then
run this code that fails with a temp-fsid enabled kernel
fi
Thanks.
Quoted 10 lines
tests/btrfs/219 +4
-1+ else + _fail "We were allowed to mount when we should have failed" + fi +fi _btrfs_rescan_devices # success, all done --2.39.3
Re: [PATCH 2/2 v2] fstests: btrfs/219 cloned-device mount capability update
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +2
-0+ + # The variables are set before the test case can fail.What if the _require_* statements fail?
Then the variables won't be defined...
Oh, yes indeed. It was fixed in v3 by moving the variable definition before the 'require' statement.
Quoted 18 lines
Review
Quoted 11 lines
(quoted diff) +11
-0+ $UMOUNT_PROG ${loop_mnt1} &> /dev/null + $UMOUNT_PROG ${loop_mnt2} &> /dev/null + + _destroy_loop_device $loop_dev1 &> /dev/null + _destroy_loop_device $loop_dev2 &> /dev/null + + rm -rf $fs_img1 &> /dev/null + rm -rf $fs_img2 &> /dev/null + + rm -rf $loop_mnt1 &> /dev/null + rm -rf $loop_mnt2 &> /dev/nullAlso please for simplicity and clarity don't mix this type of change with the actual purpose of the patch,
to make the test succeed on a kernel with the temp-fsid feature.You're mixing 3 different changes in the same patch...
Quoted 13 lines
Review
Quoted 8 lines
(quoted diff) +4
-4-loop_mnt=$TEST_DIR/$seq.mnt -loop_mnt1=$TEST_DIR/$seq.mnt1 -fs_img1=$TEST_DIR/$seq.img1 -fs_img2=$TEST_DIR/$seq.img2 +loop_mnt1=$TEST_DIR/$seq/mnt1 +loop_mnt2=$TEST_DIR/$seq/mnt2 +fs_img1=$TEST_DIR/$seq/img1 +fs_img2=$TEST_DIR/$seq/img2So this is the other unrelated change, renaming all these variables... This is making the diff larger to follow as this has nothing to do with the goal of making the test succeed on a kernel with the temp-fsid feature.
Sure. I'll move these changes to a new patch in v3.
Quoted 10 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+_mount $loop_dev2 $loop_mnt2 > /dev/null 2>&1 + +if [ $? == 0 ]; then + # On temp-fsid supported kernels, mounting cloned device will be successfull. + if _has_fs_sysfs_attr $loop_dev2 temp_fsid; then + temp_fsid=$(_get_fs_sysfs_attr ${loop_dev2} temp_fsid) + if [ $temp_fsid == 0 ]; then + _fail "Cloned devices mounted without temp_fsid" + fi
Hmm. It is exactly testing what happens with and without the temp-fsid feature.
Quoted 7 lines
This is too complex. Why not just surround the existing code in an if statement like this:
if "sysfs-file-for-temp-fsid does not exist" then
run this code that fails with a temp-fsid enabled kernel
fi
Your suggestion will test what to expect when there is no 'temp-fsid.'
However, if 'temp-fsid' is present, we expect its sysfs temp_fsid to be set to 1, which I believe is a straightforward verification.
And do you think adding more comments will make it simpler? Such as:
# If the second mount is successful, then check if 'temp-fsid'
# is in the kernel. If it's present, verify that it outputs 1.
Or, Are you suggesting we postpone confirming the correct operation of 'temp-fsid' for another test case? However, I believe in thoroughly verifying it wherever it's used, as this approach promotes a better understanding of what to anticipate. No?
I will await your response before sending v3. Thx.
Thanks, Anand
Quoted 11 lines
Review _fs_sysfs_dname() · line 4732
Quoted 9 lines
(quoted diff) +2
-1@@ -4728,7 +4728,9 @@ _fs_sysfs_dname() case "$FSTYP" in btrfs) - findmnt -n -o UUID ${dev} ;; + fsid=$($BTRFS_UTIL_PROG filesystem show ${dev} | grep uuid: | \ + awk '{print $NF}')Please make the variable local.
Added in v3. Thx, Anand
Re: [PATCH 2/2 v2] fstests: btrfs/219 cloned-device mount capability update
In reply to Anand JainQuoted 4 lines · Anand Jain
Quoted 8 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + # The variables are set before the test case can fail.What if the _require_* statements fail?
Then the variables won't be defined...Oh, yes indeed. It was fixed in v3 by moving the variable definition before the 'require' statement.
Is it really worth doing this type of change?
I mean it doesn't change the correctness of the test, doesn't make it more readable or
maintainable, or even shorter... It seems pointless to me, no clear benefit of any sort.
Quoted 68 lines
Quoted 20 lines
Review
Quoted 13 lines
(quoted diff) +11
-0+ $UMOUNT_PROG ${loop_mnt1} &> /dev/null + $UMOUNT_PROG ${loop_mnt2} &> /dev/null + + _destroy_loop_device $loop_dev1 &> /dev/null + _destroy_loop_device $loop_dev2 &> /dev/null + + rm -rf $fs_img1 &> /dev/null + rm -rf $fs_img2 &> /dev/null + + rm -rf $loop_mnt1 &> /dev/null + rm -rf $loop_mnt2 &> /dev/nullAlso please for simplicity and clarity don't mix this type of change with the actual purpose of the patch,
to make the test succeed on a kernel with the temp-fsid feature.You're mixing 3 different changes in the same patch...
Quoted 13 lines
Review
Quoted 8 lines
(quoted diff) +4
-4-loop_mnt=$TEST_DIR/$seq.mnt -loop_mnt1=$TEST_DIR/$seq.mnt1 -fs_img1=$TEST_DIR/$seq.img1 -fs_img2=$TEST_DIR/$seq.img2 +loop_mnt1=$TEST_DIR/$seq/mnt1 +loop_mnt2=$TEST_DIR/$seq/mnt2 +fs_img1=$TEST_DIR/$seq/img1 +fs_img2=$TEST_DIR/$seq/img2So this is the other unrelated change, renaming all these variables... This is making the diff larger to follow as this has nothing to do with the goal of making the test succeed on a kernel with the temp-fsid feature.
Sure. I'll move these changes to a new patch in v3.
Quoted 10 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+_mount $loop_dev2 $loop_mnt2 > /dev/null 2>&1 + +if [ $? == 0 ]; then + # On temp-fsid supported kernels, mounting cloned device will be successfull. + if _has_fs_sysfs_attr $loop_dev2 temp_fsid; then + temp_fsid=$(_get_fs_sysfs_attr ${loop_dev2} temp_fsid) + if [ $temp_fsid == 0 ]; then + _fail "Cloned devices mounted without temp_fsid" + fiHmm. It is exactly testing what happens with and without the temp-fsid feature.
Quoted 7 lines
This is too complex. Why not just surround the existing code in an if statement like this:
if "sysfs-file-for-temp-fsid does not exist" then
run this code that fails with a temp-fsid enabled kernel
fiYour suggestion will test what to expect when there is no 'temp-fsid.'
However, if 'temp-fsid' is present, we expect its sysfs
temp_fsidto be set to 1, which I believe is a straightforward verification.And do you think adding more comments will make it simpler? Such as:
# If the second mount is successful, then check if 'temp-fsid'
Quoted 6 lines
# is in the kernel. If it's present, verify that it outputs 1.Or, Are you suggesting we postpone confirming the correct operation of 'temp-fsid' for another test case? However, I believe in thoroughly verifying it wherever it's used, as this approach promotes a better understanding of what to anticipate. No?
I'm not suggesting a new test case.
Remember the code you removed in v1?
My suggestion was to instead of removing it, just surround it in the body of an if statement:
if temp-fsid-feature-not-abailable; then
run that code you tried to remove in v1
fi
Isn't that a lot simpler and clear?
Thanks.
Quoted 5 lines
I will await your response before sending v3. Thx.
Thanks, Anand
Re: [PATCH 2/2 v2] fstests: btrfs/219 cloned-device mount capability update
Quoted 7 lines
Is it really worth doing this type of change?
I mean it doesn't change the correctness of the test, doesn't make it more readable or
maintainable, or even shorter... It seems pointless to me, no clear benefit of any sort.
It fixes the cleanup bug that, when a test case failed, it failed to remove the 2nd loop device.
Quoted 11 lines
I'm not suggesting a new test case.
Remember the code you removed in v1?
My suggestion was to instead of removing it, just surround it in the body of an if statement:if temp-fsid-feature-not-abailable; then
run that code you tried to remove in v1
fiIsn't that a lot simpler and clear?
Alright, I'll maintain the simplicity as mentioned above. Nevertheless, implementing a thorough check for temp-fsid doesn't add much complexity either.
Re: [PATCH 2/2 v2] fstests: btrfs/219 cloned-device mount capability update
Quoted 11 lines · Anand Jain
Quoted 8 lines
Is it really worth doing this type of change?
I mean it doesn't change the correctness of the test, doesn't make it more readable or
maintainable, or even shorter... It seems pointless to me, no clear benefit of any sort.It fixes the cleanup bug that, when a test case failed, it failed to remove the 2nd loop device.
Then that's a very strong reason to make it a separate patch and explain the bug, instead
of sneaking it in with other different changes without being explicit about it.
Thanks.
Quoted 19 lines
Quoted 7 lines
I'm not suggesting a new test case.
Remember the code you removed in v1?
My suggestion was to instead of removing it, just surround it in the body of an if statement:Quoted 5 lines
if temp-fsid-feature-not-abailable; then
run that code you tried to remove in v1
fiIsn't that a lot simpler and clear?
Alright, I'll maintain the simplicity as mentioned above. Nevertheless, implementing a thorough check for temp-fsid doesn't add much complexity either.