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
59 _require_local_device $SCRATCH_DEV
65 $FSSTRESS_PROG -z -n 50 -p 3 \
82 # prepare some mountpoint dir
83 MNTHEAD=$TEST_DIR/$seq
85 mkdir $MNTHEAD 2>>$seqres.full
93 findmnt -n -o TARGET,SOURCE $SCRATCH_DEV | \
94 sed -e "s;$mpA;mpA;g" \
97 _filter_spaces | _filter_testdir_and_scratch | sort
105 _scratch_mkfs >$seqres.full 2>&1
106 _get_mount -t $FSTYP $SCRATCH_DEV $MNTHEAD
107 $MOUNT_PROG --make-"${type}" $MNTHEAD
114 rm -rf $mpA $mpB $mpC
119 # command include make-shared/slave/private/unbindable
121 # orginal status include shared/slave/shared&slave/private/unbindable
124 # bind anything on un-shared dest will keep the source type
125 # So use un-shared dest at here
128 echo "make-$cmd a $orgs mount"
129 _get_mount -t $FSTYP $SCRATCH_DEV $mpA
130 mkdir -p $mpA/dir 2>/dev/null
131 $MOUNT_PROG --make-shared $mpA
133 # prepare the original status on mpB
134 _get_mount --bind $mpA $mpB
135 # shared&slave status need to do make-slave then make-shared
138 $MOUNT_PROG --make-"$t" $mpB
141 # "before" for prepare and check original status
142 # "after" for check the impact of make-$cmd command
143 for i in before after; do
144 echo "$i make-$cmd run on $orgs"
145 # maybe unbindable at here
146 _get_mount --bind $mpB $mpC 2>/dev/null
150 for m in $mpA $mpB $mpC; do
151 _get_mount -t $FSTYP $SCRATCH_DEV $m/dir
156 _put_mount # umount C
158 if [ "$i" = "before" ];then
159 $MOUNT_PROG --make-"${cmd}" $mpB
168 # operation original_status
171 run shared "slave shared"
173 run shared unbindable
177 run slave "slave shared"
183 run private "slave shared"
185 run private unbindable
187 run unbindable shared
189 run unbindable "slave shared"
190 run unbindable private
191 run unbindable unbindable