3 # Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it would be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 # Functions useful for xfsdump/xfsrestore tests
22 # --- initializations ---
25 if [ -n "$DEBUGDUMP" ]; then
30 # Use dump/restore in qa directory (copy them here) for debugging
31 export PATH="$here:$PATH"
32 export __XFSDUMP_PROG="`set_prog_path xfsdump`"
33 export XFSDUMP_PROG="$__XFSDUMP_PROG -e"
34 export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
35 export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
36 [ -x $here/xfsdump ] && echo "Using xfstests' xfsdump for debug"
37 [ -x $here/xfsrestore ] && echo "Using xfstests' xfsrestore for debug"
38 [ -x $here/xfsinvutil ] && echo "Using xfstests' xfsinvutil for debug"
41 [ "$XFSDUMP_PROG" = "" ] && _notrun "xfsdump not found"
42 [ "$XFSRESTORE_PROG" = "" ] && _notrun "xfsrestore not found"
43 [ "$XFSINVUTIL_PROG" = "" ] && _notrun "xfsinvutil not found"
45 # status returned for not run tests
48 # name those directories
49 dump_file=$tmp.dumpfile
50 # dump_file=$here/dumpfile #TEMP OVERRIDE DUMP FILE
52 dump_dir=$SCRATCH_MNT/$dump_sdir
53 restore_sdir=restoredir
54 restore_dir=$SCRATCH_MNT/$restore_sdir
57 media_label="stress_tape_media"
58 session_label="stress_$seq"
60 nobody=4 # define this uid/gid as a number
61 do_quota_check=true # do quota check if quotas enabled
66 trap "_cleanup; exit \$status" 0 1 2 3 15
68 # start inventory from a known base - move it aside for test
69 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
71 [ -d $dir.$seq ] && rm -rf $dir.$seq
77 [ `uname` = "Linux" ] && have_mtvariable=true
80 _require_multi_stream()
82 $XFSDUMP_PROG -JF -f /dev/null -f /dev/null 2> /dev/null |
83 grep -q "too many -f arguments" &&
84 _notrun "xfsdump multi-stream support required"
87 _require_legacy_v2_format()
90 grep -q "generate format 2 dump" ||
91 _notrun "xfsdump -K option required"
93 $XFSRESTORE_PROG 2>&1 |
94 grep -q "force use of format 2 generation" ||
95 _notrun "xfsrestore -K option required"
99 # do a remote/local mt
106 _rmtdev=`echo $dumptape | $AWK_PROG -F: '{print $2}'`
108 if echo $dumptape | grep '@' >/dev/null; then
109 _spec=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
110 _rmtuser=`echo $_spec | $AWK_PROG -F@ '{print $1}'`
111 _rmthost=`echo $_spec | $AWK_PROG -F@ '{print $2}'`
112 rsh -n -l $_rmtuser $_rmthost "mt -t $_rmtdev $op"
114 _rmthost=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
115 rsh -n $_rmthost "mt -t $_rmtdev $op"
127 while [ $i -lt $_limit ]; do
128 echo "Checking online..." >>$seqres.full
129 if _mt status >$tmp.status 2>&1; then
138 if [ $i -eq $_limit ]; then
139 echo "ERROR: mt -f $dumptape failed"
142 _notrun "mt -f $dumptape failed"
146 if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
149 echo "ERROR: $dumptape is not online"
152 _notrun "dumptape, $dumptape, is not online"
158 echo "Wait for tape, $dumptape, ..." >>$seqres.full
161 while [ $i -lt 20 ]; do
162 echo "Checking status..." >>$seqres.full
163 if _mt status 2>&1 | tee -a $seqres.full | egrep -i "onl|ready" >/dev/null; then
173 # Keep trying so we know we really have rewound
177 echo "Initiate rewind..." >>$seqres.full
179 _mt rewind >/dev/null
184 # Do a custom erase because:
185 # (i) some machines don't support it
186 # (ii) some machines take forever to do it
190 echo "Erasing tape" | tee -a $seqres.full
198 echo "Erasing tape" | tee -a $seqres.full
204 echo $dumptape | grep ':' >/dev/null
212 $have_mtvariable || return
218 echo "Put scsi tape driver into variable block size mode"
219 mt -f $dumptape setblk 0
227 if [ -z "$dumptape" -o "@" == "$dumptape" ]; then
228 _notrun "No dump tape specified"
239 _scratch_mkfs_xfs >>$seqres.full || _fail "mkfs failed"
240 _scratch_mount >>$seqres.full || _fail "mount failed"
244 # Cleanup created dirs and files
249 # Some tests include this before checking _supported_fs xfs
250 # and the sleeps & checks here get annoying
251 if [ "$FSTYP" != "xfs" ]; then
258 if [ -n "$DEBUGDUMP" ]; then
259 # save it for inspection
260 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
261 [ -d $dir ] || continue
262 tar -cvf $seqres.inventory.tar $dir
263 ls -nR $dir >$seqres.inventory.ls
267 # put inventory dir back
268 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
269 [ -d $dir.$seq ] || continue
270 rm -rf $dir # get rid of new one
274 if [ $status -ne $NOTRUNSTS ]; then
275 # Sleep added to stop _check_scratch_fs from complaining that the
276 # scratch_dev is still busy
284 # ensure that bulkstat data will
285 # match with incore data
286 # by forcing disk data to be written out
290 _saveddir=`pwd`; cd /
291 umount $SCRATCH_MNT >>$seqres.full || _fail "unmount failed"
292 _scratch_mount >>$seqres.full || _fail "mount failed"
297 # Run fsstress to create a mixture of
298 # files,dirs,links,symlinks
300 # Pinched from test 013.
301 # Takes one argument, the number of ops to perform
303 _create_dumpdir_stress_num()
305 echo "Creating directory system to dump using fsstress."
310 _param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
312 if ! mkdir $dump_dir; then
313 echo " failed to mkdir $dump_dir"
318 echo "-----------------------------------------------"
319 echo "fsstress : $_param"
320 echo "-----------------------------------------------"
321 if ! $here/ltp/fsstress $_param -s 1 $FSSTRESS_AVOID -n $_count -d $dump_dir >$tmp.out 2>&1
323 echo " fsstress (count=$_count) returned $? - see $seqres.full"
325 echo "--------------------------------------" >>$seqres.full
326 echo "output from fsstress:" >>$seqres.full
327 echo "--------------------------------------" >>$seqres.full
328 cat $tmp.out >>$seqres.full
335 _create_dumpdir_stress() {
336 _create_dumpdir_stress_num 240
341 cat <<End-of-File >$tmp.config
342 # pathname size in bytes owner group
344 small 10 $nobody $nobody
345 big 102400 daemon sys
347 sub/big 102400 $nobody sys
349 sub/a 1 $nobody $nobody
350 sub/b 2 $nobody $nobody
351 sub/c 4 $nobody $nobody
352 sub/d 8 $nobody $nobody
353 sub/e 16 $nobody $nobody
354 sub/f 32 $nobody $nobody
355 sub/g 64 $nobody $nobody
356 sub/h 128 $nobody $nobody
357 sub/i 256 $nobody $nobody
358 sub/j 512 $nobody $nobody
359 sub/k 1024 $nobody $nobody
360 sub/l 2048 $nobody $nobody
361 sub/m 4096 $nobody $nobody
362 sub/n 8192 $nobody $nobody
364 sub/a00 100 $nobody $nobody
365 sub/b00 200 $nobody $nobody
366 sub/c00 400 $nobody $nobody
367 sub/d00 800 $nobody $nobody
368 sub/e00 1600 $nobody $nobody
369 sub/f00 3200 $nobody $nobody
370 sub/g00 6400 $nobody $nobody
371 sub/h00 12800 $nobody $nobody
372 sub/i00 25600 $nobody $nobody
373 sub/j00 51200 $nobody $nobody
374 sub/k00 102400 $nobody $nobody
375 sub/l00 204800 $nobody $nobody
376 sub/m00 409600 $nobody $nobody
377 sub/n00 819200 $nobody $nobody
379 sub/a000 1000 $nobody $nobody
380 sub/e000 16000 $nobody $nobody
381 sub/h000 128000 $nobody $nobody
382 sub/k000 1024000 $nobody $nobody
388 cat <<End-of-File >$tmp.config
389 # pathname size in bytes
391 smalll 10 $nobody $nobody
392 biggg 102400 $nobody $nobody
393 sub/smalll 10 $nobody $nobody
394 sub/biggg 102400 $nobody $nobody
398 _mk_fillconfig_perm()
400 # dir_guid: ugo=rwx,g+s on dir is for IRIX chmod(1)
402 cat <<End-of-File >$tmp.config
403 # pathname size/dir user group mode
405 file_suid 10 $nobody $nobody 04777
406 file_guid 10 $nobody $nobody 02777
407 file_sticky 10 $nobody $nobody 01777
408 file_mix1 10 $nobody $nobody 761
409 file_mix2 10 $nobody $nobody 642
410 dir_suid d $nobody $nobody 04777
411 dir_guid d $nobody $nobody ugo=rwx,g+s
412 dir_sticky d $nobody $nobody 01777
413 dir_mix1 d $nobody $nobody 761
414 dir_mix2 d $nobody $nobody 642
420 cat <<End-of-File >$tmp.config
421 # pathname size user group perm name value namespace
423 smalll 10 $nobody $nobody 777 attr1 some_text user
424 biggg 102400 $nobody $nobody 777 attr2 some_text2 root
425 sub/smalll 10 $nobody $nobody 777 attr3 some_text3 user
426 sub/biggg 102400 $nobody $nobody 777 attr4 some_text4 root
427 dir d $nobody $nobody 777 attr5 dir_text user
429 # Add more files so that there are more than the number
431 # There are bugs in dump/restore for # non-dir files < # streams
432 # It can be tested in another configuration.
433 # It is a pathalogical case.
435 sub/a 1 $nobody $nobody
436 sub/b 2 $nobody $nobody
437 sub/c 4 $nobody $nobody
438 sub/d 8 $nobody $nobody
439 sub/e 16 $nobody $nobody
440 sub/f 32 $nobody $nobody
441 sub/g 64 $nobody $nobody
442 sub/h 128 $nobody $nobody
443 sub/i 256 $nobody $nobody
444 sub/j 512 $nobody $nobody
445 sub/k 1024 $nobody $nobody
446 sub/l 2048 $nobody $nobody
447 sub/m 4096 $nobody $nobody
448 sub/n 8192 $nobody $nobody
453 # extended file attribute flags
455 _mk_fillconfig_xattr()
457 cat <<End-of-File >$tmp.config
458 # pathname size user group perm name
460 xflag_realtime 10 $nobody $nobody 777 XFS_XFLAG_REALTIME
461 xflag_prealloc 10 $nobody $nobody 777 XFS_XFLAG_PREALLOC
462 xflag_immutable 10 $nobody $nobody 777 XFS_XFLAG_IMMUTABLE
463 xflag_append 10 $nobody $nobody 777 XFS_XFLAG_APPEND
464 xflag_sync 10 $nobody $nobody 777 XFS_XFLAG_SYNC
465 xflag_noatime 10 $nobody $nobody 777 XFS_XFLAG_NOATIME
466 xflag_nodump 10 $nobody $nobody 777 XFS_XFLAG_NODUMP
467 xflag_hasattr 10 $nobody $nobody 777 XFS_XFLAG_HASATTR
472 # Create a bunch of directories/files of different sizes
475 # Pinched from test 001.
477 _do_create_dumpdir_fill()
479 echo "Creating directory system to dump using src/fill."
481 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
484 $verbose && echo -n "Setup "
485 sed -e '/^#/d' $tmp.config \
486 | while read file nbytes owner group perms ea_name ea_value namespace
488 if [ $nbytes = "d" ]; then
498 echo "Error: cannot mkdir \"$dir\""
503 # create a directory/file
514 echo "Error: cannot mkdir \"$dir\""
520 if $here/src/fill $file $file $nbytes
525 echo "Error: cannot create \"$file\""
529 if [ -n "$owner" -a -n "$group" ]; then
530 chown $owner.$group $file
532 if [ -n "$perms" ]; then
536 # extended attributes (EA)
537 if [ -n "$ea_name" -a -n "$ea_value" ]; then
538 if [ "X$namespace" = "Xroot" ]; then
539 attr -R -s $ea_name -V $ea_value $file
541 attr -s $ea_name -V $ea_value $file
543 # extended file attribute flags - no value - NOT EAs
544 elif [ -n "$ea_name" -a -z "$ea_value" ]; then
547 # use xfs_io to send the ioctl
550 $verbose && echo -n "."
557 _mk_fillconfig_multi()
560 cat <<End-of-File >>$tmp.config
561 # pathname size in bytes
563 large000 8874368 $nobody $nobody
564 large111 2582912 $nobody $nobody
565 large222 7825792 $nobody $nobody
569 _create_dumpdir_largefile()
572 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
573 _largesize=4294967297
574 _largefile=$dump_dir/largefile
575 echo "dd a largefile at offset $_largesize"
576 POSIXLY_CORRECT=yes \
577 dd if=/dev/zero of=$_largefile bs=1 seek=$_largesize count=10 2>&1
581 _create_dumpdir_fill()
585 _do_create_dumpdir_fill
589 _create_dumpdir_fill2()
593 _do_create_dumpdir_fill
597 _create_dumpdir_fill_perm()
601 _do_create_dumpdir_fill
605 _create_dumpdir_fill_ea()
609 _do_create_dumpdir_fill
614 # Create enough files, and a few large enough files, so that
615 # some files are likely to be split across streams.
617 _create_dumpdir_fill_multi()
621 _do_create_dumpdir_fill
626 # Append a subset of the fill'ed files
627 # So we can see if just these get dumped on an incremental
629 _append_dumpdir_fill()
632 cat <<End-of-File >$tmp.config
642 sed -e '/^#/d' $tmp.config \
645 echo 'Extra text' >>$file
652 _do_create_dump_symlinks()
654 echo "Creating directory system of symlinks to dump."
656 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
659 $verbose && echo -n "Setup "
660 sed -e '/^#/d' $tmp.config \
661 | while read file nbytes owner group owner2 group2 perms perms2
673 echo "Error: cannot mkdir \"$dir\""
681 # Do chmod on symlink using umask.
682 # This won't do the right thing as it subtracts permissions.
683 # However, I don't care, as long as I get some different perms
685 if [ -n "$perms2" ]; then
689 ln -s $file $file-link
690 if [ -n "$perms2" ]; then
694 if [ -n "$owner" -a -n "$group" ]; then
695 chown $owner.$group $file
697 if [ -n "$owner" -a -n "$group" ]; then
698 chown -h $owner.$group $file-link
700 if [ -n "$perms" ]; then
703 $verbose && echo -n "."
712 cat <<End-of-File >$tmp.config
713 # path size owner1 group1 owner2 group2 perm1 perm2
715 a 0 $nobody $nobody daemon sys 124 421
716 b 0 daemon sys bin bin 347 743
717 sub/a 0 bin bin $nobody sys 777 777
718 sub/b 0 $nobody sys $nobody $nobody 367 763
722 _create_dumpdir_symlinks()
726 _do_create_dump_symlinks
731 # create hardlinks of form $_fname, $_fname_h1 $_fname_h2 ...
740 while [ $_j -le $_numlinks ]; do
742 _hardlink=$_fname$_suffix
743 echo "creating hardlink $_hardlink to $_fname"
744 ln $_fname $_hardlink
750 # create a set of hardlinks
751 # create hardlinks of form file1, file1_h1 file1_h2 ...
752 # create hardlinks of form file2, file2_h1 file2_h2 ...
753 # create hardlinks of form file3, file3_h1 file3_h2 ...
759 while [ $_i -le $_numsets ]; do
760 _create_hardlinks file$_i 5
769 echo "mod level $_level" >$dump_dir/file$_level
772 _create_dumpdir_hardlinks()
776 echo "Creating directory system of hardlinks to incrementally dump."
778 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
781 _create_hardset $_numsets
789 # Filter out times and dates on symlinks and char devices.
790 # Filter out size on directories because this can differ
791 # when transitioning to long inode numbers (ie. 64 bits).
796 /^l/ { date = $8; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
797 /^c/ { date = $9; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
798 /^d/ { size = $5; sub(size,"SIZE"); print}
800 | sed -e 's/total [0-9][0-9]*/total TOTAL/'
804 # Filtering of Irix character hwgraph device names
806 # chardev: /hw/node/xtalk/15/pci/0/scsi_ctlr/0/target/1/lun/0/disk/partition/4/char
807 # blkdev: /dev/dsk/dks0d1s4
813 sub(/\/hw.*scsi_ctlr\//,"/dev/dsk/dks") # blah blah /dev/dsk/dks0/target/1/....
814 sub(/\/target\//,"d") # blah blah /dev/dsk/dks0d1/lun/0/disk.....
815 sub(/\/lun.*partition\//,"s") # blah blah /dev/dsk/dks0d1s4/char
816 sub(/\/char/,"") # blah blah /dev/dsk/dks0d1s4
824 # Filter out the non-deterministic dump msgs from
825 # xfsdump and xfsrestore
831 -e "s#$__XFSDUMP_PROG#xfsdump#" \
832 -e "s#$XFSRESTORE_PROG#xfsrestore#" \
833 -e "s#$XFSINVUTIL_PROG#xfsinvutil#" \
834 -e "s/`hostname`/HOSTNAME/" \
835 -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
836 -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
837 -e "s#$dumptape#TAPE_DEV#" \
838 -e "s#$SCRATCH_MNT#SCRATCH_MNT#" \
839 -e "s#$dump_file#DUMP_FILE#" \
840 -e 's#/var/lib/xfsdump#/var/xfsdump#' \
841 -e 's/session id:[ ]*[0-9a-f-]*/session id: ID/' \
842 -e '/filesystem id:[ ]*[0-9a-f-]*/d' \
843 -e 's/time:[ ].*/time: TIME/' \
844 -e 's/date:[ ].*/date: DATE/' \
845 -e 's/dump begun .*/dump begun DATE/' \
846 -e 's/previously begun .*/previously begun DATE/' \
847 -e 's/[0-9][0-9]* seconds/SECS seconds/' \
848 -e 's/restore.[0-9][0-9]*/restore.PID/' \
849 -e 's/ino [0-9][0-9]*/ino INO/g' \
850 -e '/stream [0-9]:/s/offset [0-9][0-9]*/offset NUM/g' \
851 -e '/: dump size/s/[0-9][0-9]*/NUM/' \
852 -e '/dump size:/s/[0-9][0-9]*/NUM/' \
853 -e '/dump size per stream:/s/[0-9][0-9]*/NUM/' \
854 -e 's/\(media file size[ ]*\)[0-9][0-9]*/\1NUM/' \
855 -e 's/\(mfile size:[ ]*\)[0-9][0-9]*/\1NUM/' \
856 -e '/drive[ ]*[0-9][0-9]*:/d' \
858 -e '/inventory session uuid/d' \
859 -e '/ - Running single-threaded/d' \
860 -e '/Mount point match/d' \
861 -e '/^.*I\/O metrics: .*$/d' \
862 -e 's/1048576/BLOCKSZ/' \
863 -e 's/2097152/BLOCKSZ/' \
864 -e 's/(pid[ ]*[1-9][0-9]*)/\(pid PID\)/' \
865 -e '/version [3-9]\.[0-9]/d' \
866 -e 's/\/hw\/module.*$/SCRATCH_DEV/' \
867 -e 's/xfsdump: ino map phase 1: .*/xfsdump: ino map <PHASES>/' \
868 -e '/xfsdump: ino map phase [2]/,1d' \
869 -e '/xfsdump: ino map phase [3]/,1d' \
870 -e '/xfsdump: ino map phase [4]/,1d' \
871 -e '/xfsdump: ino map phase [5]/,1d' \
872 -e 's/id:[[:space:]]*[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/ID: ID/' \
873 -e 's/\[y\/n\][- ]----------------------*/\[y\/n\]/' \
874 -e '/skip attribute set/d' \
876 # filter out all the output between the lines "Dump Summary:"
878 if ($_ =~ /(?:Dump|Restore) Summary/) {
880 } elsif ($_ =~ /(?:Dump|Restore) Status/) {
883 print if (! $skip);' \
885 # correct the file count if large scratch devices are being used
887 if ($_ =~ /(\S+) directories and (\S+) entries/) {
889 if ($ENV{'LARGE_SCRATCH_DEV'} && $foo > 0) {
892 printf("xfsrestore: %u directories and %u entries processed\n",
903 _dump_filter_main | _check_quota_dumprestore | _check_quota_entries
913 -e 's/UUID[ ]*:[ ][0-9a-f-]*/UUID : ID/' \
914 -e 's/TIME OF DUMP[ ]*:.*/TIME OF DUMP : TIME/' \
915 -e 's/HOSTNAME:SCRATCH_MNT.*/HOSTNAME:SCRATCH_MNT/' \
916 -e 's#inventory/[0-9a-f-]*#inventory/UUID#' \
924 -e "s#$dump_file#DUMP_FILE#g" \
925 -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
926 -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
927 -e "s#$dumptape#TAPE_DEV#" \
928 -e "s#$dump_dir#DUMP_DIR#g" \
929 -e "s#$restore_dir#RESTORE_DIR#g" \
930 -e "s#$SCRATCH_MNT#SCRATCH_MNT#g" \
931 -e "s#$dump_sdir#DUMP_SUBDIR#g" \
932 -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
934 -e "/Only in SCRATCH_MNT: .use_space/d" \
935 -e "s#$RESULT_DIR/##g" \
940 # Parse xfsdump arguments.
941 # Note: requires a space between option letter and argument
952 [ -z "$2" ] && _fail "missing argument for -f"
958 [ -z "$2" ] && _fail "missing argument for -L"
963 [ -z "$2" ] && _fail "missing argument for --multi"
974 dump_args="$dump_args $1"
977 [ -z "$2" ] && _fail "missing argument for $1"
978 dump_args="$dump_args $1$2"
982 _fail "invalid argument to common/dump function: $1"
990 # Parse xfsrestore arguments.
991 # Note: requires a space between option letter and argument
993 _parse_restore_args()
1002 [ -z "$2" ] && _fail "missing argument for -f"
1008 [ -z "$2" ] && _fail "missing argument for -L"
1013 [ -z "$2" ] && _fail "missing argument for --multi"
1021 do_quota_check=false
1024 restore_args="$restore_args $1"
1027 _fail "invalid argument to common/dump function: $1"
1042 echo "Dumping to tape..."
1043 opts="$_dump_debug$dump_args -s $dump_sdir -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
1044 echo "xfsdump $opts" | _dir_filter
1045 $XFSDUMP_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1055 echo "Dumping to tape..."
1056 opts="$_dump_debug$dump_args -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
1057 echo "xfsdump $opts" | _dir_filter
1058 $XFSDUMP_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1063 # Do full dump with -m
1069 echo "Dumping to tape..."
1071 opts="$_dump_debug$dump_args -m -b $onemeg -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
1072 echo "xfsdump $opts" | _dir_filter
1073 $XFSDUMP_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1078 # Do full dump to file
1084 echo "Dumping to file..."
1085 opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
1086 echo "xfsdump $opts" | _dir_filter
1087 $XFSDUMP_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1091 # Do full dump to multiple files
1093 _do_dump_multi_file()
1100 while [ $i -lt $multi ]
1102 multi_args="$multi_args -f $dump_file.$i -M $media_label.$i"
1106 echo "Dumping to files..."
1107 opts="$_dump_debug$dump_args $multi_args -L $session_label $SCRATCH_MNT"
1108 echo "xfsdump $opts" | _dir_filter
1109 $XFSDUMP_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1113 _prepare_restore_dir()
1116 mkdir $restore_dir || _fail "failed to mkdir $restore_dir"
1121 # Get tape ready and restore dir
1125 _prepare_restore_dir
1127 echo "Rewinding tape"
1132 # Restore the tape into $restore_dir
1136 _parse_restore_args $*
1139 echo "Restoring from tape..."
1140 opts="$_restore_debug$restore_args -f $dumptape -L $session_label $restore_dir"
1141 echo "xfsrestore $opts" | _dir_filter
1142 $XFSRESTORE_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1146 # Restore the tape into $restore_dir using -m
1150 _parse_restore_args $*
1153 echo "Restoring from tape..."
1155 opts="$_restore_debug$restore_args -m -b $onemeg -f $dumptape -L $session_label $restore_dir"
1156 echo "xfsrestore $opts" | _dir_filter
1157 $XFSRESTORE_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1161 # Restore the tape from a dump file
1165 _parse_restore_args $*
1166 _prepare_restore_dir
1168 echo "Restoring from file..."
1169 opts="$_restore_debug$restore_args -f $dump_file -L $session_label $restore_dir"
1170 echo "xfsrestore $opts" | _dir_filter
1171 $XFSRESTORE_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1175 # Cumulative restore from a file
1176 # Must call _prepare_restore_dir before the first
1177 # (and only the first) call to this function.
1179 _do_restore_file_cum()
1181 _parse_restore_args $*
1183 echo "Restoring cumumlative from file..."
1184 opts="$_restore_debug$restore_args -f $dump_file -r $restore_dir"
1185 echo "xfsrestore $opts" | _dir_filter
1186 $XFSRESTORE_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1191 _parse_restore_args $*
1193 echo "Contents of dump ..."
1194 opts="$_restore_debug$restore_args -f $dump_file -t"
1195 echo "xfsrestore $opts" | _dir_filter
1196 cd $SCRATCH_MNT # for IRIX which needs xfs cwd
1197 $XFSRESTORE_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter_main |\
1198 _check_quota_file |\
1199 _check_quota_entries |\
1200 $AWK_PROG 'NF != 1 { print; next }
1201 {files = sprintf("%s\n%s", files, $1)}
1202 END { print files | "sort" } '
1203 # the above awk code is to alpha sort only the output
1204 # of files (and not the verbose restore msgs)
1209 # Restore the tape from multiple dump files
1211 _do_restore_multi_file()
1213 _parse_restore_args $*
1214 _prepare_restore_dir
1219 while [ $i -lt $multi ]
1221 multi_args="$multi_args -f $dump_file.$i"
1225 echo "Restoring from file..."
1226 opts="$_restore_debug$restore_args $multi_args -L $session_label $restore_dir"
1227 echo "xfsrestore $opts" | _dir_filter
1228 $XFSRESTORE_PROG $opts 2>&1 | tee -a $seqres.full | _dump_filter
1232 # Do xfsdump piped into xfsrestore - xfsdump | xfsrestore
1233 # Pass dump options in $1 and restore options in $2, if required. e.g.:
1234 # _do_dump_restore "-o -F" "-R"
1235 # _do_dump_restore "" "-R"
1237 # Use -s as we want to dump and restore to the same xfs partition
1242 _parse_restore_args $2
1243 _prepare_restore_dir
1244 echo "xfsdump|xfsrestore ..."
1245 restore_opts="$_restore_debug$restore_args - $restore_dir"
1246 dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
1247 echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter
1248 $XFSDUMP_PROG $dump_opts 2>$tmp.dump.mlog | $XFSRESTORE_PROG $restore_opts 2>&1 | tee -a $seqres.full | _dump_filter
1249 _dump_filter <$tmp.dump.mlog
1253 # Compare dumped subdirectory with restored dir
1255 # Thus no contents are compared but permissions, sizes,
1256 # owners, etc... are.
1261 # verify we got back what we dumped
1263 echo "Comparing listing of dump directory with restore directory"
1264 ls -nR $dump_dir | tee -a $seqres.full | _ls_filter >$tmp.dump_dir
1265 ls -nR $restore_dir/$dump_sdir | tee -a $seqres.full | _ls_filter \
1266 | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1268 diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1272 # filter out the date fields
1276 $AWK_PROG 'NF == 9 { print $1, $2, $3, $4, $9 }'
1280 # _ls_compare_sub but don't compare dates
1281 _ls_nodate_compare_sub()
1284 # verify we got back what we dumped
1286 echo "Comparing listing of dump directory with restore directory"
1287 ls -nR $dump_dir | tee -a $seqres.full | _ls_filter | _ls_nodate_filter >$tmp.dump_dir
1288 ls -nR $restore_dir/$dump_sdir | tee -a $seqres.full | _ls_filter \
1289 | _ls_nodate_filter | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1291 diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1295 # Compare using recursive diff the files of the dumped
1297 # This one will compare the contents.
1301 echo "Comparing dump directory with restore directory"
1302 diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
1309 # Tim - this is the IRIX way...
1310 # find $_path -exec attr -l {} \; |\
1311 # awk '{print $9, $2}' |\
1314 # and this is now the Linux way...
1316 getfattr --absolute-names -Rh -m user $_path |\
1318 if (m/^# file: (\S+)/) { $file = $1 }
1319 elsif (m/^user\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1321 while read file ea_name; do
1322 attr -g $ea_name $file
1325 if [ "$USE_ATTR_SECURE" = yes ]; then
1326 echo "Security names"
1327 getfattr --absolute-names -Rh -m security $_path |\
1329 if (m/^# file: (\S+)/) { $file = $1 }
1330 elsif (m/^security\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1332 while read file ea_name; do
1333 attr -g $ea_name $file
1338 getfattr --absolute-names -Rh -m trusted $_path |\
1340 if (m/^# file: (\S+)/) { $file = $1 }
1341 elsif (m/^trusted\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1343 while read file ea_name; do
1344 attr -R -g $ea_name $file
1349 # Compare the extended attributes of the files/dirs
1350 # b/w the dumped and restore dirs.
1353 # Attribute "attr5" had a 8 byte value for /spare1/dump.5460/dir:
1354 # Attribute "attr5" had a 8 byte value for /spare1/restore.5460/dump.5460/dir:
1358 echo "Comparing dump directory with restore directory"
1359 echo "Looking at the extended attributes (EAs)"
1361 _get_eas_on_path $dump_dir | tee $seqres.ea1 | _dir_filter
1362 echo "EAs on restore"
1363 _get_eas_on_path $restore_dir/$dump_sdir \
1364 | sed -e "s#$restore_sdir\/##" \
1367 diff -s $seqres.ea1 $seqres.ea2 | _dir_filter
1372 # Compare using recursive diff the files of the dumped
1377 echo "Comparing dump directory with restore directory"
1378 diff -rs $SCRATCH_MNT $restore_dir | _dir_filter | _check_quota_diff
1382 # Check out the dump inventory
1386 $XFSDUMP_PROG $_dump_debug -I | tee -a $seqres.full | _dump_filter_main
1390 # Do the xfsinvutil cmd with debug and filters
1391 # Need to set variable: "$middate" to the invutil date
1396 echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$seqres.full
1397 $XFSINVUTIL_PROG $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
1398 | tee -a $seqres.full | _invutil_filter
1402 # ensure we can find the user quota msg if user quotas are on
1403 # ensure we can find the group quota msg if group quotas are on
1413 $here/src/feature -U $SCRATCH_DEV && uquota=1
1414 $here/src/feature -G $SCRATCH_DEV && gquota=1
1415 $here/src/feature -P $SCRATCH_DEV && pquota=1
1417 $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota \
1418 -v full=$seqres.full -v usermsg="$usermsg" \
1419 -v groupmsg="$groupmsg" -v projectmsg="$projectmsg" '
1421 print "Found project quota:", $0 >>full
1424 print "Found extra:", $0
1429 print "Found group quota:", $0 >>full
1432 print "Found extra:", $0
1437 print "Found user quota:", $0 >>full
1440 print "Found extra:", $0
1446 if (uquota && !found_uquota) {
1447 print "Missing user quota msg:", usermsg
1449 if (gquota && !found_gquota) {
1450 print "Missing group quota msg:", groupmsg
1452 if (pquota && !found_pquota) {
1453 print "Missing project quota msg:", projectmsg
1460 # xfsrestore: 3 directories and 40 entries processed
1462 # num entries needs to be reduced by num quota file(s)
1464 _check_quota_entries()
1469 $here/src/feature -U $SCRATCH_DEV && uquota=1
1470 $here/src/feature -G $SCRATCH_DEV && gquota=1
1471 $here/src/feature -P $SCRATCH_DEV && pquota=1
1472 $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota '
1473 /entries processed/ {
1483 # xfsdump: saving user quota information for: SCRATCH_MNT
1484 # xfsdump: saving group quota information for: SCRATCH_MNT
1485 # xfsdump: saving project quota information for: SCRATCH_MNT
1486 # xfsrestore: user quota information written to ...'
1487 # xfsrestore: group quota information written to ...'
1488 # xfsrestore: project quota information written to ...'
1490 # If on IRIX then look for:
1491 # xfsrestore: use 'edquota' to restore quotas
1493 # xfsrestore: use 'xfs_quota' to restore quotas
1495 _check_quota_dumprestore()
1497 if [ "$HOSTOS" == "IRIX" ]; then
1498 _check_quota 'user quota information' \
1499 'group quota information' \
1500 'project quota information' | \
1501 sed "/xfsrestore:.*use 'edquota' to restore quotas/d"
1503 _check_quota 'user quota information' \
1504 'group quota information' \
1505 'project quota information' | \
1506 sed "/xfsrestore:.*use 'xfs_quota' to restore quotas/d"
1512 # Only in RESTORE_DIR: xfsdump_quotas
1513 # Only in RESTORE_DIR: xfsdump_quotas_group
1514 # Only in RESTORE_DIR: xfsdump_quotas_project
1518 _check_quota 'Only in RESTORE_DIR: xfsdump_quotas' \
1519 'Only in RESTORE_DIR: xfsdump_quotas_group' \
1520 'Only in RESTORE_DIR: xfsdump_quotas_proj'
1524 # Look for the quota file in the output
1525 # Ensure that it is there if it should be
1526 # Filter it out so that the output is always the same
1527 # even with no quotas
1531 _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group' 'xfsdump_quotas_proj'
1535 # make sure this script returns success