8 # Due to the severe brokenness of mount's handling of loopback devices, we
9 # hardcode the loop devices we use for this test. This enables us to clean up
10 # the pieces when we remount the loop device because mount loses all trace of
11 # the fact this is a loop device. Hence to enable us to unmount the hosting
12 # filesystem, we need to manually tear down the relevant loop device. If
13 # mount ever gets fixed then this hack can be removed.
15 #-----------------------------------------------------------------------
16 # Copyright (c) 2000-2003,2008 Silicon Graphics, Inc. All Rights Reserved.
18 # This program is free software; you can redistribute it and/or
19 # modify it under the terms of the GNU General Public License as
20 # published by the Free Software Foundation.
22 # This program is distributed in the hope that it would be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write the Free Software Foundation,
29 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #-----------------------------------------------------------------------
37 echo "QA output created by $seq"
41 status=1 # failure is the default!
43 # get standard environment, filters and checks
47 # don't put fs images in /tmp
53 umount $SCRATCH_MNT 2>/dev/null
54 umount $imgs.loop 2>/dev/null
55 [ -d $imgs.loop ] && rmdir $imgs.loop
56 [ -d $imgs.source_dir ] && rm -rf $imgs.source_dir
57 rm -f $imgs.* $tmp.* /var/tmp/xfs_copy.log.*
59 trap "_cleanup; exit \$status" 0 1 2 3 15
63 sed -e "s,$1,<DEVIMAGE>,g" -e "s,$2,<FSIMAGE1>,g" \
64 -e "s,$3,<DEVIMAGE>,g" -e "s,$4,<FSIMAGE2>,g"
69 sed -e "s,$1,<MNTPATH>,g" | LC_COLLATE=POSIX sort
75 dd if=/dev/zero of=$SCRATCH_MNT/big+attr count=1000 bs=4096
76 [ "$FAST_POPULATE" = true ] && return
77 echo $SCRATCH_MNT/big+attr | $here/src/fill2attr
78 $here/src/fill2fs --bytes=1048576 --filesize=4096 --stddev=0 --force \
79 --dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest
89 [ $source = $SCRATCH_DEV ] && _scratch_mount
91 echo checking new image
92 _check_xfs_filesystem $target none none
94 echo mounting new image on loopback
95 rmdir $target_dir 2>/dev/null
98 mount -t xfs -o loop $target $target_dir 2>/dev/null
100 echo retrying mount with nouuid option
101 mount -t xfs -o loop -o nouuid $target $target_dir
102 if [ $? -ne 0 ]; then
103 echo mount failed - evil!
108 echo comparing new image files to old
109 diff -Naur $source_dir $target_dir
111 echo comparing new image directories to old
112 find $source_dir | _filter_path $source_dir > $tmp.manifest1
113 find $target_dir | _filter_path $target_dir > $tmp.manifest2
114 [ -s $tmp.manifest1 ] || echo no directory output
115 diff -u $tmp.manifest1 $tmp.manifest2
117 echo comparing new image geometry to old
118 xfs_info $source_dir \
119 | _filter_copy $source $source_dir '/dev/loop.' '#' \
122 xfs_info $target_dir \
123 | _filter_copy $target $target_dir '/dev/loop.' '#' \
126 [ -s $tmp.geometry1 ] || echo no geometry output
127 diff -u $tmp.geometry1 $tmp.geometry2
129 echo unmounting and removing new image
130 loop=`mount | grep $target | grep -o -e 'loop=.*[^),]' | grep -o -e '/.*$'`
131 umount $source $target
132 losetup -d $loop > /dev/null 2>&1
137 # real QA test starts here
141 [ "$USE_EXTERNAL" = yes ] && _notrun "Cannot xfs_copy with external devices"
142 [ -x /usr/sbin/xfs_copy ] || _notrun "xfs_copy binary not yet installed"
147 _scratch_mkfs_xfs -dsize=41m,agcount=2 | _filter_mkfs 2>/dev/null
148 _scratch_mount 2>/dev/null || _fail "initial scratch mount failed"
151 echo === populating scratch device
153 umount $SCRATCH_MNT 2>/dev/null
156 echo === copying scratch device to single target
157 xfs_copy $SCRATCH_DEV $imgs.image | _filter_copy '#' $imgs.image '#' '#'
158 _verify_copy $imgs.image $SCRATCH_DEV $SCRATCH_MNT
161 echo === copying scratch device to single target, duplicate UUID
162 xfs_copy -d $SCRATCH_DEV $imgs.image | _filter_copy '#' $imgs.image '#' '#'
163 _verify_copy $imgs.image $SCRATCH_DEV $SCRATCH_MNT
166 echo === copying scratch device to single target, large ro device
167 /sbin/mkfs.xfs -dfile,name=$imgs.source,size=100g | _filter_mkfs 2>/dev/null
168 rmdir $imgs.source_dir 2>/dev/null
169 mkdir $imgs.source_dir
171 mount -t xfs -o loop $imgs.source $imgs.source_dir
172 loop2=`mount | grep $imgs.source | grep -o -e 'loop=.*[^),]' | grep -o -e '/.*$'`
173 cp -a $here $imgs.source_dir
174 mount -t xfs -o remount,ro $imgs.source $imgs.source_dir
175 xfs_copy $imgs.source $imgs.image | _filter_copy '#' $imgs.image '#' '#'
176 _verify_copy $imgs.image $imgs.source $imgs.source_dir
180 # We're done with the nested loop mount, now we have to clean
181 # up the pieces that mount is incapable of doing.
182 losetup -d $loop2 > /dev/null 2>&1
185 echo === copying scratch device to multiple targets
186 xfs_copy -L$imgs.log -b $SCRATCH_DEV $imgs.image1 $imgs.image2 \
187 | _filter_copy '#' $imgs.image1 '#' $imgs.image2
188 _verify_copy $imgs.image1 $SCRATCH_DEV $SCRATCH_MNT
189 _verify_copy $imgs.image2 $SCRATCH_DEV $SCRATCH_MNT