4 # Test mount shared subtrees, verify the state transition when use:
10 # ------------------------------------------------------------------------
11 # | |make-shared | make-slave | make-private |make-unbindab|
12 # --------------|------------|--------------|--------------|-------------|
13 # |shared |shared |*slave/private| private | unbindable |
15 # |-------------|------------|--------------|--------------|-------------|
16 # |slave |shared | **slave | private | unbindable |
17 # | |and slave | | | |
18 # |-------------|------------|--------------|--------------|-------------|
19 # |shared |shared | slave | private | unbindable |
20 # |and slave |and slave | | | |
21 # |-------------|------------|--------------|--------------|-------------|
22 # |private |shared | **private | private | unbindable |
23 # |-------------|------------|--------------|--------------|-------------|
24 # |unbindable |shared |**unbindable | private | unbindable |
25 # ------------------------------------------------------------------------
27 #-----------------------------------------------------------------------
28 # Copyright (c) 2016 Red Hat Inc. All Rights Reserved.
30 # This program is free software; you can redistribute it and/or
31 # modify it under the terms of the GNU General Public License as
32 # published by the Free Software Foundation.
34 # This program is distributed in the hope that it would be useful,
35 # but WITHOUT ANY WARRANTY; without even the implied warranty of
36 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 # GNU General Public License for more details.
39 # You should have received a copy of the GNU General Public License
40 # along with this program; if not, write the Free Software Foundation,
41 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
42 #-----------------------------------------------------------------------
46 seqres=$RESULT_DIR/$seq
47 echo "QA output created by $seq"
51 status=1 # failure is the default!
52 trap "_cleanup; exit \$status" 0 1 2 3 15
59 # make sure there's no bug cause dentry isn't be freed
63 # get standard environment, filters and checks
67 # remove previous $seqres.full before test
70 # real QA test starts here
75 _require_local_device $SCRATCH_DEV
81 $FSSTRESS_PROG -z -n 50 -p 3 \
98 # prepare some mountpoint dir
99 MNTHEAD=$TEST_DIR/$seq
101 mkdir $MNTHEAD 2>>$seqres.full
102 mpA=$MNTHEAD/"$$"_mpA
103 mpB=$MNTHEAD/"$$"_mpB
104 mpC=$MNTHEAD/"$$"_mpC
109 findmnt -n -o TARGET,SOURCE $SCRATCH_DEV | \
110 sed -e "s;$mpA;mpA;g" \
112 -e "s;$mpC;mpC;g" | \
113 _filter_spaces | _filter_scratch | \
114 _filter_test_dir | sort
122 _scratch_mkfs >$seqres.full 2>&1
123 _get_mount -t $FSTYP $SCRATCH_DEV $MNTHEAD
124 $MOUNT_PROG --make-"${type}" $MNTHEAD
131 rm -rf $mpA $mpB $mpC
136 # command include make-shared/slave/private/unbindable
138 # orginal status include shared/slave/shared&slave/private/unbindable
141 # bind anything on un-shared dest will keep the source type
142 # So use un-shared dest at here
145 echo "make-$cmd a $orgs mount"
146 _get_mount -t $FSTYP $SCRATCH_DEV $mpA
147 mkdir -p $mpA/dir 2>/dev/null
148 $MOUNT_PROG --make-shared $mpA
150 # prepare the original status on mpB
151 _get_mount --bind $mpA $mpB
152 # shared&slave status need to do make-slave then make-shared
155 $MOUNT_PROG --make-"$t" $mpB
158 # "before" for prepare and check original status
159 # "after" for check the impact of make-$cmd command
160 for i in before after; do
161 echo "$i make-$cmd run on $orgs"
162 # maybe unbindable at here
163 _get_mount --bind $mpB $mpC 2>/dev/null
167 for m in $mpA $mpB $mpC; do
168 _get_mount -t $FSTYP $SCRATCH_DEV $m/dir
173 _put_mount # umount C
175 if [ "$i" = "before" ];then
176 $MOUNT_PROG --make-"${cmd}" $mpB
185 # operation original_status
188 run shared "slave shared"
190 run shared unbindable
194 run slave "slave shared"
200 run private "slave shared"
202 run private unbindable
204 run unbindable shared
206 run unbindable "slave shared"
207 run unbindable private
208 run unbindable unbindable