2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc. All Rights Reserved.
7 # Test mount shared subtrees, verify the state transition when use:
13 # ------------------------------------------------------------------------
14 # | |make-shared | make-slave | make-private |make-unbindab|
15 # --------------|------------|--------------|--------------|-------------|
16 # |shared |shared |*slave/private| private | unbindable |
18 # |-------------|------------|--------------|--------------|-------------|
19 # |slave |shared | **slave | private | unbindable |
20 # | |and slave | | | |
21 # |-------------|------------|--------------|--------------|-------------|
22 # |shared |shared | slave | private | unbindable |
23 # |and slave |and slave | | | |
24 # |-------------|------------|--------------|--------------|-------------|
25 # |private |shared | **private | private | unbindable |
26 # |-------------|------------|--------------|--------------|-------------|
27 # |unbindable |shared |**unbindable | private | unbindable |
28 # ------------------------------------------------------------------------
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
36 status=1 # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
44 # make sure there's no bug cause dentry isn't be freed
48 # get standard environment, filters and checks
52 # remove previous $seqres.full before test
55 # real QA test starts here
60 _require_local_device $SCRATCH_DEV
66 $FSSTRESS_PROG -z -n 50 -p 3 \
83 # prepare some mountpoint dir
84 MNTHEAD=$TEST_DIR/$seq
86 mkdir $MNTHEAD 2>>$seqres.full
94 findmnt -n -o TARGET,SOURCE $SCRATCH_DEV | \
95 sed -e "s;$mpA;mpA;g" \
98 _filter_spaces | _filter_testdir_and_scratch | sort
106 _scratch_mkfs >$seqres.full 2>&1
107 _get_mount -t $FSTYP $SCRATCH_DEV $MNTHEAD
108 $MOUNT_PROG --make-"${type}" $MNTHEAD
115 rm -rf $mpA $mpB $mpC
120 # command include make-shared/slave/private/unbindable
122 # orginal status include shared/slave/shared&slave/private/unbindable
125 # bind anything on un-shared dest will keep the source type
126 # So use un-shared dest at here
129 echo "make-$cmd a $orgs mount"
130 _get_mount -t $FSTYP $SCRATCH_DEV $mpA
131 mkdir -p $mpA/dir 2>/dev/null
132 $MOUNT_PROG --make-shared $mpA
134 # prepare the original status on mpB
135 _get_mount --bind $mpA $mpB
136 # shared&slave status need to do make-slave then make-shared
139 $MOUNT_PROG --make-"$t" $mpB
142 # "before" for prepare and check original status
143 # "after" for check the impact of make-$cmd command
144 for i in before after; do
145 echo "$i make-$cmd run on $orgs"
146 # maybe unbindable at here
147 _get_mount --bind $mpB $mpC 2>/dev/null
151 for m in $mpA $mpB $mpC; do
152 _get_mount -t $FSTYP $SCRATCH_DEV $m/dir
157 _put_mount # umount C
159 if [ "$i" = "before" ];then
160 $MOUNT_PROG --make-"${cmd}" $mpB
169 # operation original_status
172 run shared "slave shared"
174 run shared unbindable
178 run slave "slave shared"
184 run private "slave shared"
186 run private unbindable
188 run unbindable shared
190 run unbindable "slave shared"
191 run unbindable private
192 run unbindable unbindable