]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commit
common/btrfs: add helper to get the bytenr for a file extent item
authorFilipe Manana <fdmanana@suse.com>
Tue, 9 May 2023 11:52:04 +0000 (12:52 +0100)
committerZorro Lang <zlang@kernel.org>
Fri, 12 May 2023 12:20:07 +0000 (20:20 +0800)
commita580ecd1dfc6fb83d8883a4231f89137488d8bbc
tree5b964dbaecb5688a326044cc63d748686372cb08
parent2e361b3da66d3537ec9b78d1b7bd12654a3a1ef8
common/btrfs: add helper to get the bytenr for a file extent item

In upcoming changes there will be the need to find out the logical disk
address (bytenr) that a particular file extent item points to. This is
already implemented as local functions in the test btrfs/299, which is
a bit limited but works fine for that test. Some important or subtle
details why it works for this test:

1) It dumps all trees of the filesystem;

2) It relies on fsync'ing a file and then finding the desired file
   extent item in the log tree from the dump;

3) There's a single subvolume, so it always finds the correct file extent
   item. In case there were multiple subvolumes, it could pick the wrong
   file extent item in case we have inodes with the same number on
   multiple subvolumes (inode numbers are unique only within a subvolume,
   they are not unique across an entire filesystem).

So add a helper to get the bytenr associated to a file extent item to
common/btrfs and use it at btrfs/299 and the upcoming changes.

This helper will dump only the tree of the default subvolume, will sync
the filesystem to commit any open transaction and works only in case the
filesystem is using the scratch device. This is explicitly documented.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/btrfs
tests/btrfs/299