No title Revision 396463363338 (Wed Feb 13 2019 at 18:11) - Diff Link to this snippet: https://friendpaste.com/22t4OdktHQTl0aMGxckc86 Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950#!/bin/bash# Write a 4096 byte block of somethingblock (){ head -c 4096 /dev/zero | tr '\0' "\\$1";}# Here is some test data with holes in it:for y in $(seq 0 2); do for x in 0 1; do block 0; block 21; block 21; block 21; block 21; block 21; block 21; block 21; block 21; block 21; block 21; block 21; block 21; block 21; block 21; block 21; donedone > amsyncecho "file size: $(du -h am)"echo "digests after file creation: $(sha1sum am)"sysctl -q vm.drop_caches=1echo "digests after file creation 2: $(sha1sum am)"# Now replace those 101 distinct extents with 101 references to the first extentbtrfs-extent-same 131072 $(for x in $(seq 0 2); do echo am $((x * 131072)); done) 2>&1 | tail -1echo "digests after dedupe: $(sha1sum am)"sysctl -q vm.drop_caches=1echo "digests after dedupe 2: $(sha1sum am)"# Punch holes into the extent refsfallocate -v -d amecho "digests after hole punching: $(sha1sum am)"sysctl -q vm.drop_caches=1echo "digests after hole punching 2: $(sha1sum am)"