Re: FIEMAP ioctl gets "wrong" address for the extent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/7/20 7:43 pm, David Sterba wrote:
On Thu, Jul 02, 2020 at 09:11:20AM +0000, Rebraca Dejan (BSOT/PJ-ES1-Bg) wrote:
Hi all,

I'm collecting file extents for our application from BtrFs filesystem image.
I've noticed that for some files a get the "wrong" physical offset for
start of the extent. I verified it using hexdump of the filesystem
image: when dump the content starting from the address returned from
FIEMAP ioctl, I see that the content is absolutely different from the
content of the file itself. Also, the FIEMAP ioctl reports regular
extent, it is not inline.

There are 3 address spaces:

- device physical offsets
- filesystem physical offsets
- filesystem logical offsets

What you seem to expect is that device physical and filesystem physical
and the same. This is not true in general in btrfs and fiemap will
return only the filesystem offsets. To get to the device offsets you'd
need to do the reverse mapping.

Do you think is it a good idea to rather update vfs? A quick check indicates struct fiemap_extent has reserved space to hold the devid, and should handle the backward compatibility issues.

struct fiemap_extent {
	__u64	fe_logical; /* logical offset in bytes for the start of
 * the extent */
	__u64	fe_physical; /* physical offset in bytes for the start
 * of the extent */
	__u64	fe_length; /* length in bytes for the extent */
	__u64	fe_reserved64[2];
	__u32	fe_flags; /* FIEMAP_EXTENT_* flags for this extent */
	__u32	fe_reserved[3];
};



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux