btrfs/095: work on non-4k block sized filesystems

This commit makes use of the new _filter_xfs_io_blocks_modified filtering
function to print information in terms of file blocks rather than file
offset.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Chandan Rajendra
2015-12-21 18:01:46 +11:00
committed by Dave Chinner
parent 0b21062a72
commit 5514417282
2 changed files with 95 additions and 55 deletions
+61 -47
View File
@@ -63,84 +63,98 @@ _scratch_mkfs >>$seqres.full 2>&1
_init_flakey _init_flakey
_mount_flakey _mount_flakey
# Create prealloc extent covering range [160K, 620K[ BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
$XFS_IO_PROG -f -c "falloc 160K 460K" $SCRATCH_MNT/foo
# Now write to the last 80K of the prealloc extent plus 40K to the unallocated # Create prealloc extent covering file block range [40, 155[
# space that immediately follows it. This creates a new extent of 40K that spans $XFS_IO_PROG -f -c "falloc $((40 * $BLOCK_SIZE)) $((115 * $BLOCK_SIZE))" \
# the range [620K, 660K[. $SCRATCH_MNT/foo
$XFS_IO_PROG -c "pwrite -S 0xaa 540K 120K" $SCRATCH_MNT/foo | _filter_xfs_io
# Now write to the last 20 blocks of the prealloc extent plus 10 blocks to the
# unallocated space that immediately follows it. This creates a new extent of 10
# blocks that spans the block range [155, 165[.
$XFS_IO_PROG -c "pwrite -S 0xaa $((135 * $BLOCK_SIZE)) $((30 * $BLOCK_SIZE))" \
$SCRATCH_MNT/foo | _filter_xfs_io_blocks_modified
# At this point, there are now 2 back references to the prealloc extent in our # At this point, there are now 2 back references to the prealloc extent in our
# extent tree. Both are for our file offset 160K and one relates to a file # extent tree. Both are for our file offset mapped by the 40th block of the file
# extent item with a data offset of 0 and a length of 380K, while the other # and one relates to a file extent item with a data offset of 0 and a length of
# relates to a file extent item with a data offset of 380K and a length of 80K. # 95 blocks, while the other relates to a file extent item with a data offset of
# 95 blocks and a length of 20 blocks.
# Make sure everything done so far is durably persisted (all back references are # Make sure everything done so far is durably persisted (all back references are
# in the extent tree, etc). # in the extent tree, etc).
sync sync
# Now clone all extents of our file that cover the offset 160K up to its eof # Now clone all extents of our file that cover the file range spanned by 40th
# (660K at this point) into itself at offset 2M. This leaves a hole in the file # block up to its eof (165th block at this point) into itself at 512th
# covering the range [660K, 2M[. The prealloc extent will now be referenced by # block. This leaves a hole in the file covering the block range [165, 512[. The
# the file twice, once for offset 160K and once for offset 2M. The 40K extent # prealloc extent will now be referenced by the file twice, once for offset
# that follows the prealloc extent will also be referenced twice by our file, # mapped by the 40th block and once for offset mapped by 512th block. The 10
# once for offset 620K and once for offset 2M + 460K. # blocks extent that follows the prealloc extent will also be referenced twice
$CLONER_PROG -s $((160 * 1024)) -d $((2 * 1024 * 1024)) -l 0 $SCRATCH_MNT/foo \ # by our file, once for offset mapped by the 155th block and once for offset
$SCRATCH_MNT/foo # (512 block + 115 blocks)
$CLONER_PROG -s $((40 * $BLOCK_SIZE)) -d $((512 * $BLOCK_SIZE)) -l 0 \
$SCRATCH_MNT/foo $SCRATCH_MNT/foo
# Now create one new extent in our file with a size of 100Kb. It will span the # Now create one new extent in our file with a size of 25 blocks. It will span
# range [3M, 3M + 100K[. It also will cause creation of a hole spanning the # the block range [768, 768 + 25[. It also will cause creation of a hole
# range [2M + 460K, 3M[. Our new file size is 3M + 100K. # spanning the block range [512 + 115, 768[. Our new file size is the file
$XFS_IO_PROG -c "pwrite -S 0xbb 3M 100K" $SCRATCH_MNT/foo | _filter_xfs_io # offset mapped by (768 + 25)th block.
$XFS_IO_PROG -c "pwrite -S 0xbb $((768 * $BLOCK_SIZE)) $((25 * $BLOCK_SIZE))" \
$SCRATCH_MNT/foo | _filter_xfs_io_blocks_modified
# At this point, there are now (in memory) 4 back references to the prealloc # At this point, there are now (in memory) 4 back references to the prealloc
# extent. # extent.
# #
# Two of them are for file offset 160K, related to file extent items # Two of them are for file offset mapped by the 40th block, related to file
# matching the file offsets 160K and 540K respectively, with data offsets of # extent items matching the file offsets mapped by 40th and 135th block
# 0 and 380K respectively, and with lengths of 380K and 80K respectively. # respectively, with data offsets of 0 and 95 blocks respectively, and with
# lengths of 95 and 20 blocks respectively.
# #
# The other two references are for file offset 2M, related to file extent items # The other two references are for file offset mapped by 512th block, related to
# matching the file offsets 2M and 2M + 380K respectively, with data offsets of # file extent items matching the file offsets mapped by 512th and (512 + 95)th
# 0 and 380K respectively, and with lengths of 380K and 80K respectively. # block respectively, with data offsets mapped by 0th and 95th block
# respectively, and with lengths of 95 and 20 blocks respectively.
# #
# The 40K extent has 2 back references, one for file offset 620K and the other # The 10 block extent has 2 back references, one for file offset mapped by 155th
# for file offset 2M + 460K. # block and the other for file offset mapped by (512 + 115)th block.
# #
# The 100K extent has a single back reference and it relates to file offset 3M. # The 25 blocks extent has a single back reference and it relates to file offset
# mapped by 768th block.
# Now clone our 100K extent into offset 600K. That offset covers the last 20K
# of the prealloc extent, the whole 40K extent and 40K of the hole starting at # Now clone our 25 block extent into offset mapped by 150th block. That offset
# offset 660K. # covers the last 5 blocks of the prealloc extent, the whole 10 block extent and
$CLONER_PROG -s $((3 * 1024 * 1024)) -d $((600 * 1024)) -l $((100 * 1024)) \ # 10 blocks of the hole starting at offset mapped by 165th block.
$CLONER_PROG -s $((768 * $BLOCK_SIZE)) -d $((150 * $BLOCK_SIZE)) -l $((25 * $BLOCK_SIZE)) \
$SCRATCH_MNT/foo $SCRATCH_MNT/foo $SCRATCH_MNT/foo $SCRATCH_MNT/foo
# At this point there's only one reference to the 40K extent, at file offset # At this point there's only one reference to the 10 block extent, at file
# 2M + 460K, we have 4 references for the prealloc extent (2 for file offset # offset mapped by (512 + 115) block, we have 4 references for the prealloc
# 160K and 2 for file offset 2M) and 2 references for the 100K extent (1 for # extent (2 for file offset mapped by 40th block and 2 for file offset mapped by
# file offset 3M and a new one for file offset 600K). # 512th block) and 2 references for the 25 block extent (1 for file offset
# mapped by 768th block and a new one for file offset mapped by 150th block).
# Now fsync our file to make all its new data and metadata updates are durably # Now fsync our file to make all its new data and metadata updates are durably
# persisted and present if a power failure/crash happens after a successful # persisted and present if a power failure/crash happens after a successful
# fsync and before the next transaction commit. # fsync and before the next transaction commit.
$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
echo "File digest before power failure:" echo "File contents before power failure:"
md5sum $SCRATCH_MNT/foo | _filter_scratch od -t x1 $SCRATCH_MNT/foo | _filter_od
# During log replay, the btrfs delayed references implementation used to run the # During log replay, the btrfs delayed references implementation used to run the
# deletion of back references before the addition of new back references, which # deletion of back references before the addition of new back references, which
# made the addition fail as it didn't find the key in the extent tree that it # made the addition fail as it didn't find the key in the extent tree that it
# was looking for. The failure triggered by this test was related to the 40K # was looking for. The failure triggered by this test was related to the 10
# extent, which got 1 reference dropped and 1 reference added during the fsync # block extent, which got 1 reference dropped and 1 reference added during the
# log replay - when running the delayed references at transaction commit time, # fsync log replay - when running the delayed references at transaction commit
# btrfs was applying the deletion before the insertion, resulting in a failure # time, btrfs was applying the deletion before the insertion, resulting in a
# of the insertion that ended up turning the fs into read-only mode. # failure of the insertion that ended up turning the fs into read-only mode.
_flakey_drop_and_remount _flakey_drop_and_remount
echo "File digest after log replay:" echo "File contents after log replay:"
md5sum $SCRATCH_MNT/foo | _filter_scratch od -t x1 $SCRATCH_MNT/foo | _filter_od
_unmount_flakey _unmount_flakey
+34 -8
View File
@@ -1,9 +1,35 @@
QA output created by 095 QA output created by 095
wrote 122880/122880 bytes at offset 552960 Blocks modified: [135 - 164]
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Blocks modified: [768 - 792]
wrote 102400/102400 bytes at offset 3145728 File contents before power failure:
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
File digest before power failure: *
beaf47c36659ac29bb9363fb8ffa10a1 SCRATCH_MNT/foo 207 aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
File digest after log replay: *
beaf47c36659ac29bb9363fb8ffa10a1 SCRATCH_MNT/foo 226 bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb
*
257 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
1137 aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
*
1175 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
1400 bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb
*
1431
File contents after log replay:
0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
207 aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
*
226 bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb
*
257 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
1137 aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
*
1175 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
1400 bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb
*
1431