Skip to content

Instantly share code, notes, and snippets.

@LongHairedHacker
Last active June 20, 2017 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LongHairedHacker/50fee617301e4ad1af788e567461bb87 to your computer and use it in GitHub Desktop.
Save LongHairedHacker/50fee617301e4ad1af788e567461bb87 to your computer and use it in GitHub Desktop.
! t/test-sparse-files.sh sparse restore on zfs, assuming 131072B blocks: ..... 2.629s ok
! t/test-sparse-files.sh sparse file restore (all sparse): ...
! t/test-sparse-files.sh:44 bup restore -C restore src/latest//usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi/ ok
! t/test-sparse-files.sh:45 du -k -s restore ok
! t/test-sparse-files.sh:45 cut -f1 ok
! t/test-! t/test-sparse-files.sh sparse restore on zfs, assuming 131072B blocks: ..... 2.629s ok
! t/test-sparse-files.sh sparse file restore (all sparse): ...
! t/test-sparse-files.sh:44 bup restore -C restore src/latest//usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi/ ok
! t/test-sparse-files.sh:45 du -k -s restore ok
! t/test-sparse-files.sh:45 cut -f1 ok
! t/test-sparse-files.sh:46 [ 2 -ge 1280 ] FAILED
0.491s ok
called from t/test-sparse-files.sh:46 WVPASS [ 2 -ge 1280 ]
gmake[1]: *** [Makefile:190: tmp-target-run-test-sparse-files.sh] Error 1
gmake[1]: Leaving directory '/usr/home/sebastian/bup'
! Program returned non-zero exit code (2) FAILED
WvTest: result code 2, total time 484.733s
./wvtest report t/tmp/test-log/*.log
! t/test-sparse-files.sh:44 bup restore -C restore src/latest//usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi/ ok
! t/test-sparse-files.sh:45 du -k -s restore ok
! t/test-sparse-files.sh:45 cut -f1 ok
! t/test-sparse-files.sh:46 [ 2 -ge 1280 ] FAILED
! Program returned non-zero exit code (2) FAILED
WvTest: 3777 tests, 2 failures
gmake: *** [Makefile:202: test] Error 125
Apparent files size (what ls says) vs. real file size (what du says):
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ du -h src/foo
512B src/foo
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ ls -alh src/foo
-rw-r--r-- 1 sebastian sebastian 1.3M Mar 15 16:18 src/foo
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ du -h restore/src/foo
512B restore/src/foo
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ ls -alh restore/src/foo
-rw-r--r-- 1 sebastian sebastian 1.3M Mar 15 16:18 restore/src/foo
Let's ask stat:
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ stat src/foo
3947765690 5291 -rw-r--r-- 1 sebastian sebastian 4294967295 1310721 "Mar 15 16:18:42 2017" "Mar 15 16:18:42 2017" "Mar 15 16:18:42 2017" "Mar 15 16:18:42 2017" 131072 1 0x800 src/foo
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ stat restore/src/foo
3947765690 5304 -rw-r--r-- 1 sebastian sebastian 4294967295 1310721 "Mar 15 16:18:42 2017" "Mar 15 16:18:42 2017" "Mar 15 16:18:45 2017" "Mar 15 16:18:45 2017" 131072 1 0x800 restore/src/foo
=> Restore seems to have worked fine
Let's play with du:
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ du -s -k restore/
2 restore/
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ du -s -k src/
1 src/
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ du -s -k src/*
1 src/foo
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ du -s -k restore/*
1 restore/src
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ du -s -k restore/src/*
1 restore/src/foo
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ du -h src/
1.0K src/
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ du -h restore/
1.0K restore/src
1.5K restore/
[sebastian@mawhrin /usr/home/sebastian/bup/t/tmp/test-sparse-files.sh-6w5JWBi]$ du -h restore/src/
1.0K restore/src/
Looking at https://github.com/bup/bup/blob/master/t/test-sparse-files.sh#L46
restore_size=$(WVPASS du -k -s restore | WVPASS cut -f1) || exit $?
WVPASS [ "$restore_size" -ge "$((data_size / 1024))" ]
For a block size of 4096 bytes:
data_size = block_size * 10 = 40960
File is created using:
WVPASS dd if=/dev/zero of=src/foo seek="$data_size" bs=1 count=1
restore_size = 4 (a single block if we have sparse file support)
This leads to:
WVPASS [ "4" -ge "40" ]
Which should never pass for any sensible blocksize ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment