fstests: verify that xfs_growfs can operate on mounted device node
PATCH 1/1 fstests: verify that xfs_growfs can operate on mounted device node
The ability to use a mounted device node as the primary argument to xfs_growfs will be added back in, because it was an undocumented behavior that some userspace depended on. This test exercises that functionality.
---
tests/xfs/148 new file +100 -0
@@ -0,0 +1,100 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2019 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test 148 +# +# Test to ensure xfs_growfs command accepts device nodes if & only +# if they are mounted. +# This functionality, though undocumented, worked until xfsprogs v4.12 +# It was added back and documented after xfsprogs v5.2 +# +# Based on xfs/289 +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + $UMOUNT_PROG $mntdir + _destroy_loop_device $loop_dev + rmdir $mntdir + rm -f $loop_symlink + rm -f $loopfile +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_supported_os Linux +_require_test +_require_loop + +loopfile=$TEST_DIR/fsfile +mntdir=$TEST_DIR/mntdir +loop_symlink=$TEST_DIR/loop_symlink.$$ + +mkdir -p $mntdir || _fail "!!! failed to create temp mount dir" + +echo "=== mkfs.xfs ===" +$MKFS_XFS_PROG -d file,name=$loopfile,size=16m -f >/dev/null 2>&1 + +echo "=== truncate ===" +$XFS_IO_PROG -fc "truncate 256m" $loopfile + +echo "=== create loop device ===" +loop_dev=$(_create_loop_device $loopfile) + +echo "=== create loop device symlink ===" +ln -s $loop_dev $loop_symlink + +echo "loop device is $loop_dev" + +# These unmounted operations should fail + +echo "=== xfs_growfs - unmounted device, command should be rejected ===" +$XFS_GROWFS_PROG $loop_dev 2>&1 | sed -e s:$loop_dev:LOOPDEV: + +echo "=== xfs_growfs - check symlinked dev, unmounted ===" +$XFS_GROWFS_PROG $loop_symlink 2>&1 | sed -e s:$loop_symlink:LOOPSYMLINK: + +# These mounted operations should pass + +echo "=== mount ===" +$MOUNT_PROG $loop_dev $mntdir || _fail "!!! failed to loopback mount" + +echo "=== xfs_growfs - check device node ===" +$XFS_GROWFS_PROG -D 8192 $loop_dev > /dev/null + +echo "=== xfs_growfs - check device symlink ===" +$XFS_GROWFS_PROG -D 12288 $loop_symlink > /dev/null + +echo "=== unmount ===" +$UMOUNT_PROG $mntdir || _fail "!!! failed to unmount" + +echo "=== mount device symlink ===" +$MOUNT_PROG $loop_symlink $mntdir || _fail "!!! failed to loopback mount" + +echo "=== xfs_growfs - check device symlink ===" +$XFS_GROWFS_PROG -D 16384 $loop_symlink > /dev/null + +echo "=== xfs_growfs - check device node ===" +$XFS_GROWFS_PROG -D 20480 $loop_dev > /dev/null + +# success, all done +status=0 +exit
tests/xfs/148.out new file +17 -0
@@ -0,0 +1,17 @@ +QA output created by 148 +=== mkfs.xfs === +=== truncate === +=== create loop device === +=== create loop device symlink === +loop device is /dev/loop0 +=== xfs_growfs - unmounted device, command should be rejected === +xfs_growfs: LOOPDEV is not a mounted XFS filesystem +=== xfs_growfs - check symlinked dev, unmounted === +xfs_growfs: LOOPSYMLINK is not a mounted XFS filesystem +=== mount === +=== xfs_growfs - check device node === +=== xfs_growfs - check device symlink === +=== unmount === +=== mount device symlink === +=== xfs_growfs - check device symlink === +=== xfs_growfs - check device node ===
tests/xfs/group +1 -0
@@ -145,6 +145,7 @@ 145 dmapi 146 dmapi 147 dmapi +148 quick auto growfs 150 dmapi 151 dmapi 152 dmapi
Quoted 14 lines · Eric Sandeen
The ability to use a mounted device node as the primary argument to
xfs_growfswill be added back in, because it was an undocumented behavior that some userspace depended on. This test exercises that functionality.Signed-off-by Eric Sandeen <[email protected]>---
tests/xfs/148 new file +0
-0
tests/xfs/148 line 10
Quoted 10 lines
tests/xfs/148 new file +10
-0@@ -0,0 +1,100 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2019 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test 148 +# +# Test to ensure xfs_growfs command accepts device nodes if & only +# if they are mounted. +# This functionality, though undocumented, worked until xfsprogs v4.12 +# It was added back and documented after xfsprogs v5.2
I'm testing with xfsprogs from for-next branch, which is v5.3.0-rc1 based xfs_growfs, but I still see failures like
=== xfs_growfs - check device node ===
+xfs_growfs: /dev/loop0 is not a mounted XFS filesystem
=== xfs_growfs - check device symlink ===
+xfs_growfs: /mnt/test/loop_symlink.21781 is not a mounted XFS filesystem
=== unmount ===If it's already fixed, would you please list the related commits in commit log as well?
Quoted 10 lines
tests/xfs/148 new file +10
-0+# +# Based on xfs/289 +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default!
tests/xfs/148 line 30
Quoted 10 lines
tests/xfs/148 new file +10
-0+trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + $UMOUNT_PROG $mntdir + _destroy_loop_device $loop_dev + rmdir $mntdir + rm -f $loop_symlink + rm -f $loopfile +}
'mntdir', 'loop_symlink' and 'loopfile' should be defined before _cleanup, otherwise if we exit early, e.g. due to unmet requirement, we'll see false failures.
And should check if 'loop_dev' is defined before destroy it.
Quoted 25 lines
tests/xfs/148 new file +25
-0+ +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs xfs +_supported_os Linux +_require_test +_require_loop + +loopfile=$TEST_DIR/fsfile +mntdir=$TEST_DIR/mntdir +loop_symlink=$TEST_DIR/loop_symlink.$$ + +mkdir -p $mntdir || _fail "!!! failed to create temp mount dir" + +echo "=== mkfs.xfs ===" +$MKFS_XFS_PROG -d file,name=$loopfile,size=16m -f >/dev/null 2>&1 +
tests/xfs/148 line 65
Quoted 10 lines
tests/xfs/148 new file +10
-0+echo "=== truncate ===" +$XFS_IO_PROG -fc "truncate 256m" $loopfile + +echo "=== create loop device ===" +loop_dev=$(_create_loop_device $loopfile) + +echo "=== create loop device symlink ===" +ln -s $loop_dev $loop_symlink + +echo "loop device is $loop_dev"
This should be redirected to $seqres.full, as $loop_dev could be any loop device.
Quoted 41 lines
tests/xfs/148 new file +35
-0+ +# These unmounted operations should fail + +echo "=== xfs_growfs - unmounted device, command should be rejected ===" +$XFS_GROWFS_PROG $loop_dev 2>&1 | sed -e s:$loop_dev:LOOPDEV: + +echo "=== xfs_growfs - check symlinked dev, unmounted ===" +$XFS_GROWFS_PROG $loop_symlink 2>&1 | sed -e s:$loop_symlink:LOOPSYMLINK: + +# These mounted operations should pass + +echo "=== mount ===" +$MOUNT_PROG $loop_dev $mntdir || _fail "!!! failed to loopback mount" + +echo "=== xfs_growfs - check device node ===" +$XFS_GROWFS_PROG -D 8192 $loop_dev > /dev/null + +echo "=== xfs_growfs - check device symlink ===" +$XFS_GROWFS_PROG -D 12288 $loop_symlink > /dev/null + +echo "=== unmount ===" +$UMOUNT_PROG $mntdir || _fail "!!! failed to unmount" + +echo "=== mount device symlink ===" +$MOUNT_PROG $loop_symlink $mntdir || _fail "!!! failed to loopback mount" + +echo "=== xfs_growfs - check device symlink ===" +$XFS_GROWFS_PROG -D 16384 $loop_symlink > /dev/null + +echo "=== xfs_growfs - check device node ===" +$XFS_GROWFS_PROG -D 20480 $loop_dev > /dev/null + +# success, all done +status=0 +exittests/xfs/148.out new file +0
-0
tests/xfs/148.out line 6
Quoted 6 lines
tests/xfs/148.out new file +6
-0@@ -0,0 +1,17 @@ +QA output created by 148 +=== mkfs.xfs === +=== truncate === +=== create loop device === +=== create loop device symlink === +loop device is /dev/loop0
So this line should be removed as well.
Thanks,
Eryu
Quoted 24 lines
tests/xfs/148.out new file +11
-0+=== xfs_growfs - unmounted device, command should be rejected === +xfs_growfs: LOOPDEV is not a mounted XFS filesystem +=== xfs_growfs - check symlinked dev, unmounted === +xfs_growfs: LOOPSYMLINK is not a mounted XFS filesystem +=== mount === +=== xfs_growfs - check device node === +=== xfs_growfs - check device symlink === +=== unmount === +=== mount device symlink === +=== xfs_growfs - check device symlink === +=== xfs_growfs - check device node ===tests/xfs/group +1
-0@@ -145,6 +145,7 @@ 145 dmapi 146 dmapi 147 dmapi +148 quick auto growfs 150 dmapi 151 dmapi 152 dmapi
Quoted 29 lines · Eryu Guan
Quoted 14 lines · Eric Sandeen
The ability to use a mounted device node as the primary argument to
xfs_growfswill be added back in, because it was an undocumented behavior that some userspace depended on. This test exercises that functionality.Signed-off-by Eric Sandeen <[email protected]>---
tests/xfs/148 new file +0
-0tests/xfs/148 line 10
Quoted 10 lines
tests/xfs/148 new file +10
-0@@ -0,0 +1,100 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2019 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test 148 +# +# Test to ensure xfs_growfs command accepts device nodes if & only +# if they are mounted. +# This functionality, though undocumented, worked until xfsprogs v4.12 +# It was added back and documented after xfsprogs v5.2I'm testing with xfsprogs from for-next branch, which is v5.3.0-rc1 based
xfs_growfs, but I still see failures like
Quoted 8 lines
=== xfs_growfs - check device node === +xfs_growfs: /dev/loop0 is not a mounted XFS filesystem === xfs_growfs - check device symlink === +xfs_growfs: /mnt/test/loop_symlink.21781 is not a mounted XFS filesystem === unmount ===If it's already fixed, would you please list the related commits in commit log as well?
I haven't merged the fix yet.
If you like I can resend the test when it's merged.
Quoted 36 lines · Eric Sandeen
Quoted 35 lines · Eryu Guan
Quoted 14 lines · Eric Sandeen
The ability to use a mounted device node as the primary argument to
xfs_growfswill be added back in, because it was an undocumented behavior that some userspace depended on. This test exercises that functionality.Signed-off-by Eric Sandeen <[email protected]>---
tests/xfs/148 new file +0
-0tests/xfs/148 line 10
Quoted 10 lines
tests/xfs/148 new file +10
-0@@ -0,0 +1,100 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2019 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test 148 +# +# Test to ensure xfs_growfs command accepts device nodes if & only +# if they are mounted. +# This functionality, though undocumented, worked until xfsprogs v4.12 +# It was added back and documented after xfsprogs v5.2I'm testing with xfsprogs from for-next branch, which is v5.3.0-rc1 based
xfs_growfs, but I still see failures like=== xfs_growfs - check device node === +xfs_growfs: /dev/loop0 is not a mounted XFS filesystem === xfs_growfs - check device symlink === +xfs_growfs: /mnt/test/loop_symlink.21781 is not a mounted XFS filesystem === unmount ===
Quoted 4 lines
Quoted 2 lines
If it's already fixed, would you please list the related commits in commit log as well?
I haven't merged the fix yet.
Ah, that explains. I saw "It was added back and documented after xfsprogs v5.2", so I expected it to be PASS when testing with v5.3-rc1.
Quoted 3 lines
If you like I can resend the test when it's merged.
Either way is fine, as long as the fix is referenced somewhere (either in commit log or in test description, and refer to the patch summary if it's not merged yet).
Thanks,
Eryu