2003-07-14 05:12:23 +00:00
|
|
|
#! /bin/sh
|
2004-06-15 07:32:36 +00:00
|
|
|
# FS QA Test No. 073
|
2003-07-14 05:12:23 +00:00
|
|
|
#
|
|
|
|
|
# Test xfs_copy
|
|
|
|
|
#
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
# Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# creator
|
2003-07-22 02:38:08 +00:00
|
|
|
owner=nathans@sgi.com
|
2003-07-14 05:12:23 +00:00
|
|
|
|
|
|
|
|
seq=`basename $0`
|
|
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
2003-07-22 02:38:08 +00:00
|
|
|
_cleanup()
|
|
|
|
|
{
|
2004-06-15 07:32:36 +00:00
|
|
|
cd /
|
2003-07-22 02:38:08 +00:00
|
|
|
umount $SCRATCH_MNT 2>/dev/null
|
|
|
|
|
umount $tmp.loop 2>/dev/null
|
2006-11-06 02:52:23 +00:00
|
|
|
[ -d $tmp.loop ] && rmdir $tmp.loop
|
2007-06-08 16:24:08 +00:00
|
|
|
[ -d $tmp.source_dir ] && rm -rf $tmp.source_dir
|
2006-11-06 02:52:23 +00:00
|
|
|
rm -f $tmp.* /var/tmp/xfs_copy.log.*
|
2003-07-22 02:38:08 +00:00
|
|
|
}
|
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
|
|
_filter_copy()
|
|
|
|
|
{
|
2006-03-30 03:53:33 +00:00
|
|
|
sed -e "s,$1,<DEVIMAGE>,g" -e "s,$2,<FSIMAGE1>,g" \
|
|
|
|
|
-e "s,$3,<DEVIMAGE>,g" -e "s,$4,<FSIMAGE2>,g"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_filter_path()
|
|
|
|
|
{
|
|
|
|
|
sed -e "s,$1,<MNTPATH>,g" | LC_COLLATE=POSIX sort
|
2003-07-22 02:38:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_populate_scratch()
|
|
|
|
|
{
|
|
|
|
|
POSIXLY_CORRECT=yes \
|
|
|
|
|
dd if=/dev/zero of=$SCRATCH_MNT/big+attr count=1000 bs=4096
|
|
|
|
|
[ "$FAST_POPULATE" = true ] && return
|
|
|
|
|
echo $SCRATCH_MNT/big+attr | $here/src/fill2attr
|
|
|
|
|
$here/src/fill2fs --bytes=1048576 --filesize=4096 --stddev=0 --force \
|
|
|
|
|
--dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_verify_copy()
|
|
|
|
|
{
|
|
|
|
|
target=$1
|
|
|
|
|
target_dir=$tmp.loop
|
|
|
|
|
source=$2
|
|
|
|
|
source_dir=$3
|
|
|
|
|
|
|
|
|
|
[ $source = $SCRATCH_DEV ] && _scratch_mount
|
|
|
|
|
|
|
|
|
|
echo checking new image
|
2004-11-24 13:44:32 +00:00
|
|
|
_check_xfs_filesystem $target none none
|
2003-07-22 02:38:08 +00:00
|
|
|
|
|
|
|
|
echo mounting new image on loopback
|
|
|
|
|
rmdir $target_dir 2>/dev/null
|
|
|
|
|
mkdir $target_dir
|
|
|
|
|
mount -t xfs -o loop $target $target_dir 2>/dev/null
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo retrying mount with nouuid option
|
|
|
|
|
mount -t xfs -o loop -o nouuid $target $target_dir
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo mount failed - evil!
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo comparing new image files to old
|
|
|
|
|
diff -Naur $source_dir $target_dir
|
|
|
|
|
|
|
|
|
|
echo comparing new image directories to old
|
2006-03-30 03:53:33 +00:00
|
|
|
find $source_dir | _filter_path $source_dir > $tmp.manifest1
|
|
|
|
|
find $target_dir | _filter_path $target_dir > $tmp.manifest2
|
2003-07-22 02:38:08 +00:00
|
|
|
[ -s $tmp.manifest1 ] || echo no directory output
|
|
|
|
|
diff -u $tmp.manifest1 $tmp.manifest2
|
|
|
|
|
|
|
|
|
|
echo comparing new image geometry to old
|
|
|
|
|
xfs_info $source_dir \
|
2006-03-30 03:53:33 +00:00
|
|
|
| _filter_copy $source $source_dir '/dev/loop.' '#' \
|
2003-07-22 02:38:08 +00:00
|
|
|
| tr -s ' ' \
|
|
|
|
|
> $tmp.geometry1
|
|
|
|
|
xfs_info $target_dir \
|
2006-03-30 03:53:33 +00:00
|
|
|
| _filter_copy $target $target_dir '/dev/loop.' '#' \
|
2003-07-22 02:38:08 +00:00
|
|
|
| tr -s ' ' \
|
|
|
|
|
> $tmp.geometry2
|
|
|
|
|
[ -s $tmp.geometry1 ] || echo no geometry output
|
|
|
|
|
diff -u $tmp.geometry1 $tmp.geometry2
|
|
|
|
|
|
|
|
|
|
echo unmounting and removing new image
|
|
|
|
|
umount $source $target
|
|
|
|
|
rm -f $target
|
|
|
|
|
}
|
2003-07-14 05:12:23 +00:00
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
|
. ./common.rc
|
|
|
|
|
. ./common.filter
|
|
|
|
|
|
2004-06-15 07:32:36 +00:00
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
_supported_fs xfs
|
|
|
|
|
_supported_os Linux
|
|
|
|
|
|
2003-07-22 02:38:08 +00:00
|
|
|
[ "$USE_EXTERNAL" = yes ] && _notrun "Cannot xfs_copy with external devices"
|
|
|
|
|
[ -x /usr/sbin/xfs_copy ] || _notrun "xfs_copy binary not yet installed"
|
|
|
|
|
|
|
|
|
|
_require_scratch
|
|
|
|
|
_require_loop
|
2003-07-14 05:12:23 +00:00
|
|
|
|
2006-03-30 03:53:33 +00:00
|
|
|
_scratch_mkfs_xfs -dsize=41m,agcount=2 | _filter_mkfs 2>/dev/null
|
2003-07-22 02:38:08 +00:00
|
|
|
_scratch_mount 2>/dev/null || _fail "initial scratch mount failed"
|
2003-07-14 05:12:23 +00:00
|
|
|
|
2003-07-22 02:38:08 +00:00
|
|
|
echo
|
|
|
|
|
echo === populating scratch device
|
|
|
|
|
_populate_scratch
|
|
|
|
|
umount $SCRATCH_MNT 2>/dev/null
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo === copying scratch device to single target
|
2006-03-30 03:53:33 +00:00
|
|
|
xfs_copy $SCRATCH_DEV $tmp.image | _filter_copy '#' $tmp.image '#' '#'
|
2003-07-22 02:38:08 +00:00
|
|
|
_verify_copy $tmp.image $SCRATCH_DEV $SCRATCH_MNT
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo === copying scratch device to single target, duplicate UUID
|
2006-03-30 03:53:33 +00:00
|
|
|
xfs_copy -d $SCRATCH_DEV $tmp.image | _filter_copy '#' $tmp.image '#' '#'
|
2003-07-22 02:38:08 +00:00
|
|
|
_verify_copy $tmp.image $SCRATCH_DEV $SCRATCH_MNT
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo === copying scratch device to single target, large ro device
|
2003-07-25 00:45:59 +00:00
|
|
|
/sbin/mkfs.xfs -dfile,name=$tmp.source,size=100g | _filter_mkfs 2>/dev/null
|
2003-07-22 02:38:08 +00:00
|
|
|
rmdir $tmp.source_dir 2>/dev/null
|
|
|
|
|
mkdir $tmp.source_dir
|
|
|
|
|
mount -t xfs -o loop $tmp.source $tmp.source_dir
|
|
|
|
|
cp -a $here $tmp.source_dir
|
|
|
|
|
mount -t xfs -o remount,ro $tmp.source $tmp.source_dir
|
2006-03-30 03:53:33 +00:00
|
|
|
xfs_copy $tmp.source $tmp.image | _filter_copy '#' $tmp.image '#' '#'
|
2003-07-22 02:38:08 +00:00
|
|
|
_verify_copy $tmp.image $tmp.source $tmp.source_dir
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo === copying scratch device to multiple targets
|
|
|
|
|
xfs_copy -L$tmp.log -b $SCRATCH_DEV $tmp.image1 $tmp.image2 \
|
2006-03-30 03:53:33 +00:00
|
|
|
| _filter_copy '#' $tmp.image1 '#' $tmp.image2
|
2003-07-22 02:38:08 +00:00
|
|
|
_verify_copy $tmp.image1 $SCRATCH_DEV $SCRATCH_MNT
|
|
|
|
|
_verify_copy $tmp.image2 $SCRATCH_DEV $SCRATCH_MNT
|
2003-07-14 05:12:23 +00:00
|
|
|
|
|
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|