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.
17 #-----------------------------------------------------------------------
23 echo "QA output created by $seq"
27 status=1 # failure is the default!
29 # get standard environment, filters and checks
33 # don't put fs images in /tmp
39 umount $SCRATCH_MNT 2>/dev/null
40 umount $imgs.loop 2>/dev/null
41 [ -d $imgs.loop ] && rmdir $imgs.loop
42 [ -d $imgs.source_dir ] && rm -rf $imgs.source_dir
43 rm -f $imgs.* $tmp.* /var/tmp/xfs_copy.log.*
45 trap "_cleanup; exit \$status" 0 1 2 3 15
49 sed -e "s,$1,<DEVIMAGE>,g" -e "s,$2,<FSIMAGE1>,g" \
50 -e "s,$3,<DEVIMAGE>,g" -e "s,$4,<FSIMAGE2>,g"
55 sed -e "s,$1,<MNTPATH>,g" | LC_COLLATE=POSIX sort
61 dd if=/dev/zero of=$SCRATCH_MNT/big+attr count=1000 bs=4096
62 [ "$FAST_POPULATE" = true ] && return
63 echo $SCRATCH_MNT/big+attr | $here/src/fill2attr
64 $here/src/fill2fs --bytes=1048576 --filesize=4096 --stddev=0 --force \
65 --dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest
75 [ $source = $SCRATCH_DEV ] && _scratch_mount
77 echo checking new image
78 _check_xfs_filesystem $target none none
80 echo mounting new image on loopback
81 rmdir $target_dir 2>/dev/null
84 mount -t xfs -o loop $target $target_dir 2>/dev/null
86 echo retrying mount with nouuid option
87 mount -t xfs -o loop -o nouuid $target $target_dir
89 echo mount failed - evil!
94 echo comparing new image files to old
95 diff -Naur $source_dir $target_dir
97 echo comparing new image directories to old
98 find $source_dir | _filter_path $source_dir > $tmp.manifest1
99 find $target_dir | _filter_path $target_dir > $tmp.manifest2
100 [ -s $tmp.manifest1 ] || echo no directory output
101 diff -u $tmp.manifest1 $tmp.manifest2
103 echo comparing new image geometry to old
104 xfs_info $source_dir \
105 | _filter_copy $source $source_dir '/dev/loop.' '#' \
108 xfs_info $target_dir \
109 | _filter_copy $target $target_dir '/dev/loop.' '#' \
112 [ -s $tmp.geometry1 ] || echo no geometry output
113 diff -u $tmp.geometry1 $tmp.geometry2
115 echo unmounting and removing new image
116 loop=`mount | grep $target | grep -o -e 'loop=.*[^),]' | grep -o -e '/.*$'`
117 umount $source $target
118 losetup -d $loop > /dev/null 2>&1
123 # real QA test starts here
127 [ "$USE_EXTERNAL" = yes ] && _notrun "Cannot xfs_copy with external devices"
128 [ -x /usr/sbin/xfs_copy ] || _notrun "xfs_copy binary not yet installed"
133 _scratch_mkfs_xfs -dsize=41m,agcount=2 | _filter_mkfs 2>/dev/null
134 _scratch_mount 2>/dev/null || _fail "initial scratch mount failed"
137 echo === populating scratch device
139 umount $SCRATCH_MNT 2>/dev/null
142 echo === copying scratch device to single target
143 xfs_copy $SCRATCH_DEV $imgs.image | _filter_copy '#' $imgs.image '#' '#'
144 _verify_copy $imgs.image $SCRATCH_DEV $SCRATCH_MNT
147 echo === copying scratch device to single target, duplicate UUID
148 xfs_copy -d $SCRATCH_DEV $imgs.image | _filter_copy '#' $imgs.image '#' '#'
149 _verify_copy $imgs.image $SCRATCH_DEV $SCRATCH_MNT
152 echo === copying scratch device to single target, large ro device
153 /sbin/mkfs.xfs -dfile,name=$imgs.source,size=100g | _filter_mkfs 2>/dev/null
154 rmdir $imgs.source_dir 2>/dev/null
155 mkdir $imgs.source_dir
157 mount -t xfs -o loop $imgs.source $imgs.source_dir
158 loop2=`mount | grep $imgs.source | grep -o -e 'loop=.*[^),]' | grep -o -e '/.*$'`
159 cp -a $here $imgs.source_dir
160 mount -t xfs -o remount,ro $imgs.source $imgs.source_dir
161 xfs_copy $imgs.source $imgs.image | _filter_copy '#' $imgs.image '#' '#'
162 _verify_copy $imgs.image $imgs.source $imgs.source_dir
166 # We're done with the nested loop mount, now we have to clean
167 # up the pieces that mount is incapable of doing.
168 losetup -d $loop2 > /dev/null 2>&1
171 echo === copying scratch device to multiple targets
172 xfs_copy -L$imgs.log -b $SCRATCH_DEV $imgs.image1 $imgs.image2 \
173 | _filter_copy '#' $imgs.image1 '#' $imgs.image2
174 _verify_copy $imgs.image1 $SCRATCH_DEV $SCRATCH_MNT
175 _verify_copy $imgs.image2 $SCRATCH_DEV $SCRATCH_MNT