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>