xfs: test xfsdump with bind-mounted filesystem
PATCH 1/1 xfs: test xfsdump with bind-mounted filesystem
From: Masayoshi Mizuma <[email protected]>
commit 25195eb ("xfsdump: handle bind mount target") introduced a bug of xfsdump which doesn't store the files to the dump file correctly when the root inode number is changed.
The commit 25195eb is reverted, and commit 0717c1c ("xfsdump: intercept bind mount targets") which is in xfsdump v3.1.10 fixes the bug to reject the filesystem if it's bind-mounted.
Test that xfsdump can reject the bind-mounted filesystem.
--- tests/xfs/544 | 63 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/544.out | 2 ++ 2 files changed, 65 insertions(+) create mode 100755 tests/xfs/544 create mode 100644 tests/xfs/544.out
tests/xfs/544 new file +63 -0
@@ -0,0 +1,63 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Fujitsu Limited. All Rights Reserved. +# +# FS QA Test 544 +# +# Regression test for commit: +# 0717c1c ("xfsdump: intercept bind mount targets") + +. ./common/preamble +_begin_fstest auto dump + +_cleanup() +{ + _cleanup_dump + cd / + rm -r -f $tmp.* + $UMOUNT_PROG $mntpnt2 2> /dev/null + rmdir $mntpnt1/dir 2> /dev/null + $UMOUNT_PROG $mntpnt1 2> /dev/null + rmdir $mntpnt2 2> /dev/null + rmdir $mntpnt1 2> /dev/null + [ -n "$loopdev" ] && _destroy_loop_device $loopdev + rm -f "$TEST_DIR"/fsfile +} + +# Import common functions. +. ./common/filter +. ./common/dump + +# real QA test starts here + +_supported_fs xfs + +mntpnt1=$TEST_DIR/MNT1 +mntpnt2=$TEST_DIR/MNT2 + + +# Set up +$MKFS_XFS_PROG -s size=4096 -b size=4096 \ + -dfile,name=$TEST_DIR/fsfile,size=8649728b,sunit=1024,swidth=2048 \ + >> $seqres.full 2>&1 || _fail "mkfs failed" + +loopdev=$(_create_loop_device "$TEST_DIR"/fsfile) + +mkdir $mntpnt1 >> $seqres.full 2>&1 || _fail "mkdir \"$mntpnt1\" failed" + +_mount $loopdev $mntpnt1 +mkdir $mntpnt1/dir >> $seqres.full 2>&1 || _fail "mkdir \"$mntpnt1/dir\" failed" +mkdir $mntpnt2 >> $seqres.full 2>&1 || _fail "mkdir \"$mntpnt2\" failed" + + +# Test +echo "*** dump with bind-mounted test ***" >> $seqres.full + +mount -o bind $mntpnt1/dir $mntpnt2 + +$XFSDUMP_PROG -L session -M test -f $tmp.dump $mntpnt2 \ + >> $seqres.full 2>&1 && echo "dump with bind-mounted should be failed, but passed." + +echo "Silence is golden" +status=0 +exit
tests/xfs/544.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 544 +Silence is golden
Signature · 1 line
2.31.1
Quoted 31 lines · Masayoshi Mizuma
From: Masayoshi Mizuma <[email protected]>
commit 25195eb ("xfsdump: handle bind mount target") introduced a bug of xfsdump which doesn't store the files to the dump file correctly when the root inode number is changed.
The commit 25195eb is reverted, and commit 0717c1c ("xfsdump: intercept bind mount targets") which is in xfsdump v3.1.10 fixes the bug to reject the filesystem if it's bind-mounted.
Test that xfsdump can reject the bind-mounted filesystem.
Signed-off-by Masayoshi Mizuma <[email protected]>--- tests/xfs/544 | 63 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/544.out | 2 ++ 2 files changed, 65 insertions(+) create mode 100755 tests/xfs/544 create mode 100644 tests/xfs/544.outtests/xfs/544 new file +5
-0@@ -0,0 +1,63 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Fujitsu Limited. All Rights Reserved. +# +# FS QA Test 544
tests/xfs/544 line 15
Quoted 10 lines
tests/xfs/544 new file +10
-0+# +# Regression test for commit: +# 0717c1c ("xfsdump: intercept bind mount targets") + +. ./common/preamble +_begin_fstest auto dump + +_cleanup() +{ + _cleanup_dump
Is this really needed?
Quoted 17 lines
tests/xfs/544 new file +17
-0+ cd / + rm -r -f $tmp.* + $UMOUNT_PROG $mntpnt2 2> /dev/null + rmdir $mntpnt1/dir 2> /dev/null + $UMOUNT_PROG $mntpnt1 2> /dev/null + rmdir $mntpnt2 2> /dev/null + rmdir $mntpnt1 2> /dev/null + [ -n "$loopdev" ] && _destroy_loop_device $loopdev + rm -f "$TEST_DIR"/fsfile +} + +# Import common functions. +. ./common/filter +. ./common/dump + +# real QA test starts here +
tests/xfs/544 line 42
Quoted 10 lines
tests/xfs/544 new file +10
-0+_supported_fs xfs + +mntpnt1=$TEST_DIR/MNT1 +mntpnt2=$TEST_DIR/MNT2 + + +# Set up +$MKFS_XFS_PROG -s size=4096 -b size=4096 \ + -dfile,name=$TEST_DIR/fsfile,size=8649728b,sunit=1024,swidth=2048 \ + >> $seqres.full 2>&1 || _fail "mkfs failed"
Are "-s size=4096 -b size=4096 -d sunit=1024,swidth=2048" necessary? If so, better to add comments to explain why they're needed.
tests/xfs/544 line 44
Quoted 2 lines
tests/xfs/544 new file +2
-0+ +loopdev=$(_create_loop_device "$TEST_DIR"/fsfile)
Is loopdev necessary? If you need mkfs, can we just use SCRATCH_DEV, and bind $SCRATCH_MNT/someonedir on $TEST_DIR/someonedir ? E.g:
_cleanup()
{
$UMOUNT_PROG $TEST_DIR/dest 2> /dev/null
cd /
rm -r -f $tmp.*
}_scratch_mkfs > $seqres.full_scratch_mount
mkdir $SCRATCH_MNT/src
mkdir $TEST_DIR/dest
$MOUNT_PROG --bind $SCRATCH_MNT/src $TEST_DIR/dest || _fail "Bind mount failed" $XFSDUMP_PROG -L session -M test -f $tmp.dump $TEST_DIR/dest >> $seqres.full 2>&1 && \
echo "dump with bind-mounted should be failed, but passed."
echo "Silence is golden"
...
If you don't need mkfs, you can use $TEST_DIR (e.g. $TEST_DIR/src and $TEST_DIR/dest) to be bind mount source and target. Due to this case just trys to test xfsdump a bind mount, and make sure dump failed as expected. Am I right?
Thanks,
Zorro
Quoted 30 lines
tests/xfs/544 new file +19
-0+ +mkdir $mntpnt1 >> $seqres.full 2>&1 || _fail "mkdir \"$mntpnt1\" failed" + +_mount $loopdev $mntpnt1 +mkdir $mntpnt1/dir >> $seqres.full 2>&1 || _fail "mkdir \"$mntpnt1/dir\" failed" +mkdir $mntpnt2 >> $seqres.full 2>&1 || _fail "mkdir \"$mntpnt2\" failed" + + +# Test +echo "*** dump with bind-mounted test ***" >> $seqres.full + +mount -o bind $mntpnt1/dir $mntpnt2 + +$XFSDUMP_PROG -L session -M test -f $tmp.dump $mntpnt2 \ + >> $seqres.full 2>&1 && echo "dump with bind-mounted should be failed, but passed." + +echo "Silence is golden" +status=0 +exittests/xfs/544.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 544 +Silence is goldenSignature · 1 line
2.31.1
Quoted 97 lines · Zorro Lang
Quoted 31 lines · Masayoshi Mizuma
From: Masayoshi Mizuma <[email protected]>
commit 25195eb ("xfsdump: handle bind mount target") introduced a bug of xfsdump which doesn't store the files to the dump file correctly when the root inode number is changed.
The commit 25195eb is reverted, and commit 0717c1c ("xfsdump: intercept bind mount targets") which is in xfsdump v3.1.10 fixes the bug to reject the filesystem if it's bind-mounted.
Test that xfsdump can reject the bind-mounted filesystem.
Signed-off-by Masayoshi Mizuma <[email protected]>--- tests/xfs/544 | 63 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/544.out | 2 ++ 2 files changed, 65 insertions(+) create mode 100755 tests/xfs/544 create mode 100644 tests/xfs/544.outtests/xfs/544 new file +5
-0@@ -0,0 +1,63 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022 Fujitsu Limited. All Rights Reserved. +# +# FS QA Test 544tests/xfs/544 line 15
Quoted 10 lines
tests/xfs/544 new file +10
-0+# +# Regression test for commit: +# 0717c1c ("xfsdump: intercept bind mount targets") + +. ./common/preamble +_begin_fstest auto dump + +_cleanup() +{ + _cleanup_dumpIs this really needed?
Quoted 17 lines
tests/xfs/544 new file +17
-0+ cd / + rm -r -f $tmp.* + $UMOUNT_PROG $mntpnt2 2> /dev/null + rmdir $mntpnt1/dir 2> /dev/null + $UMOUNT_PROG $mntpnt1 2> /dev/null + rmdir $mntpnt2 2> /dev/null + rmdir $mntpnt1 2> /dev/null + [ -n "$loopdev" ] && _destroy_loop_device $loopdev + rm -f "$TEST_DIR"/fsfile +} + +# Import common functions. +. ./common/filter +. ./common/dump + +# real QA test starts here +tests/xfs/544 line 42
Quoted 10 lines
tests/xfs/544 new file +10
-0+_supported_fs xfs + +mntpnt1=$TEST_DIR/MNT1 +mntpnt2=$TEST_DIR/MNT2 + + +# Set up +$MKFS_XFS_PROG -s size=4096 -b size=4096 \ + -dfile,name=$TEST_DIR/fsfile,size=8649728b,sunit=1024,swidth=2048 \ + >> $seqres.full 2>&1 || _fail "mkfs failed"Are "-s size=4096 -b size=4096 -d sunit=1024,swidth=2048" necessary? If so, better to add comments to explain why they're needed.
tests/xfs/544 line 44
Quoted 2 lines
tests/xfs/544 new file +2
-0+ +loopdev=$(_create_loop_device "$TEST_DIR"/fsfile)Is loopdev necessary? If you need mkfs, can we just use
SCRATCH_DEV, and bind $SCRATCH_MNT/someonedir on $TEST_DIR/someonedir ? E.g:
_cleanup(){ $UMOUNT_PROG $TEST_DIR/dest 2> /dev/null cd / rm -r -f $tmp.* }
_scratch_mkfs> $seqres.full_scratch_mount
mkdir $SCRATCH_MNT/src
mkdir $TEST_DIR/dest
$MOUNT_PROG --bind $SCRATCH_MNT/src $TEST_DIR/dest ||_fail"Bind mount failed" $XFSDUMP_PROG -L session -M test -f $tmp.dump $TEST_DIR/dest >> $seqres.full 2>&1 && \
echo "dump with bind-mounted should be failed, but passed."
Quoted 6 lines
echo "Silence is golden"
...If you don't need mkfs, you can use $TEST_DIR (e.g. $TEST_DIR/src and $TEST_DIR/dest) to be bind mount source and target. Due to this case just trys to test xfsdump a bind mount, and make sure dump failed as expected. Am I right?
Thank you for pointing it out! Yes, you're right. I'll remove the unnecessary parts and post the v2.
Thanks!
Masa
Quoted 35 lines
Thanks,
ZorroQuoted 30 lines
tests/xfs/544 new file +19
-0+ +mkdir $mntpnt1 >> $seqres.full 2>&1 || _fail "mkdir \"$mntpnt1\" failed" + +_mount $loopdev $mntpnt1 +mkdir $mntpnt1/dir >> $seqres.full 2>&1 || _fail "mkdir \"$mntpnt1/dir\" failed" +mkdir $mntpnt2 >> $seqres.full 2>&1 || _fail "mkdir \"$mntpnt2\" failed" + + +# Test +echo "*** dump with bind-mounted test ***" >> $seqres.full + +mount -o bind $mntpnt1/dir $mntpnt2 + +$XFSDUMP_PROG -L session -M test -f $tmp.dump $mntpnt2 \ + >> $seqres.full 2>&1 && echo "dump with bind-mounted should be failed, but passed." + +echo "Silence is golden" +status=0 +exittests/xfs/544.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 544 +Silence is goldenSignature · 1 line
2.31.1