From: Liu Bo <liubo2009@cn.fujitsu.com>
To: Alex Lyakas <alex.bolshoy.btrfs@gmail.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: Newbie questions on some of btrfs code...
Date: Tue, 22 May 2012 09:42:54 +0800 [thread overview]
Message-ID: <4FBAEF1E.4050706@cn.fujitsu.com> (raw)
In-Reply-To: <CAHf9xvZDwjSJvJnaX9qmYyXJoM4t=E2zi=eH0bZpknYFpsAsjw@mail.gmail.com>
On 05/21/2012 06:05 PM, Alex Lyakas wrote:
> Hi Liu,
> thanks for the clarifications.
>
> I did not understand the dd example of yours, though.
>
>> So for the following situation:
>>> item 23 key (266 EXTENT_DATA 4096) itemoff 2269 itemsize 53
>>> extent data disk byte 0 nr 0
>>> extent data offset 0 nr 4096 ram 8192
>>> extent compression 0
>> As your case, after the first 'size 5' inline extent is written,
>> "nr 4096 < ram 8192" could come from:
>> 1) dd if=/dev/zero of=/mnt/btrfs/foobar bs=1k seek=12 count=4 conv=notrunc;sync
>> 2) dd if=/dev/zero of=/mnt/btrfs/foobar bs=1k seek=8 count=4 conv=notrunc;sync
>>
>> 1) makes
>>> item 23 key (266 EXTENT_DATA 4096) itemoff 2269 itemsize 53
>>> extent data disk byte 0 nr 0
>>> extent data offset 0 nr 8192 ram 8192
>>> extent compression 0
>> 2) makes
>>> item 23 key (266 EXTENT_DATA 4096) itemoff 2269 itemsize 53
>>> extent data disk byte 0 nr 0
>>> extent data offset 0 nr 4096 ram 8192
>>> extent compression 0
>
> You talk about the "ram_bytes" field. But do I need to look at it, if
> I don't use compression or another encoding? Shouldn't I always look
> at btrfs_file_extent_item::offset/num_bytes for the real data, and at
> btrfs_file_extent_item::disk_bytenr/disk_num_bytes for finding
> CHUNK_ITEM? Any reason I should be aware of "ram_bytes" field?
>
> The first dd created a 4k extent at offset 12k. How did we end up with
> "nr 8192 ram 8192" and offset 4k?
> The second dd added a 4k extent at 8k offset. But still EXTENT_DATA
> has 4k offset.
> So now we should have have twp 4k extents or one 8k extent. What am I missing?
>
> Alex.
>
As I mentioned, disk_bytenr == 0 means dummy extents, which we have not yet allocate
a range of space for it.
After your first 'size=5' inline extent, we'll start allocating extents from _4096_, cause
it is _4k aligned_.
>> 1) dd if=/dev/zero of=/mnt/btrfs/foobar bs=1k seek=12 count=4 conv=notrunc;sync
: we need a dummy extent for [4k, 12k], which starts from 4096, and nr is 8192
>> 2) dd if=/dev/zero of=/mnt/btrfs/foobar bs=1k seek=8 count=4 conv=notrunc;sync
: we break [4k, 12k] into a dummy one [4k, 8k] and a real one [8k, 12k].
More details, plz refer to btrfs_drop_extents();
thanks,
liubo
next prev parent reply other threads:[~2012-05-22 1:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-18 11:21 Newbie questions on some of btrfs code Alex Lyakas
2012-05-18 11:50 ` Hugo Mills
2012-05-18 13:32 ` Alex Lyakas
2012-05-18 13:59 ` Hugo Mills
2012-05-20 7:40 ` Alex Lyakas
2012-05-21 1:59 ` Liu Bo
2012-05-21 8:20 ` Alex Lyakas
2012-05-21 9:33 ` Liu Bo
2012-05-21 10:05 ` Alex Lyakas
2012-05-22 1:42 ` Liu Bo [this message]
2012-05-22 7:48 ` Alex Lyakas
2012-05-21 10:44 ` Jan Schmidt
2012-05-22 8:07 ` Alex Lyakas
2012-05-22 22:08 ` Jan Schmidt
2012-05-28 18:45 ` Alex Lyakas
2012-05-29 9:13 ` Jan Schmidt
2012-05-29 11:27 ` Alex Lyakas
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=4FBAEF1E.4050706@cn.fujitsu.com \
--to=liubo2009@cn.fujitsu.com \
--cc=alex.bolshoy.btrfs@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).