Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: dsterba@suse.cz,
	"Rebraca Dejan (BSOT/PJ-ES1-Bg)" <Dejan.Rebraca@rs.bosch.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: FIEMAP ioctl gets "wrong" address for the extent
Date: Tue, 7 Jul 2020 17:43:09 +0800	[thread overview]
Message-ID: <486ad3ac-a6f4-ef94-7dfc-1a58b6a7b747@oracle.com> (raw)
In-Reply-To: <20200702114348.GJ27795@twin.jikos.cz>

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];
};

  reply	other threads:[~2020-07-07  9:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02  9:11 FIEMAP ioctl gets "wrong" address for the extent Rebraca Dejan (BSOT/PJ-ES1-Bg)
2020-07-02 10:18 ` Qu Wenruo
2020-07-02 11:08   ` Rebraca Dejan (BSOT/PJ-ES1-Bg)
2020-07-02 11:21     ` Qu Wenruo
2020-07-03  7:13       ` Rebraca Dejan (BSOT/PJ-ES1-Bg)
2020-07-06 17:10       ` Omar Sandoval
2020-07-02 11:43 ` David Sterba
2020-07-07  9:43   ` Anand Jain [this message]
2020-07-07 11:38     ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=486ad3ac-a6f4-ef94-7dfc-1a58b6a7b747@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=Dejan.Rebraca@rs.bosch.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox