fstests: verify that xfs_growfs can operate on mounted device node
authorEric Sandeen <sandeen@redhat.com>
Tue, 17 Dec 2019 22:34:07 +0000 (16:34 -0600)
committerEryu Guan <guaneryu@gmail.com>
Mon, 6 Jan 2020 09:00:07 +0000 (17:00 +0800)
The ability to use a mounted device node as the primary argument
to xfs_growfs was added back in with:
  7e8275f8 xfs_growfs: allow mounted device node as argument
because it was an undocumented behavior that some userspace depended on.
This test exercises that functionality.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/xfs/149 [new file with mode: 0755]
tests/xfs/149.out [new file with mode: 0644]
tests/xfs/group

diff --git a/tests/xfs/149 b/tests/xfs/149
new file mode 100755 (executable)
index 0000000..23949e4
--- /dev/null
@@ -0,0 +1,101 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test No. 149
+#
+# 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 via
+#   7e8275f8 xfs_growfs: allow mounted device node as argument
+#
+# 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
+
+loopfile=$TEST_DIR/fsfile
+mntdir=$TEST_DIR/mntdir
+loop_symlink=$TEST_DIR/loop_symlink.$$
+
+_cleanup()
+{
+    $UMOUNT_PROG $mntdir
+    [ -n "$loop_dev" ] && _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
+
+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" >> $seqres.full
+
+# 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
diff --git a/tests/xfs/149.out b/tests/xfs/149.out
new file mode 100644 (file)
index 0000000..02dc338
--- /dev/null
@@ -0,0 +1,16 @@
+QA output created by 149
+=== mkfs.xfs ===
+=== truncate ===
+=== create loop device ===
+=== create loop device symlink ===
+=== 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 ===
index 4373d082762a7787409715b3825b43401079279a..c7253cf10788351a4e4f0d8260ae4c05592b4ca1 100644 (file)
 146 dmapi
 147 dmapi
 148 auto quick fuzzers
+149 auto quick growfs
 150 dmapi
 151 dmapi
 152 dmapi