3 # Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. All Rights Reserved.
5 # Functions useful for xfsdump/xfsrestore tests
8 # --- initializations ---
11 if [ -n "$DEBUGDUMP" ]; then
17 # Use dump/restore in qa directory for debugging
24 # status returned for not run tests
27 # name those directories
28 dump_file=$tmp.dumpfile
29 # dump_file=$here/dumpfile #TEMP OVERRIDE DUMP FILE
31 dump_dir=$SCRATCH_MNT/$dump_sdir
32 restore_sdir=restoredir
33 restore_dir=$SCRATCH_MNT/$restore_sdir
36 media_label="stress_tape_media"
37 session_label="stress_$seq"
39 nobody=4 # define this uid/gid as a number
40 do_quota_check=true # do quota check if quotas enabled
45 trap "_cleanup; exit \$status" 0 1 2 3 15
47 # start inventory from a known base - move it aside for test
48 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
50 [ -d $dir.$seq ] && rm -rf $dir.$seq
56 [ `uname` = "Linux" ] && have_mtvariable=true
59 # do a remote/local mt
66 _rmtdev=`echo $dumptape | $AWK_PROG -F: '{print $2}'`
68 if echo $dumptape | grep '@' >/dev/null; then
69 _spec=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
70 _rmtuser=`echo $_spec | $AWK_PROG -F@ '{print $1}'`
71 _rmthost=`echo $_spec | $AWK_PROG -F@ '{print $2}'`
72 rsh -n -l $_rmtuser $_rmthost "mt -t $_rmtdev $op"
74 _rmthost=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
75 rsh -n $_rmthost "mt -t $_rmtdev $op"
87 while [ $i -lt $_limit ]; do
88 echo "Checking online..." >>$here/$seq.full
89 if _mt status >$tmp.status 2>&1; then
98 if [ $i -eq $_limit ]; then
99 echo "ERROR: mt -f $dumptape failed"
102 echo "mt -f $dumptape failed" >$seq.notrun
108 if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
111 echo "ERROR: $dumptape is not online"
114 echo "dumptape, $dumptape, is not online" >$seq.notrun
122 echo "Wait for tape, $dumptape, ..." >>$here/$seq.full
125 while [ $i -lt 20 ]; do
126 echo "Checking status..." >>$here/$seq.full
127 if _mt status 2>&1 | tee -a $here/$seq.full | egrep -i "onl|ready" >/dev/null; then
137 # Keep trying so we know we really have rewound
141 echo "Initiate rewind..." >>$here/$seq.full
143 _mt rewind >/dev/null
148 # Do a custom erase because:
149 # (i) some machines don't support it
150 # (ii) some machines take forever to do it
154 echo "Erasing tape" | tee -a $here/$seq.full
162 echo "Erasing tape" | tee -a $here/$seq.full
168 echo $dumptape | grep ':' >/dev/null
176 $have_mtvariable || return
182 echo "Put scsi tape driver into variable block size mode"
183 mt -f $dumptape setblk 0
191 if [ -z "$dumptape" -o "@" == "$dumptape" ]; then
192 echo "This test requires a dump tape - none was specified"
193 echo "No dump tape specified" >$seq.notrun
206 _scratch_mkfs_xfs >>$here/$seq.full || _fail "mkfs failed"
207 _scratch_mount >>$here/$seq.full || _fail "mount failed"
211 # Cleanup created dirs and files
219 if [ -n "$DEBUGDUMP" ]; then
220 # save it for inspection
221 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
222 [ -d $dir ] || continue
223 tar -cvf $seq.inventory.tar $dir
224 ls -nR $dir >$seq.inventory.ls
228 # put inventory dir back
229 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
230 [ -d $dir.$seq ] || continue
231 rm -rf $dir # get rid of new one
235 if [ $status -ne $NOTRUNSTS ]; then
236 # Sleep added to stop _check_scratch_fs from complaining that the
237 # scratch_dev is still busy
245 # ensure that bulkstat data will
246 # match with incore data
247 # by forcing disk data to be written out
251 _saveddir=`pwd`; cd /
252 umount $SCRATCH_MNT >>$here/$seq.full || _fail "unmount failed"
253 _scratch_mount >>$here/$seq.full || _fail "mount failed"
258 # Run fsstress to create a mixture of
259 # files,dirs,links,symlinks
261 # Pinched from test 013.
263 _create_dumpdir_stress()
265 echo "Creating directory system to dump using fsstress."
269 _param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
272 if ! mkdir $dump_dir; then
273 echo " failed to mkdir $dump_dir"
278 echo "-----------------------------------------------"
279 echo "fsstress : $_param"
280 echo "-----------------------------------------------"
281 if ! $here/ltp/fsstress $_param -s 1 $FSSTRESS_AVOID -n $_count -d $dump_dir >$tmp.out 2>&1
283 echo " fsstress (count=$_count) returned $? - see $here/$seq.full"
285 echo "--------------------------------------" >>$here/$seq.full
286 echo "output from fsstress:" >>$here/$seq.full
287 echo "--------------------------------------" >>$here/$seq.full
288 cat $tmp.out >>$here/$seq.full
297 cat <<End-of-File >$tmp.config
298 # pathname size in bytes owner group
300 small 10 $nobody $nobody
301 big 102400 daemon sys
303 sub/big 102400 $nobody sys
305 sub/a 1 $nobody $nobody
306 sub/b 2 $nobody $nobody
307 sub/c 4 $nobody $nobody
308 sub/d 8 $nobody $nobody
309 sub/e 16 $nobody $nobody
310 sub/f 32 $nobody $nobody
311 sub/g 64 $nobody $nobody
312 sub/h 128 $nobody $nobody
313 sub/i 256 $nobody $nobody
314 sub/j 512 $nobody $nobody
315 sub/k 1024 $nobody $nobody
316 sub/l 2048 $nobody $nobody
317 sub/m 4096 $nobody $nobody
318 sub/n 8192 $nobody $nobody
320 sub/a00 100 $nobody $nobody
321 sub/b00 200 $nobody $nobody
322 sub/c00 400 $nobody $nobody
323 sub/d00 800 $nobody $nobody
324 sub/e00 1600 $nobody $nobody
325 sub/f00 3200 $nobody $nobody
326 sub/g00 6400 $nobody $nobody
327 sub/h00 12800 $nobody $nobody
328 sub/i00 25600 $nobody $nobody
329 sub/j00 51200 $nobody $nobody
330 sub/k00 102400 $nobody $nobody
331 sub/l00 204800 $nobody $nobody
332 sub/m00 409600 $nobody $nobody
333 sub/n00 819200 $nobody $nobody
335 sub/a000 1000 $nobody $nobody
336 sub/e000 16000 $nobody $nobody
337 sub/h000 128000 $nobody $nobody
338 sub/k000 1024000 $nobody $nobody
344 cat <<End-of-File >$tmp.config
345 # pathname size in bytes
347 smalll 10 $nobody $nobody
348 biggg 102400 $nobody $nobody
349 sub/smalll 10 $nobody $nobody
350 sub/biggg 102400 $nobody $nobody
354 _mk_fillconfig_perm()
356 # dir_guid: ugo=rwx,g+s on dir is for IRIX chmod(1)
358 cat <<End-of-File >$tmp.config
359 # pathname size/dir user group mode
361 file_suid 10 $nobody $nobody 04777
362 file_guid 10 $nobody $nobody 02777
363 file_sticky 10 $nobody $nobody 01777
364 file_mix1 10 $nobody $nobody 761
365 file_mix2 10 $nobody $nobody 642
366 dir_suid d $nobody $nobody 04777
367 dir_guid d $nobody $nobody ugo=rwx,g+s
368 dir_sticky d $nobody $nobody 01777
369 dir_mix1 d $nobody $nobody 761
370 dir_mix2 d $nobody $nobody 642
376 cat <<End-of-File >$tmp.config
377 # pathname size user group perm name value namespace
379 smalll 10 $nobody $nobody 777 attr1 some_text user
380 biggg 102400 $nobody $nobody 777 attr2 some_text2 root
381 sub/smalll 10 $nobody $nobody 777 attr3 some_text3 user
382 sub/biggg 102400 $nobody $nobody 777 attr4 some_text4 root
383 dir d $nobody $nobody 777 attr5 dir_text user
385 # Add more files so that there are more than the number
387 # There are bugs in dump/restore for # non-dir files < # streams
388 # It can be tested in another configuration.
389 # It is a pathalogical case.
391 sub/a 1 $nobody $nobody
392 sub/b 2 $nobody $nobody
393 sub/c 4 $nobody $nobody
394 sub/d 8 $nobody $nobody
395 sub/e 16 $nobody $nobody
396 sub/f 32 $nobody $nobody
397 sub/g 64 $nobody $nobody
398 sub/h 128 $nobody $nobody
399 sub/i 256 $nobody $nobody
400 sub/j 512 $nobody $nobody
401 sub/k 1024 $nobody $nobody
402 sub/l 2048 $nobody $nobody
403 sub/m 4096 $nobody $nobody
404 sub/n 8192 $nobody $nobody
409 # extended file attribute flags
411 _mk_fillconfig_xattr()
413 cat <<End-of-File >$tmp.config
414 # pathname size user group perm name
416 xflag_realtime 10 $nobody $nobody 777 XFS_XFLAG_REALTIME
417 xflag_prealloc 10 $nobody $nobody 777 XFS_XFLAG_PREALLOC
418 xflag_immutable 10 $nobody $nobody 777 XFS_XFLAG_IMMUTABLE
419 xflag_append 10 $nobody $nobody 777 XFS_XFLAG_APPEND
420 xflag_sync 10 $nobody $nobody 777 XFS_XFLAG_SYNC
421 xflag_noatime 10 $nobody $nobody 777 XFS_XFLAG_NOATIME
422 xflag_nodump 10 $nobody $nobody 777 XFS_XFLAG_NODUMP
423 xflag_hasattr 10 $nobody $nobody 777 XFS_XFLAG_HASATTR
428 # Create a bunch of directories/files of different sizes
431 # Pinched from test 001.
433 _do_create_dumpdir_fill()
435 echo "Creating directory system to dump using src/fill."
437 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
440 $verbose && echo -n "Setup "
441 sed -e '/^#/d' $tmp.config \
442 | while read file nbytes owner group perms ea_name ea_value namespace
444 if [ $nbytes = "d" ]; then
454 echo "Error: cannot mkdir \"$dir\""
459 # create a directory/file
470 echo "Error: cannot mkdir \"$dir\""
476 if $here/src/fill $file $file $nbytes
481 echo "Error: cannot create \"$file\""
485 if [ -n "$owner" -a -n "$group" ]; then
486 chown $owner.$group $file
488 if [ -n "$perms" ]; then
492 # extended attributes (EA)
493 if [ -n "$ea_name" -a -n "$ea_value" ]; then
494 if [ "X$namespace" = "Xroot" ]; then
495 attr -R -s $ea_name -V $ea_value $file
497 attr -s $ea_name -V $ea_value $file
499 # extended file attribute flags - no value - NOT EAs
500 elif [ -n "$ea_name" -a -z "$ea_value" ]; then
503 # use xfs_io to send the ioctl
506 $verbose && echo -n "."
513 _create_dumpdir_largefile()
516 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
517 _largesize=4294967297
518 _largefile=$dump_dir/largefile
519 echo "dd a largefile at offset $_largesize"
520 POSIXLY_CORRECT=yes \
521 dd if=/dev/zero of=$_largefile bs=1 seek=$_largesize count=10 2>&1
525 _create_dumpdir_fill()
529 _do_create_dumpdir_fill
533 _create_dumpdir_fill2()
537 _do_create_dumpdir_fill
541 _create_dumpdir_fill_perm()
545 _do_create_dumpdir_fill
549 _create_dumpdir_fill_ea()
553 _do_create_dumpdir_fill
559 # Append a subset of the fill'ed files
560 # So we can see if just these get dumped on an incremental
562 _append_dumpdir_fill()
565 cat <<End-of-File >$tmp.config
575 sed -e '/^#/d' $tmp.config \
578 echo 'Extra text' >>$file
585 _do_create_dump_symlinks()
587 echo "Creating directory system of symlinks to dump."
589 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
592 $verbose && echo -n "Setup "
593 sed -e '/^#/d' $tmp.config \
594 | while read file nbytes owner group owner2 group2 perms perms2
606 echo "Error: cannot mkdir \"$dir\""
614 # Do chmod on symlink using umask.
615 # This won't do the right thing as it subtracts permissions.
616 # However, I don't care, as long as I get some different perms
618 if [ -n "$perms2" ]; then
622 ln -s $file $file-link
623 if [ -n "$perms2" ]; then
627 if [ -n "$owner" -a -n "$group" ]; then
628 chown $owner.$group $file
630 if [ -n "$owner" -a -n "$group" ]; then
631 chown -h $owner.$group $file-link
633 if [ -n "$perms" ]; then
636 $verbose && echo -n "."
645 cat <<End-of-File >$tmp.config
646 # path size owner1 group1 owner2 group2 perm1 perm2
648 a 0 $nobody $nobody daemon sys 124 421
649 b 0 daemon sys bin bin 347 743
650 sub/a 0 bin bin $nobody sys 777 777
651 sub/b 0 $nobody sys $nobody $nobody 367 763
655 _create_dumpdir_symlinks()
659 _do_create_dump_symlinks
664 # create hardlinks of form $_fname, $_fname_h1 $_fname_h2 ...
673 while [ $_j -le $_numlinks ]; do
675 _hardlink=$_fname$_suffix
676 echo "creating hardlink $_hardlink to $_fname"
677 ln $_fname $_hardlink
683 # create a set of hardlinks
684 # create hardlinks of form file1, file1_h1 file1_h2 ...
685 # create hardlinks of form file2, file2_h1 file2_h2 ...
686 # create hardlinks of form file3, file3_h1 file3_h2 ...
692 while [ $_i -le $_numsets ]; do
693 _create_hardlinks file$_i 5
702 echo "mod level $_level" >$dump_dir/file$_level
705 _create_dumpdir_hardlinks()
709 echo "Creating directory system of hardlinks to incrementally dump."
711 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
714 _create_hardset $_numsets
722 # Filter out times and dates on symlinks and char devices.
723 # Filter out size on directories because this can differ
724 # when transitioning to long inode numbers (ie. 64 bits).
729 /^l/ { date = $8; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
730 /^c/ { date = $9; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
731 /^d/ { size = $5; sub(size,"SIZE"); print}
733 | sed -e 's/total [0-9][0-9]*/total TOTAL/'
737 # Filtering of Irix character hwgraph device names
739 # chardev: /hw/node/xtalk/15/pci/0/scsi_ctlr/0/target/1/lun/0/disk/partition/4/char
740 # blkdev: /dev/dsk/dks0d1s4
746 sub(/\/hw.*scsi_ctlr\//,"/dev/dsk/dks") # blah blah /dev/dsk/dks0/target/1/....
747 sub(/\/target\//,"d") # blah blah /dev/dsk/dks0d1/lun/0/disk.....
748 sub(/\/lun.*partition\//,"s") # blah blah /dev/dsk/dks0d1s4/char
749 sub(/\/char/,"") # blah blah /dev/dsk/dks0d1s4
757 # Filter out the non-deterministic dump msgs from
758 # xfsdump and xfsrestore
764 -e "s/`hostname`/HOSTNAME/" \
765 -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
766 -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
767 -e "s#$dumptape#TAPE_DEV#" \
768 -e "s#$SCRATCH_MNT#SCRATCH_MNT#" \
769 -e "s#$dump_file#DUMP_FILE#" \
770 -e 's#/var/lib/xfsdump#/var/xfsdump#' \
771 -e 's/session id:[ ]*[0-9a-f-]*/session id: ID/' \
772 -e '/filesystem id:[ ]*[0-9a-f-]*/d' \
773 -e 's/time:[ ].*/time: TIME/' \
774 -e 's/date:[ ].*/date: DATE/' \
775 -e 's/dump begun .*/dump begun DATE/' \
776 -e 's/[0-9][0-9]* seconds/SECS seconds/' \
777 -e 's/restore.[0-9][0-9]*/restore.PID/' \
778 -e 's/ino [0-9][0-9]*/ino INO/' \
779 -e '/: dump size/s/[0-9][0-9]*/NUM/' \
780 -e '/dump size:/s/[0-9][0-9]*/NUM/' \
781 -e '/dump size per stream:/s/[0-9][0-9]*/NUM/' \
782 -e 's/\(media file size[ ]*\)[0-9][0-9]*/\1NUM/' \
783 -e 's/\(mfile size:[ ]*\)[0-9][0-9]*/\1NUM/' \
784 -e '/drive[ ]*[0-9][0-9]*:/d' \
786 -e '/inventory session uuid/d' \
787 -e '/ - Running single-threaded/d' \
788 -e '/^.*I\/O metrics: .*$/d' \
789 -e 's/1048576/BLOCKSZ/' \
790 -e 's/2097152/BLOCKSZ/' \
791 -e 's/(pid[ ]*[1-9][0-9]*)/\(pid PID\)/' \
792 -e '/version 3\.0/d' \
793 -e 's/\/hw\/module.*$/SCRATCH_DEV/' \
794 -e 's/xfsdump: ino map phase 1: .*/xfsdump: ino map <PHASES>/' \
795 -e '/xfsdump: ino map phase [2]/,1d' \
796 -e '/xfsdump: ino map phase [3]/,1d' \
797 -e '/xfsdump: ino map phase [4]/,1d' \
798 -e '/xfsdump: ino map phase [5]/,1d' \
799 -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/' \
800 -e 's/\[y\/n\][- ]----------------------*/\[y\/n\]/' \
802 if ($_ =~ /(?:Dump|Restore) Summary/) {
804 } elsif ($_ =~ /(?:Dump|Restore) Status/) {
814 _dump_filter_main | _check_quota_dumprestore | _check_quota_entries
824 -e 's/UUID[ ]*:[ ][0-9a-f-]*/UUID : ID/' \
825 -e 's/TIME OF DUMP[ ]*:.*/TIME OF DUMP : TIME/' \
826 -e 's/HOSTNAME:SCRATCH_MNT.*/HOSTNAME:SCRATCH_MNT/' \
827 -e 's#inventory/[0-9a-f-]*#inventory/UUID#' \
835 -e "s#$dump_file#DUMP_FILE#" \
836 -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
837 -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
838 -e "s#$dumptape#TAPE_DEV#" \
839 -e "s#$dump_dir#DUMP_DIR#g" \
840 -e "s#$restore_dir#RESTORE_DIR#g" \
841 -e "s#$SCRATCH_MNT#SCRATCH_MNT#g" \
842 -e "s#$dump_sdir#DUMP_SUBDIR#g" \
843 -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
849 # Note: requires a space between option letter and argument
860 [ -z "$2" ] && _fail "missing argument for -f"
865 [ -z "$2" ] && _fail "missing argument for -L"
870 dump_args="$dump_args -o"
873 dump_args="$dump_args -F"
886 [ -z "$2" ] && _fail "missing argument for -l"
887 dump_args="$dump_args -l$2"
891 _fail "invalid argument to common.dump function: $1"
906 echo "Dumping to tape..."
907 opts="$_dump_debug$dump_args -s $dump_sdir -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
908 echo "xfsdump $opts" | _dir_filter
909 xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
919 echo "Dumping to tape..."
920 opts="$_dump_debug$dump_args -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
921 echo "xfsdump $opts" | _dir_filter
922 xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
927 # Do full dump with -m
933 echo "Dumping to tape..."
935 opts="$_dump_debug$dump_args -m -b $onemeg -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
936 echo "xfsdump $opts" | _dir_filter
937 xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
942 # Do full dump to file
948 echo "Dumping to file..."
949 opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
950 echo "xfsdump $opts" | _dir_filter
951 xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
955 # Do full dump to multiple files
957 _do_dump_multi_file()
964 while [ $i -lt $multi ]
966 multi_args="$multi_args -f $dump_file.$i -M $media_label.$i"
970 echo "Dumping to files..."
971 opts="$_dump_debug$dump_args $multi_args -L $session_label $SCRATCH_MNT"
972 echo "xfsdump $opts" | _dir_filter
973 xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
977 _prepare_restore_dir()
980 mkdir $restore_dir || _fail "failed to mkdir $restore_dir"
985 # Get tape ready and restore dir
991 echo "Rewinding tape"
996 # Restore the tape into $restore_dir
1004 echo "Restoring from tape..."
1005 opts="$_restore_debug -f $dumptape -L $session_label $restore_dir"
1006 echo "xfsrestore $opts" | _dir_filter
1007 xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1011 # Restore the tape into $restore_dir using -m
1018 echo "Restoring from tape..."
1020 opts="$_restore_debug -m -b $onemeg -f $dumptape -L $session_label $restore_dir"
1021 echo "xfsrestore $opts" | _dir_filter
1022 xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1026 # Restore the tape from a dump file
1031 _prepare_restore_dir
1033 echo "Restoring from file..."
1034 opts="$_restore_debug -f $dump_file -L $session_label $restore_dir"
1035 echo "xfsrestore $opts" | _dir_filter
1036 xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1040 # Cumulative restore from a file
1041 # Need to specify the dump level e.g. "-l 0"
1043 _do_restore_file_cum()
1046 if echo $dump_args | grep '\-l0' >/dev/null; then
1047 _prepare_restore_dir
1050 echo "Restoring cumumlative from file..."
1051 opts="$_restore_debug -f $dump_file -r $restore_dir"
1052 echo "xfsrestore $opts" | _dir_filter
1053 xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1058 echo "Contents of dump ..."
1059 opts="$_restore_debug -f $dump_file -t"
1060 echo "xfsrestore $opts" | _dir_filter
1061 cd $SCRATCH_MNT # for IRIX which needs xfs cwd
1062 xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter_main |\
1063 _check_quota_file |\
1064 _check_quota_entries |\
1065 $AWK_PROG 'NF != 1 { print; next }
1066 {files = sprintf("%s\n%s", files, $1)}
1067 END { print files | "sort" } '
1068 # the above awk code is to alpha sort only the output
1069 # of files (and not the verbose restore msgs)
1074 # Restore the tape from multiple dump files
1076 _do_restore_multi_file()
1079 _prepare_restore_dir
1084 while [ $i -lt $multi ]
1086 multi_args="$multi_args -f $dump_file.$i"
1090 echo "Restoring from file..."
1091 opts="$_restore_debug $multi_args -L $session_label $restore_dir"
1092 echo "xfsrestore $opts" | _dir_filter
1093 xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1097 # Do xfsdump piped into xfsrestore - xfsdump | xfsrestore
1099 # Use -s as we want to dump and restore to the same xfs partition
1104 _prepare_restore_dir
1105 echo "xfsdump|xfsrestore ..."
1106 restore_opts="$_restore_debug - $restore_dir"
1107 dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
1108 echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter
1109 xfsdump $dump_opts 2>$tmp.dump.mlog | xfsrestore $restore_opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1110 _dump_filter <$tmp.dump.mlog
1114 # Compare dumped subdirectory with restored dir
1116 # Thus no contents are compared but permissions, sizes,
1117 # owners, etc... are.
1122 # verify we got back what we dumped
1124 echo "Comparing listing of dump directory with restore directory"
1125 ls -nR $dump_dir | tee -a $here/$seq.full | _ls_filter >$tmp.dump_dir
1126 ls -nR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
1127 | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1129 diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1133 # filter out the date fields
1137 $AWK_PROG 'NF == 9 { print $1, $2, $3, $4, $9 }'
1141 # _ls_compare_sub but don't compare dates
1142 _ls_nodate_compare_sub()
1145 # verify we got back what we dumped
1147 echo "Comparing listing of dump directory with restore directory"
1148 ls -nR $dump_dir | tee -a $here/$seq.full | _ls_filter | _ls_nodate_filter >$tmp.dump_dir
1149 ls -nR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
1150 | _ls_nodate_filter | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1152 diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1156 # Compare using recursive diff the files of the dumped
1158 # This one will compare the contents.
1162 echo "Comparing dump directory with restore directory"
1163 diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
1170 # Tim - this is the IRIX way...
1171 # find $_path -exec attr -l {} \; |\
1172 # awk '{print $9, $2}' |\
1175 # and this is now the Linux way...
1177 getfattr --absolute-names -Rh -m user $_path |\
1179 if (m/^# file: (\S+)/) { $file = $1 }
1180 elsif (m/^user\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1182 while read file ea_name; do
1183 attr -g $ea_name $file
1186 if [ "$USE_ATTR_SECURE" = yes ]; then
1187 echo "Security names"
1188 getfattr --absolute-names -Rh -m security $_path |\
1190 if (m/^# file: (\S+)/) { $file = $1 }
1191 elsif (m/^security\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1193 while read file ea_name; do
1194 attr -g $ea_name $file
1199 getfattr --absolute-names -Rh -m trusted $_path |\
1201 if (m/^# file: (\S+)/) { $file = $1 }
1202 elsif (m/^trusted\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1204 while read file ea_name; do
1205 attr -R -g $ea_name $file
1210 # Compare the extended attributes of the files/dirs
1211 # b/w the dumped and restore dirs.
1214 # Attribute "attr5" had a 8 byte value for /spare1/dump.5460/dir:
1215 # Attribute "attr5" had a 8 byte value for /spare1/restore.5460/dump.5460/dir:
1219 echo "Comparing dump directory with restore directory"
1220 echo "Looking at the extended attributes (EAs)"
1222 _get_eas_on_path $dump_dir | tee $seq.ea1 | _dir_filter
1223 echo "EAs on restore"
1224 _get_eas_on_path $restore_dir/$dump_sdir \
1225 | sed -e "s#$restore_sdir\/##" \
1228 diff -s $seq.ea1 $seq.ea2
1233 # Compare using recursive diff the files of the dumped
1238 echo "Comparing dump directory with restore directory"
1239 diff -rs $SCRATCH_MNT $restore_dir | _dir_filter | _check_quota_diff
1243 # Check out the dump inventory
1247 xfsdump $_dump_debug -I | tee -a $here/$seq.full | _dump_filter_main
1251 # Do the xfsinvutil cmd with debug and filters
1252 # Need to set variable: "$middate" to the invutil date
1257 echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$here/$seq.full
1258 xfsinvutil $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
1259 | tee -a $here/$seq.full | _invutil_filter
1263 # ensure we can find the user quota msg if user quotas are on
1264 # ensure we can find the group quota msg if group quotas are on
1274 $here/src/feature -U $SCRATCH_DEV && uquota=1
1275 $here/src/feature -G $SCRATCH_DEV && gquota=1
1276 $here/src/feature -P $SCRATCH_DEV && pquota=1
1278 $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota \
1279 -v full=$here/$seq.full -v usermsg="$usermsg" \
1280 -v groupmsg="$groupmsg" -v projectmsg="$projectmsg" '
1282 print "Found project quota:", $0 >>full
1285 print "Found extra:", $0
1290 print "Found group quota:", $0 >>full
1293 print "Found extra:", $0
1298 print "Found user quota:", $0 >>full
1301 print "Found extra:", $0
1307 if (uquota && !found_uquota) {
1308 print "Missing user quota msg:", usermsg
1310 if (gquota && !found_gquota) {
1311 print "Missing group quota msg:", groupmsg
1313 if (pquota && !found_pquota) {
1314 print "Missing project quota msg:", projectmsg
1321 # xfsrestore: 3 directories and 40 entries processed
1323 # num entries needs to be reduced by num quota file(s)
1325 _check_quota_entries()
1330 $here/src/feature -U $SCRATCH_DEV && uquota=1
1331 $here/src/feature -G $SCRATCH_DEV && gquota=1
1332 $here/src/feature -P $SCRATCH_DEV && pquota=1
1333 $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota '
1334 /entries processed/ {
1344 # xfsdump: saving user quota information for: SCRATCH_MNT
1345 # xfsdump: saving group quota information for: SCRATCH_MNT
1346 # xfsdump: saving project quota information for: SCRATCH_MNT
1347 # xfsrestore: user quota information written to ...'
1348 # xfsrestore: group quota information written to ...'
1349 # xfsrestore: project quota information written to ...'
1351 # If on IRIX then look for:
1352 # xfsrestore: use 'edquota' to restore quotas
1354 # xfsrestore: use 'xfs_quota' to restore quotas
1356 _check_quota_dumprestore()
1358 if [ "$HOSTOS" == "IRIX" ]; then
1359 _check_quota 'user quota information' \
1360 'group quota information' \
1361 'project quota information' | \
1362 sed "/xfsrestore:.*use 'edquota' to restore quotas/d"
1364 _check_quota 'user quota information' \
1365 'group quota information' \
1366 'project quota information' | \
1367 sed "/xfsrestore:.*use 'xfs_quota' to restore quotas/d"
1373 # Only in RESTORE_DIR: xfsdump_quotas
1374 # Only in RESTORE_DIR: xfsdump_quotas_group
1375 # Only in RESTORE_DIR: xfsdump_quotas_project
1379 _check_quota 'Only in RESTORE_DIR: xfsdump_quotas' \
1380 'Only in RESTORE_DIR: xfsdump_quotas_group' \
1381 'Only in RESTORE_DIR: xfsdump_quotas_proj'
1385 # Look for the quota file in the output
1386 # Ensure that it is there if it should be
1387 # Filter it out so that the output is always the same
1388 # even with no quotas
1392 _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group' 'xfsdump_quotas_proj'
1396 # make sure this script returns success