reflink: test CoW operations against the source file

Ensure that CoW operations against shared blocks in the source file
work correctly.

v2: remove filefrag dependencies

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
Darrick J. Wong
2016-02-03 12:59:27 -08:00
parent c741fbfd99
commit 37059d0ca7
22 changed files with 1007 additions and 2 deletions
+66
View File
@@ -295,3 +295,69 @@ _weave_reflink_rainbow_delalloc() {
_pwrite_byte 0x62 $((blksz * i)) $blksz $dfile.chk
done
}
# Make the source file have interleaved regular blocks and reflinked blocks
_sweave_reflink_regular() {
blksz=$1
nr=$2
sfile=$3
dfile=$4
_pwrite_byte 0x61 0 $((blksz * nr)) $sfile
_pwrite_byte 0x62 0 $((blksz * nr)) $dfile
_pwrite_byte 0x61 0 $((blksz * nr)) $sfile.chk
seq 1 2 $((nr - 1)) | while read i; do
_reflink_range $sfile $((blksz * i)) $dfile $((blksz * i)) $blksz
done
}
# Make the source file have interleaved unwritten blocks and reflinked blocks
_sweave_reflink_unwritten() {
blksz=$1
nr=$2
sfile=$3
dfile=$4
$XFS_IO_PROG -f -c "falloc 0 $((blksz * nr))" $sfile
_pwrite_byte 0x00 0 $((blksz * nr)) $sfile.chk
_pwrite_byte 0x62 0 $((blksz * nr)) $dfile
seq 1 2 $((nr - 1)) | while read i; do
_pwrite_byte 0x61 $((blksz * i)) $blksz $sfile
_pwrite_byte 0x61 $((blksz * i)) $blksz $sfile.chk
done
seq 1 2 $((nr - 1)) | while read i; do
_reflink_range $sfile $((blksz * i)) $dfile $((blksz * i)) $blksz
done
}
# Make the source file have interleaved holes and reflinked blocks
_sweave_reflink_holes() {
blksz=$1
nr=$2
sfile=$3
dfile=$4
$XFS_IO_PROG -f -c "truncate $((blksz * nr))" $sfile
_pwrite_byte 0x00 0 $((blksz * nr)) $sfile.chk
_pwrite_byte 0x62 0 $((blksz * nr)) $dfile
seq 1 2 $((nr - 1)) | while read i; do
_pwrite_byte 0x61 $((blksz * i)) $blksz $sfile
_pwrite_byte 0x61 $((blksz * i)) $blksz $sfile.chk
done
seq 1 2 $((nr - 1)) | while read i; do
_reflink_range $sfile $((blksz * i)) $dfile $((blksz * i)) $blksz
done
}
# For a file created with _sweave_reflink_holes, fill the holes with delalloc
# extents
_sweave_reflink_holes_delalloc() {
blksz=$1
nr=$2
sfile=$3
seq 0 2 $((nr - 1)) | while read i; do
_pwrite_byte 0x64 $((blksz * i)) $blksz $sfile
_pwrite_byte 0x64 $((blksz * i)) $blksz $sfile.chk
done
}