public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] test multi-level bind and shared subtree mounts
@ 2017-02-14  0:55 Theodore Ts'o
  2017-02-14  0:55 ` [PATCH 1/4] common/rc: new functions for multi-level mount/umount operations Theodore Ts'o
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Theodore Ts'o @ 2017-02-14  0:55 UTC (permalink / raw)
  To: fstests; +Cc: Zorro Lang, Theodore Ts'o

This is a respon if of Zorro Lang's patch set from May 20, 2016.  I've
reviewed them, and tested them against a recent development kernel.

The two main changes which I made to Zorro's patches:

  * I changed the numbers to the most recent unallocated test numbers
  * I added code to delete the test files in the end_test function

Zorro Lang (4):
  common/rc: new functions for multi-level mount/umount operations
  generic: new case for test mount bind operation
  generic: new case for test mount shared subtrees state transition
  generic: new case test two vfsmount no peers

 common/rc             |  31 ++
 tests/generic/409     | 182 +++++++++++
 tests/generic/409.out | 365 ++++++++++++++++++++++
 tests/generic/410     | 215 +++++++++++++
 tests/generic/410.out | 813 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/411     | 147 +++++++++
 tests/generic/411.out |  12 +
 tests/generic/group   |   3 +
 8 files changed, 1768 insertions(+)
 create mode 100644 tests/generic/409
 create mode 100644 tests/generic/409.out
 create mode 100644 tests/generic/410
 create mode 100644 tests/generic/410.out
 create mode 100644 tests/generic/411
 create mode 100644 tests/generic/411.out

-- 
2.11.0.rc0.7.gbe5a750


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] common/rc: new functions for multi-level mount/umount operations
  2017-02-14  0:55 [PATCH 0/4] test multi-level bind and shared subtree mounts Theodore Ts'o
@ 2017-02-14  0:55 ` Theodore Ts'o
  2017-02-14  0:55 ` [PATCH 2/4] generic: new case for test mount bind operation Theodore Ts'o
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Theodore Ts'o @ 2017-02-14  0:55 UTC (permalink / raw)
  To: fstests; +Cc: Zorro Lang, Theodore Ts'o

From: Zorro Lang <zlang@redhat.com>

When I try to write cases about mount shared subtrees test, I find
I always need to do many mount operations, then then umount those
mount point one by one.

For make the code clear, I use a stack to save mounted points
sequentially, then I write 3 common functions to operate this
stack.

1. The global stack named MOUNTED_POINT_STACK
2. _get_mount() accept mount parameters likes _mount(), but the
   mountpoint parameter must be the last one. It will run the
   mount operation and push the mountpoint name into stack.
3. _put_mount() don't need any parameters. It will pull the newest
   mountpoint name from the stack, and umount it.
4. _clear_mount_stack() don't need any parameters either. It will
   umount all mountpoints in the stack sequentially, and set
   MOUNTED_POINT_STACK=""

Generally, the _clear_mount_stack() function also can be used as
_init_mount_stack() at the beginning of a case. Because it will
prepare an empty stack.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 common/rc | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/common/rc b/common/rc
index 2f4778f4..0771a06a 100644
--- a/common/rc
+++ b/common/rc
@@ -160,6 +160,37 @@ _mount()
     $MOUNT_PROG `_mount_ops_filter $*`
 }
 
+# the mount point must be the last parameter
+_get_mount()
+{
+    local mnt_point=${!#}
+
+    _mount $*
+    if [ $? -eq 0 ];then
+	MOUNTED_POINT_STACK=`echo "$mnt_point $MOUNTED_POINT_STACK"`
+    else
+	return 1
+    fi
+}
+
+_put_mount()
+{
+    local last_mnt=`echo $MOUNTED_POINT_STACK | awk '{print $1}'`
+
+    if [ -n "$last_mnt" ];then
+	umount $last_mnt
+    fi
+    MOUNTED_POINT_STACK=`echo $MOUNTED_POINT_STACK | cut -d\  -f2-`
+}
+
+_clear_mount_stack()
+{
+    if [ -n "$MOUNTED_POINT_STACK" ];then
+	umount $MOUNTED_POINT_STACK
+    fi
+    MOUNTED_POINT_STACK=""
+}
+
 _scratch_options()
 {
     type=$1
-- 
2.11.0.rc0.7.gbe5a750


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] generic: new case for test mount bind operation
  2017-02-14  0:55 [PATCH 0/4] test multi-level bind and shared subtree mounts Theodore Ts'o
  2017-02-14  0:55 ` [PATCH 1/4] common/rc: new functions for multi-level mount/umount operations Theodore Ts'o
@ 2017-02-14  0:55 ` Theodore Ts'o
  2017-02-15  9:53   ` Eryu Guan
  2017-02-14  0:55 ` [PATCH 3/4] generic: new case for test mount shared subtrees state transition Theodore Ts'o
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 8+ messages in thread
From: Theodore Ts'o @ 2017-02-14  0:55 UTC (permalink / raw)
  To: fstests; +Cc: Zorro Lang, Theodore Ts'o

From: Zorro Lang <zlang@redhat.com>

This case will do function test for mount bind operation, it will
verify below semantics:

---------------------------------------------------------------------------
|         BIND MOUNT OPERATION                                            |
|**************************************************************************
|source(A)->| shared       |       private  |       slave    | unbindable |
| dest(B)  |               |                |                |            |
|   |      |               |                |                |            |
|   v      |               |                |                |            |
|**************************************************************************
|  shared  | shared        |     shared     | shared & slave |  invalid   |
|          |               |                |                |            |
|non-shared| shared        |      private   |      slave     |  invalid   |
***************************************************************************

This case use fsstress to produce a little rand load, to sure basic
operations on the bind mountpoint won't cause hang or panic etc.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 tests/generic/409     | 182 +++++++++++++++++++++++++
 tests/generic/409.out | 365 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/group   |   1 +
 3 files changed, 548 insertions(+)
 create mode 100644 tests/generic/409
 create mode 100644 tests/generic/409.out

diff --git a/tests/generic/409 b/tests/generic/409
new file mode 100644
index 00000000..88bda6c5
--- /dev/null
+++ b/tests/generic/409
@@ -0,0 +1,182 @@
+#! /bin/bash
+# FS QA Test 409
+#
+# Test mount shared subtrees, verify the bind semantics:
+#
+# ---------------------------------------------------------------------------
+# |         BIND MOUNT OPERATION                                            |
+# |**************************************************************************
+# |source(A)->| shared       |       private  |       slave    | unbindable |
+# | dest(B)  |               |                |                |            |
+# |   |      |               |                |                |            |
+# |   v      |               |                |                |            |
+# |**************************************************************************
+# |  shared  | shared        |     shared     | shared & slave |  invalid   |
+# |          |               |                |                |            |
+# |non-shared| shared        |      private   |      slave     |  invalid   |
+# ***************************************************************************
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Red Hat Inc.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+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()
+{
+	cd /
+	rm -f $tmp.*
+	_clear_mount_stack
+}
+
+# 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
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_test
+
+fs_stress()
+{
+	local target=$1
+
+	$FSSTRESS_PROG -z -n 50 -p 3 \
+		       -f creat=5 \
+		       -f mkdir=5 \
+		       -f link=2 \
+		       -f rename=1 \
+		       -f rmdir=2 \
+		       -f unlink=1 \
+		       -f symlink=1 \
+		       -f write=1 \
+		       -f read=1 \
+		       -f chown=1 \
+		       -f getdents=1 \
+		       -f fiemap=1 \
+		       -d $target >/dev/null
+	sync
+}
+
+# prepare some mountpoint dir
+MNTHEAD=$TEST_DIR/$seq
+mkdir $MNTHEAD 2>>$seqres.full
+mpA=$MNTHEAD/"$$"_mpA
+mpB=$MNTHEAD/"$$"_mpB
+mpC=$MNTHEAD/"$$"_mpC
+mpD=$MNTHEAD/"$$"_mpD
+
+find_mnt()
+{
+	echo "------"
+	findmnt -n -o TARGET,SOURCE $SCRATCH_DEV | \
+	    sed -e "s;$mpA;mpA;g" \
+		-e "s;$mpB;mpB;g" \
+		-e "s;$mpC;mpC;g" \
+		-e "s;$mpD;mpD;g" | \
+	    _filter_spaces | _filter_scratch | \
+	    _filter_test_dir | sort
+	echo "======"
+}
+
+start_test()
+{
+	local type=$1
+
+	_get_mount $SCRATCH_DEV $MNTHEAD
+	mount --make-"${type}" $MNTHEAD
+	rm -rf $mpA $mpB $mpC $mpD 2>/dev/null
+	mkdir $mpA $mpB $mpC $mpD
+        _scratch_mkfs >$seqres.full 2>&1
+}
+
+end_test()
+{
+	rm -rf $mpA $mpB $mpC $mpD 2>/dev/null
+	_clear_mount_stack
+}
+
+bind_run()
+{
+	local source=$1
+	local dest=$2
+
+	start_test $dest
+
+	echo "bind $source on $dest"
+	_get_mount $SCRATCH_DEV $mpA
+	mkdir -p $mpA/dir 2>/dev/null
+	mount --make-shared $mpA
+	_get_mount --bind $mpA $mpB
+	mount --make-"$source" $mpB
+	# maybe unbindable at here
+	_get_mount --bind $mpB $mpC 2>/dev/null
+	if [ $? -ne 0 ];then
+		find_mnt
+		end_test
+		return 0
+	fi
+	_get_mount --bind $mpC $mpD
+	for m in $mpA $mpB $mpC $mpD
+	do
+		_get_mount $SCRATCH_DEV $m/dir
+		fs_stress $m/dir
+		find_mnt
+		_put_mount
+	done
+
+	end_test
+}
+
+bind_test()
+{
+	local dest=$1
+
+        #        source     dest
+	bind_run shared     shared
+	bind_run slave      shared
+	bind_run private    shared
+	bind_run unbindable shared
+
+	bind_run shared     slave
+	bind_run slave      slave
+	bind_run private    slave
+	bind_run unbindable slave
+
+	bind_run shared     private
+	bind_run slave      private
+	bind_run private    private
+	bind_run unbindable private
+}
+
+bind_test
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/409.out b/tests/generic/409.out
new file mode 100644
index 00000000..91c8909f
--- /dev/null
+++ b/tests/generic/409.out
@@ -0,0 +1,365 @@
+QA output created by 409
+bind shared on shared
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+bind slave on shared
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpD SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+bind private on shared
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpD SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpD SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+bind unbindable on shared
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+======
+bind shared on slave
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+bind slave on slave
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpD SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+bind private on slave
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpD SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpD SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+bind unbindable on slave
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+======
+bind shared on private
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+bind slave on private
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpD SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+bind private on private
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpD SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpD SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+mpD SCRATCH_DEV
+======
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpD SCRATCH_DEV
+mpD/dir SCRATCH_DEV
+======
+bind unbindable on private
+------
+TEST_DIR/409 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+======
diff --git a/tests/generic/group b/tests/generic/group
index d0bc47de..910b3138 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -411,3 +411,4 @@
 406 auto quick dangerous
 407 auto quick clone metadata
 408 auto quick clone dedupe metadata
+409 auto quick mount
-- 
2.11.0.rc0.7.gbe5a750


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] generic: new case for test mount shared subtrees state transition
  2017-02-14  0:55 [PATCH 0/4] test multi-level bind and shared subtree mounts Theodore Ts'o
  2017-02-14  0:55 ` [PATCH 1/4] common/rc: new functions for multi-level mount/umount operations Theodore Ts'o
  2017-02-14  0:55 ` [PATCH 2/4] generic: new case for test mount bind operation Theodore Ts'o
@ 2017-02-14  0:55 ` Theodore Ts'o
  2017-02-14  0:55 ` [PATCH 4/4] generic: new case test two vfsmount no peers Theodore Ts'o
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Theodore Ts'o @ 2017-02-14  0:55 UTC (permalink / raw)
  To: fstests; +Cc: Zorro Lang, Theodore Ts'o

From: Zorro Lang <zlang@redhat.com>

This case will do function test for mount --make-* operations, it will
verify below state transition:

------------------------------------------------------------------------
|             |make-shared |  make-slave  | make-private |make-unbindab|
--------------|------------|--------------|--------------|-------------|
|shared       |shared      |*slave/private|   private    | unbindable  |
|             |            |              |              |             |
|-------------|------------|--------------|--------------|-------------|
|slave        |shared      |    **slave   |    private   | unbindable  |
|             |and slave   |              |              |             |
|-------------|------------|--------------|--------------|-------------|
|shared       |shared      |    slave     |    private   | unbindable  |
|and slave    |and slave   |              |              |             |
|-------------|------------|--------------|--------------|-------------|
|private      |shared      |  **private   |    private   | unbindable  |
|-------------|------------|--------------|--------------|-------------|
|unbindable   |shared      |**unbindable  |    private   | unbindable  |
------------------------------------------------------------------------

This case use fsstress to produce a little rand load, to sure basic
operations on the mountpoints won't cause hang or panic etc.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 tests/generic/410     | 215 +++++++++++++
 tests/generic/410.out | 813 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/group   |   1 +
 3 files changed, 1029 insertions(+)
 create mode 100644 tests/generic/410
 create mode 100644 tests/generic/410.out

diff --git a/tests/generic/410 b/tests/generic/410
new file mode 100644
index 00000000..055a0543
--- /dev/null
+++ b/tests/generic/410
@@ -0,0 +1,215 @@
+#! /bin/bash
+# FS QA Test 410
+#
+# Test mount shared subtrees, verify the state transition when use:
+#   --make-shared
+#   --make-slave
+#   --make-private
+#   --make-unbindable
+#
+# ------------------------------------------------------------------------
+# |             |make-shared |  make-slave  | make-private |make-unbindab|
+# --------------|------------|--------------|--------------|-------------|
+# |shared       |shared      |*slave/private|   private    | unbindable  |
+# |             |            |              |              |             |
+# |-------------|------------|--------------|--------------|-------------|
+# |slave        |shared      |    **slave   |    private   | unbindable  |
+# |             |and slave   |              |              |             |
+# |-------------|------------|--------------|--------------|-------------|
+# |shared       |shared      |    slave     |    private   | unbindable  |
+# |and slave    |and slave   |              |              |             |
+# |-------------|------------|--------------|--------------|-------------|
+# |private      |shared      |  **private   |    private   | unbindable  |
+# |-------------|------------|--------------|--------------|-------------|
+# |unbindable   |shared      |**unbindable  |    private   | unbindable  |
+# ------------------------------------------------------------------------
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Red Hat Inc.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+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()
+{
+	cd /
+	rm -f $tmp.*
+	_clear_mount_stack
+}
+
+# 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
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_test
+
+fs_stress()
+{
+	local target=$1
+
+	$FSSTRESS_PROG -z -n 50 -p 3 \
+		       -f creat=5 \
+		       -f mkdir=5 \
+		       -f link=2 \
+		       -f rename=1 \
+		       -f rmdir=2 \
+		       -f unlink=1 \
+		       -f symlink=1 \
+		       -f write=1 \
+		       -f read=1 \
+		       -f chown=1 \
+		       -f getdents=1 \
+		       -f fiemap=1 \
+		       -d $target >/dev/null
+	sync
+}
+
+# prepare some mountpoint dir
+MNTHEAD=$TEST_DIR/$seq
+mkdir $MNTHEAD 2>>$seqres.full
+mpA=$MNTHEAD/"$$"_mpA
+mpB=$MNTHEAD/"$$"_mpB
+mpC=$MNTHEAD/"$$"_mpC
+
+find_mnt()
+{
+	echo "------"
+	findmnt -n -o TARGET,SOURCE $SCRATCH_DEV | \
+	    sed -e "s;$mpA;mpA;g" \
+		-e "s;$mpB;mpB;g" \
+		-e "s;$mpC;mpC;g" | \
+	    _filter_spaces | _filter_scratch | \
+	    _filter_test_dir | sort
+	echo "======"
+}
+
+start_test()
+{
+	local type=$1
+
+	_get_mount $SCRATCH_DEV $MNTHEAD
+	mount --make-"${type}" $MNTHEAD
+	rm -rf $mpA $mpB $mpC 2>/dev/null
+	mkdir $mpA $mpB $mpC
+        _scratch_mkfs >$seqres.full 2>&1
+}
+
+end_test()
+{
+	rm -rf $mpA $mpB $mpC 2>/dev/null
+	_clear_mount_stack
+}
+
+run()
+{
+	# command include make-shared/slave/private/unbindable
+	local cmd=$1
+	# orginal status include shared/slave/shared&slave/private/unbindable
+	local orgs="$2"
+
+	# bind anything on un-shared dest will keep the source type
+	# So use un-shared dest at here
+	start_test private
+
+	echo "make-$cmd a $orgs mount"
+	_get_mount $SCRATCH_DEV $mpA
+	mkdir -p $mpA/dir 2>/dev/null
+	mount --make-shared $mpA
+
+	# prepare the original status on mpB
+	_get_mount --bind $mpA $mpB
+	# shared&slave status need to do make-slave then make-shared
+	# two operations.
+	for t in $orgs
+	do
+		mount --make-"$t" $mpB
+	done
+
+	# "before" for prepare and check original status
+	# "after" for check the impact of make-$cmd command
+	for i in before after
+	do
+		echo "$i make-$cmd run on $orgs"
+		# maybe unbindable at here
+		_get_mount --bind $mpB $mpC 2>/dev/null
+		if [ $? -ne 0 ];then
+			find_mnt
+		else
+			for m in $mpA $mpB $mpC
+			do
+				_get_mount $SCRATCH_DEV $m/dir
+				fs_stress $m/dir
+				find_mnt
+				_put_mount
+			done
+			_put_mount # umount C
+		fi
+		if [ "$i" = "before" ];then
+			mount --make-"${cmd}" $mpB
+		fi
+	done
+
+	end_test
+}
+
+do_test()
+{
+    #   operation  original_status
+    run shared     shared
+    run shared     slave
+    run shared     "slave shared"
+    run shared     private
+    run shared     unbindable
+
+    run slave      shared
+    run slave      slave
+    run slave      "slave shared"
+    run slave      private
+    run slave      unbindable
+
+    run private    shared
+    run private    slave
+    run private    "slave shared"
+    run private    private
+    run private    unbindable
+
+    run unbindable shared
+    run unbindable slave
+    run unbindable "slave shared"
+    run unbindable private
+    run unbindable unbindable
+}
+
+do_test
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/410.out b/tests/generic/410.out
new file mode 100644
index 00000000..3579fd30
--- /dev/null
+++ b/tests/generic/410.out
@@ -0,0 +1,813 @@
+QA output created by 410
+make-shared a shared mount
+before make-shared run on shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-shared run on shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-shared a slave mount
+before make-shared run on slave
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-shared run on slave
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-shared a slave shared mount
+before make-shared run on slave shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-shared run on slave shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-shared a private mount
+before make-shared run on private
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-shared run on private
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-shared a unbindable mount
+before make-shared run on unbindable
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+======
+after make-shared run on unbindable
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-slave a shared mount
+before make-slave run on shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-slave run on shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-slave a slave mount
+before make-slave run on slave
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-slave run on slave
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-slave a slave shared mount
+before make-slave run on slave shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-slave run on slave shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-slave a private mount
+before make-slave run on private
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-slave run on private
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-slave a unbindable mount
+before make-slave run on unbindable
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+======
+after make-slave run on unbindable
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+======
+make-private a shared mount
+before make-private run on shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-private run on shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-private a slave mount
+before make-private run on slave
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-private run on slave
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-private a slave shared mount
+before make-private run on slave shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-private run on slave shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-private a private mount
+before make-private run on private
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-private run on private
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-private a unbindable mount
+before make-private run on unbindable
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+======
+after make-private run on unbindable
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+make-unbindable a shared mount
+before make-unbindable run on shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-unbindable run on shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+======
+make-unbindable a slave mount
+before make-unbindable run on slave
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-unbindable run on slave
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+======
+make-unbindable a slave shared mount
+before make-unbindable run on slave shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-unbindable run on slave shared
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+======
+make-unbindable a private mount
+before make-unbindable run on private
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/dir SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/dir SCRATCH_DEV
+mpC SCRATCH_DEV
+======
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/dir SCRATCH_DEV
+======
+after make-unbindable run on private
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+======
+make-unbindable a unbindable mount
+before make-unbindable run on unbindable
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+======
+after make-unbindable run on unbindable
+------
+TEST_DIR/410 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpB SCRATCH_DEV
+======
diff --git a/tests/generic/group b/tests/generic/group
index 910b3138..0f9e3b35 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -412,3 +412,4 @@
 407 auto quick clone metadata
 408 auto quick clone dedupe metadata
 409 auto quick mount
+410 auto quick mount
-- 
2.11.0.rc0.7.gbe5a750


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] generic: new case test two vfsmount no peers
  2017-02-14  0:55 [PATCH 0/4] test multi-level bind and shared subtree mounts Theodore Ts'o
                   ` (2 preceding siblings ...)
  2017-02-14  0:55 ` [PATCH 3/4] generic: new case for test mount shared subtrees state transition Theodore Ts'o
@ 2017-02-14  0:55 ` Theodore Ts'o
  2017-02-14  2:28 ` [PATCH 0/4] test multi-level bind and shared subtree mounts Zorro Lang
  2017-02-15  9:46 ` Eryu Guan
  5 siblings, 0 replies; 8+ messages in thread
From: Theodore Ts'o @ 2017-02-14  0:55 UTC (permalink / raw)
  To: fstests; +Cc: Zorro Lang, Theodore Ts'o

From: Zorro Lang <zlang@redhat.com>

This test cover linux commit 7ae8fd0, when mnt_group_id=0, it means
this mount no peers. But this bug treat two zero mnt_group_id as
peers. And it cause a crash by dereference a NULL address.

As below, the crash will happen when mount fs on "B/mnt1/mnt2":

           shared            New FS           shared
     -----------------------[A/mnt1]----------------------
    |                           |                         |
    |                bind       |    bind                 |
[C/mnt1]--[slave C]<------[shared A]------>[slave B]--[B/mnt1]
                                                          |
                                                          |
                                                    [B/mnt1/mnt2]
                                                       (New FS)

Signed-off-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 tests/generic/411     | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/411.out |  12 +++++
 tests/generic/group   |   1 +
 3 files changed, 160 insertions(+)
 create mode 100644 tests/generic/411
 create mode 100644 tests/generic/411.out

diff --git a/tests/generic/411 b/tests/generic/411
new file mode 100644
index 00000000..b3e65eac
--- /dev/null
+++ b/tests/generic/411
@@ -0,0 +1,147 @@
+#! /bin/bash
+# FS QA Test 411
+#
+# This test cover linux commit 7ae8fd0, kernel two mnt_group_id == 0
+# (no peer)vfsmount as peers. It case kernel dereference a NULL
+# address.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Red Hat Inc.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+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()
+{
+	cd /
+	rm -f $tmp.*
+	_clear_mount_stack
+}
+
+# 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
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_test
+
+fs_stress()
+{
+	local target=$1
+
+	$FSSTRESS_PROG -z -n 500 -p 5 \
+		       -f creat=5 \
+		       -f mkdir=5 \
+		       -f dwrite=1 \
+		       -f dread=1 \
+		       -f link=2 \
+		       -f rename=1 \
+		       -f rmdir=2 \
+		       -f unlink=1 \
+		       -f symlink=1 \
+		       -f write=1 \
+		       -f read=1 \
+		       -f chown=1 \
+		       -f getdents=1 \
+		       -f fiemap=1 \
+		       -d $target >/dev/null
+	sync
+}
+
+# prepare some mountpoint dir
+MNTHEAD=$TEST_DIR/$seq
+mkdir $MNTHEAD 2>>$seqres.full
+mpA=$MNTHEAD/"$$"_mpA
+mpB=$MNTHEAD/"$$"_mpB
+mpC=$MNTHEAD/"$$"_mpC
+
+find_mnt()
+{
+	echo "------"
+	findmnt -n -o TARGET,SOURCE $SCRATCH_DEV | \
+	    sed -e "s;$mpA;mpA;g" \
+		-e "s;$mpB;mpB;g" \
+		-e "s;$mpC;mpC;g" | \
+	    _filter_spaces | _filter_scratch | \
+	    _filter_test_dir | sort
+	echo "======"
+}
+
+start_test()
+{
+	local type=$1
+
+	_get_mount $SCRATCH_DEV $MNTHEAD
+	mount --make-"${type}" $MNTHEAD
+	rm -rf $mpA $mpB $mpC 2>/dev/null
+	mkdir $mpA $mpB $mpC
+        _scratch_mkfs >$seqres.full 2>&1
+}
+
+end_test()
+{
+	rm -rf $mpA $mpB $mpC 2>/dev/null
+	_clear_mount_stack
+}
+
+#
+#            shared            New FS           shared
+#      -----------------------[A/mnt1]----------------------
+#     |                           |                         |
+#     |                bind       |    bind                 |       New FS
+# [C/mnt1]--[slave C]<------[shared A]------>[slave B]--[B/mnt1]--[B/mnt1/mnt2]
+#
+crash_test()
+{
+    start_test shared
+
+    _get_mount $SCRATCH_DEV $mpA
+    mkdir $mpA/mnt1
+    mount --make-shared $mpA
+    _get_mount --bind $mpA $mpB
+    _get_mount --bind $mpA $mpC
+    mount --make-slave $mpB
+    mount --make-slave $mpC
+    _get_mount $SCRATCH_DEV $mpA/mnt1
+    mkdir $mpA/mnt1/mnt2
+
+    _get_mount $SCRATCH_DEV $mpB/mnt1/mnt2
+    find_mnt
+    fs_stress $mpB/mnt1/mnt2
+
+    end_test
+    echo "crash test passed"
+}
+
+crash_test
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/411.out b/tests/generic/411.out
new file mode 100644
index 00000000..16dadaf2
--- /dev/null
+++ b/tests/generic/411.out
@@ -0,0 +1,12 @@
+QA output created by 411
+------
+TEST_DIR/411 SCRATCH_DEV
+mpA SCRATCH_DEV
+mpA/mnt1 SCRATCH_DEV
+mpB SCRATCH_DEV
+mpB/mnt1 SCRATCH_DEV
+mpB/mnt1/mnt2 SCRATCH_DEV
+mpC SCRATCH_DEV
+mpC/mnt1 SCRATCH_DEV
+======
+crash test passed
diff --git a/tests/generic/group b/tests/generic/group
index 0f9e3b35..fcb4b062 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -413,3 +413,4 @@
 408 auto quick clone dedupe metadata
 409 auto quick mount
 410 auto quick mount
+411 auto quick mount
-- 
2.11.0.rc0.7.gbe5a750


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/4] test multi-level bind and shared subtree mounts
  2017-02-14  0:55 [PATCH 0/4] test multi-level bind and shared subtree mounts Theodore Ts'o
                   ` (3 preceding siblings ...)
  2017-02-14  0:55 ` [PATCH 4/4] generic: new case test two vfsmount no peers Theodore Ts'o
@ 2017-02-14  2:28 ` Zorro Lang
  2017-02-15  9:46 ` Eryu Guan
  5 siblings, 0 replies; 8+ messages in thread
From: Zorro Lang @ 2017-02-14  2:28 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: fstests

On Mon, Feb 13, 2017 at 07:55:41PM -0500, Theodore Ts'o wrote:
> This is a respon if of Zorro Lang's patch set from May 20, 2016.  I've
> reviewed them, and tested them against a recent development kernel.
> 
> The two main changes which I made to Zorro's patches:
> 
>   * I changed the numbers to the most recent unallocated test numbers
>   * I added code to delete the test files in the end_test function

Hi Theodore,

Thanks for your review, too long time passed, I need to read these
code again to recollect something :)

> 
> Zorro Lang (4):
>   common/rc: new functions for multi-level mount/umount operations

Actually, this patch is what I want to improve. I don't know if it's
a good way, I can't find a better way to implement this common/rc
patch, I really need a stack to store mountpoints. Do you have some
better ideas than store them in a simple bash variable?

Thanks,
Zorro

>   generic: new case for test mount bind operation
>   generic: new case for test mount shared subtrees state transition
>   generic: new case test two vfsmount no peers
> 
>  common/rc             |  31 ++
>  tests/generic/409     | 182 +++++++++++
>  tests/generic/409.out | 365 ++++++++++++++++++++++
>  tests/generic/410     | 215 +++++++++++++
>  tests/generic/410.out | 813 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/411     | 147 +++++++++
>  tests/generic/411.out |  12 +
>  tests/generic/group   |   3 +
>  8 files changed, 1768 insertions(+)
>  create mode 100644 tests/generic/409
>  create mode 100644 tests/generic/409.out
>  create mode 100644 tests/generic/410
>  create mode 100644 tests/generic/410.out
>  create mode 100644 tests/generic/411
>  create mode 100644 tests/generic/411.out
> 
> -- 
> 2.11.0.rc0.7.gbe5a750
> 
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/4] test multi-level bind and shared subtree mounts
  2017-02-14  0:55 [PATCH 0/4] test multi-level bind and shared subtree mounts Theodore Ts'o
                   ` (4 preceding siblings ...)
  2017-02-14  2:28 ` [PATCH 0/4] test multi-level bind and shared subtree mounts Zorro Lang
@ 2017-02-15  9:46 ` Eryu Guan
  5 siblings, 0 replies; 8+ messages in thread
From: Eryu Guan @ 2017-02-15  9:46 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: fstests, Zorro Lang

On Mon, Feb 13, 2017 at 07:55:41PM -0500, Theodore Ts'o wrote:
> This is a respon if of Zorro Lang's patch set from May 20, 2016.  I've
> reviewed them, and tested them against a recent development kernel.
> 
> The two main changes which I made to Zorro's patches:
> 
>   * I changed the numbers to the most recent unallocated test numbers
>   * I added code to delete the test files in the end_test function

Thanks a lot!

I have some minor comments and I can fix all of them at commit time.

Thanks,
Eryu

> 
> Zorro Lang (4):
>   common/rc: new functions for multi-level mount/umount operations
>   generic: new case for test mount bind operation
>   generic: new case for test mount shared subtrees state transition
>   generic: new case test two vfsmount no peers
> 
>  common/rc             |  31 ++
>  tests/generic/409     | 182 +++++++++++
>  tests/generic/409.out | 365 ++++++++++++++++++++++
>  tests/generic/410     | 215 +++++++++++++
>  tests/generic/410.out | 813 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/411     | 147 +++++++++
>  tests/generic/411.out |  12 +
>  tests/generic/group   |   3 +
>  8 files changed, 1768 insertions(+)
>  create mode 100644 tests/generic/409
>  create mode 100644 tests/generic/409.out
>  create mode 100644 tests/generic/410
>  create mode 100644 tests/generic/410.out
>  create mode 100644 tests/generic/411
>  create mode 100644 tests/generic/411.out
> 
> -- 
> 2.11.0.rc0.7.gbe5a750
> 
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] generic: new case for test mount bind operation
  2017-02-14  0:55 ` [PATCH 2/4] generic: new case for test mount bind operation Theodore Ts'o
@ 2017-02-15  9:53   ` Eryu Guan
  0 siblings, 0 replies; 8+ messages in thread
From: Eryu Guan @ 2017-02-15  9:53 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: fstests, Zorro Lang

On Mon, Feb 13, 2017 at 07:55:43PM -0500, Theodore Ts'o wrote:
> From: Zorro Lang <zlang@redhat.com>
> 
> This case will do function test for mount bind operation, it will
> verify below semantics:
> 
> ---------------------------------------------------------------------------
> |         BIND MOUNT OPERATION                                            |
> |**************************************************************************
> |source(A)->| shared       |       private  |       slave    | unbindable |
> | dest(B)  |               |                |                |            |
> |   |      |               |                |                |            |
> |   v      |               |                |                |            |
> |**************************************************************************
> |  shared  | shared        |     shared     | shared & slave |  invalid   |
> |          |               |                |                |            |
> |non-shared| shared        |      private   |      slave     |  invalid   |
> ***************************************************************************
> 
> This case use fsstress to produce a little rand load, to sure basic
> operations on the bind mountpoint won't cause hang or panic etc.
> 
> Signed-off-by: Zorro Lang <zlang@redhat.com>
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
> ---
>  tests/generic/409     | 182 +++++++++++++++++++++++++
>  tests/generic/409.out | 365 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/group   |   1 +
>  3 files changed, 548 insertions(+)
>  create mode 100644 tests/generic/409

File mode for new case is better to be 755, so after running tests git
diff won't complain about the mode change.

>  create mode 100644 tests/generic/409.out
> 
> diff --git a/tests/generic/409 b/tests/generic/409
> new file mode 100644
> index 00000000..88bda6c5
> --- /dev/null
> +++ b/tests/generic/409
> @@ -0,0 +1,182 @@
> +#! /bin/bash
> +# FS QA Test 409
> +#
> +# Test mount shared subtrees, verify the bind semantics:
> +#
> +# ---------------------------------------------------------------------------
> +# |         BIND MOUNT OPERATION                                            |
> +# |**************************************************************************
> +# |source(A)->| shared       |       private  |       slave    | unbindable |
> +# | dest(B)  |               |                |                |            |
> +# |   |      |               |                |                |            |
> +# |   v      |               |                |                |            |
> +# |**************************************************************************
> +# |  shared  | shared        |     shared     | shared & slave |  invalid   |
> +# |          |               |                |                |            |
> +# |non-shared| shared        |      private   |      slave     |  invalid   |
> +# ***************************************************************************
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2016 Red Hat Inc.  All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#-----------------------------------------------------------------------
> +#
> +
> +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()
> +{
> +	cd /
> +	rm -f $tmp.*
> +	_clear_mount_stack
> +}
> +
> +# 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
> +_supported_fs generic
> +_supported_os Linux
> +_require_scratch
> +_require_test

Need a "_require_block_device $SCRATCH_DEV", otherwise test on
NFS/overlay etc. will fail, because we assume $SCRATCH_DEV is a block
device.

> +
> +fs_stress()
> +{
> +	local target=$1
> +
> +	$FSSTRESS_PROG -z -n 50 -p 3 \
> +		       -f creat=5 \
> +		       -f mkdir=5 \
> +		       -f link=2 \
> +		       -f rename=1 \
> +		       -f rmdir=2 \
> +		       -f unlink=1 \
> +		       -f symlink=1 \
> +		       -f write=1 \
> +		       -f read=1 \
> +		       -f chown=1 \
> +		       -f getdents=1 \
> +		       -f fiemap=1 \
> +		       -d $target >/dev/null
> +	sync
> +}
> +
> +# prepare some mountpoint dir
> +MNTHEAD=$TEST_DIR/$seq
> +mkdir $MNTHEAD 2>>$seqres.full
> +mpA=$MNTHEAD/"$$"_mpA
> +mpB=$MNTHEAD/"$$"_mpB
> +mpC=$MNTHEAD/"$$"_mpC
> +mpD=$MNTHEAD/"$$"_mpD
> +
> +find_mnt()
> +{
> +	echo "------"
> +	findmnt -n -o TARGET,SOURCE $SCRATCH_DEV | \
> +	    sed -e "s;$mpA;mpA;g" \
> +		-e "s;$mpB;mpB;g" \
> +		-e "s;$mpC;mpC;g" \
> +		-e "s;$mpD;mpD;g" | \
> +	    _filter_spaces | _filter_scratch | \
> +	    _filter_test_dir | sort
> +	echo "======"
> +}
> +
> +start_test()
> +{
> +	local type=$1
> +
> +	_get_mount $SCRATCH_DEV $MNTHEAD
> +	mount --make-"${type}" $MNTHEAD
> +	rm -rf $mpA $mpB $mpC $mpD 2>/dev/null
> +	mkdir $mpA $mpB $mpC $mpD
> +        _scratch_mkfs >$seqres.full 2>&1

We should _scratch_mkfs before mounting $SCRATCH_DEV on $MNTHEAD, and
since the filesystem is newly created, the "rm -rf" line seems not
necessary.

> +}
> +
> +end_test()
> +{
> +	rm -rf $mpA $mpB $mpC $mpD 2>/dev/null
> +	_clear_mount_stack

Unmount all mount points then remove them, otherwise rm always fails
because of "Device is busy".

> +}
> +
> +bind_run()
> +{
> +	local source=$1
> +	local dest=$2
> +
> +	start_test $dest
> +
> +	echo "bind $source on $dest"
> +	_get_mount $SCRATCH_DEV $mpA
> +	mkdir -p $mpA/dir 2>/dev/null
> +	mount --make-shared $mpA
> +	_get_mount --bind $mpA $mpB
> +	mount --make-"$source" $mpB
> +	# maybe unbindable at here
> +	_get_mount --bind $mpB $mpC 2>/dev/null
> +	if [ $? -ne 0 ];then
> +		find_mnt
> +		end_test
> +		return 0
> +	fi
> +	_get_mount --bind $mpC $mpD
> +	for m in $mpA $mpB $mpC $mpD
> +	do
> +		_get_mount $SCRATCH_DEV $m/dir
> +		fs_stress $m/dir
> +		find_mnt
> +		_put_mount
> +	done
> +
> +	end_test
> +}
> +
> +bind_test()
> +{
> +	local dest=$1

dest is not used, can be removed.

The other two tests have similar issues, I'll fix them all.

Thanks,
Eryu

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-02-15  9:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-14  0:55 [PATCH 0/4] test multi-level bind and shared subtree mounts Theodore Ts'o
2017-02-14  0:55 ` [PATCH 1/4] common/rc: new functions for multi-level mount/umount operations Theodore Ts'o
2017-02-14  0:55 ` [PATCH 2/4] generic: new case for test mount bind operation Theodore Ts'o
2017-02-15  9:53   ` Eryu Guan
2017-02-14  0:55 ` [PATCH 3/4] generic: new case for test mount shared subtrees state transition Theodore Ts'o
2017-02-14  0:55 ` [PATCH 4/4] generic: new case test two vfsmount no peers Theodore Ts'o
2017-02-14  2:28 ` [PATCH 0/4] test multi-level bind and shared subtree mounts Zorro Lang
2017-02-15  9:46 ` Eryu Guan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox