Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: Filipe Manana <fdmanana@kernel.org>, Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: linux-btrfs@vger.kernel.org, David Sterba <dsterba@suse.com>
Subject: Re: [PATCH v2 03/11] btrfs: introduce new members for extent_map
Date: Sat, 11 May 2024 07:56:57 +0930	[thread overview]
Message-ID: <f545d678-3494-4185-a8b1-384df1b9b8ae@suse.com> (raw)
In-Reply-To: <CAL3q7H6rz9Z8xCbsjvqaEQC34m7uiM_FH1ecW+PQC5kARWKxrA@mail.gmail.com>



在 2024/5/10 20:56, Filipe Manana 写道:
[...]
>>
>> Check case 1).
>>
>> Both file extents are referring to the same data extent.
>>
>> Like this:
>>
>> FE 1, file pos 0, num_bytes 4K, disk_bytenr X, disk_num_bytes 16K,
>> offset 0, ram_bytes 16K, compression none
>>
>> FE 2, file pos 4k, num_bytes 4K, disk_bytenr X, disk_num_bytes 16K,
>> offset 4k, ram_bytes 16K, compression none.
>>
>> In that case we should not just sum up the disk_num_bytes at all.
>> Remember disk_num_bytes are for the data extent.
> 
> Yes, but for cases where they refer to different file extent items
> that are contiguous on disk, the max is confusing, and a sum is what
> makes sense. Example:
> 
> FE 1, file pos 0, num_bytes 4K, disk_bytenr X, disk_num_bytes 4K,
> offset 0, ram_bytes 4K, no compression
> 
> FE 2, file pos 4K, num_bytes 4K, disk_bytenr X + 4K, disk_num_bytes
> 4K, offset 0, ram_bytes 4K, no compression
> 
> When merging the corresponding extent maps it's natural to think
> disk_num_bytes is 8K and not 4K.

The max based solution is based on their end bytenr, not disk_num_bytes.

So the merged one would have:

disk_bytenr = min(X, X + 4K) = X
disk_num_bytes = max(X + 4K, X + 4K + 4K) - disk_bytenr = 8K.

So I didn't see why it's not natural.

Furthermore, the max/min based solution can handle both case 1) (same 
data extent, different parts) and case 2) (different data extents) well.

> 
> But as I mentioned before, after merging we really don't use
> disk_num_bytes anywhere.
> It's only used during extent logging, which only happens for extents
> maps that were not merged and can not be before they are logged.
> 
> Before this patchset, when disk_num_bytes was named orig_block_len,
> that was never updated during merging, exactly because we don't use
> cases for it.

But since we want everything to match the definition of the same-named 
member, no matter if they get merged or not, we need to change the values.

If they do not get used, that's still fine.

Thanks,
Qu

  reply	other threads:[~2024-05-10 22:27 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-03  6:01 [PATCH v2 00/11] btrfs: extent-map: unify the members with btrfs_ordered_extent Qu Wenruo
2024-05-03  6:01 ` [PATCH v2 01/11] btrfs: rename extent_map::orig_block_len to disk_num_bytes Qu Wenruo
2024-05-09 16:15   ` Filipe Manana
2024-05-03  6:01 ` [PATCH v2 02/11] btrfs: export the expected file extent through can_nocow_extent() Qu Wenruo
2024-05-09 16:22   ` Filipe Manana
2024-05-09 21:55     ` Qu Wenruo
2024-05-03  6:01 ` [PATCH v2 03/11] btrfs: introduce new members for extent_map Qu Wenruo
2024-05-09 17:05   ` Filipe Manana
2024-05-09 22:11     ` Qu Wenruo
2024-05-10 11:26       ` Filipe Manana
2024-05-10 22:26         ` Qu Wenruo [this message]
2024-05-13 12:48   ` Filipe Manana
2024-05-13 12:54     ` Filipe Manana
2024-05-13 17:31   ` Filipe Manana
2024-05-03  6:01 ` [PATCH v2 04/11] btrfs: introduce extra sanity checks for extent maps Qu Wenruo
2024-05-13 12:21   ` Filipe Manana
2024-05-13 22:34     ` Qu Wenruo
2024-05-03  6:01 ` [PATCH v2 05/11] btrfs: remove extent_map::orig_start member Qu Wenruo
2024-05-13 13:09   ` Filipe Manana
2024-05-13 22:14     ` Qu Wenruo
2024-05-03  6:01 ` [PATCH v2 06/11] btrfs: remove extent_map::block_len member Qu Wenruo
2024-05-13 17:44   ` Filipe Manana
2024-05-14  7:09     ` Qu Wenruo
2024-05-03  6:01 ` [PATCH v2 07/11] btrfs: remove extent_map::block_start member Qu Wenruo
2024-05-16 17:28   ` Filipe Manana
2024-05-16 22:45     ` Qu Wenruo
2024-05-03  6:01 ` [PATCH v2 08/11] btrfs: cleanup duplicated parameters related to can_nocow_file_extent_args Qu Wenruo
2024-05-20 15:55   ` Filipe Manana
2024-05-20 22:13     ` Qu Wenruo
2024-05-03  6:01 ` [PATCH v2 09/11] btrfs: cleanup duplicated parameters related to btrfs_alloc_ordered_extent Qu Wenruo
2024-05-20 16:31   ` Filipe Manana
2024-05-03  6:01 ` [PATCH v2 10/11] btrfs: cleanup duplicated parameters related to create_io_em() Qu Wenruo
2024-05-20 16:46   ` Filipe Manana
2024-05-03  6:01 ` [PATCH v2 11/11] btrfs: cleanup duplicated parameters related to btrfs_create_dio_extent() Qu Wenruo
2024-05-20 16:48   ` Filipe Manana
2024-05-23  4:03     ` Qu Wenruo
2024-05-03 11:53 ` [PATCH v2 00/11] btrfs: extent-map: unify the members with btrfs_ordered_extent David Sterba
2024-05-20 16:55 ` Filipe Manana

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=f545d678-3494-4185-a8b1-384df1b9b8ae@suse.com \
    --to=wqu@suse.com \
    --cc=dsterba@suse.com \
    --cc=fdmanana@kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo.btrfs@gmx.com \
    /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