From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Josef Bacik <josef@toxicpanda.com>, Qu Wenruo <wqu@suse.com>,
linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 1/3] btrfs: file-item: use nodesize to determine whether we need readhead for btrfs_lookup_bio_sums()
Date: Fri, 30 Oct 2020 07:57:40 +0800 [thread overview]
Message-ID: <a933c57a-7514-4db3-7fee-04af2e7becaf@gmx.com> (raw)
In-Reply-To: <946ec8c3-9480-e3c3-aad7-9b97e8aedf12@toxicpanda.com>
[-- Attachment #1.1: Type: text/plain, Size: 2289 bytes --]
On 2020/10/30 上午2:57, Josef Bacik wrote:
> On 10/29/20 3:12 AM, Qu Wenruo wrote:
>> In btrfs_lookup_bio_sums() if the bio is pretty large, we want to
>> readahead the csum tree.
>>
>> However the threshold is an immediate number, (PAGE_SIZE * 8), from the
>> initial btrfs merge.
>>
>> The value itself is pretty hard to guess the meaning, especially when
>> the immediate number is from the age where 4K sectorsize is the default
>> and only CRC32 is supported.
>>
>> For the most common btrfs setup, CRC32 csum algorithme 4K sectorsize,
>> it means just 32K read would kick readahead, while the csum itself is
>> only 32 bytes in size.
>>
>> Now let's be more reasonable by taking both csum size and node size into
>> consideration.
>>
>> If the csum size for the bio is larger than one node, then we kick the
>> readahead.
>> This means for current default btrfs, the threshold will be 16M.
>>
>> This change should not change performance observably, thus this is mostly
>> a readability enhancement.
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>> fs/btrfs/file-item.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
>> index 7d5ec71615b8..fbc60948b2c4 100644
>> --- a/fs/btrfs/file-item.c
>> +++ b/fs/btrfs/file-item.c
>> @@ -295,7 +295,11 @@ blk_status_t btrfs_lookup_bio_sums(struct inode
>> *inode, struct bio *bio,
>> csum = dst;
>> }
>> - if (bio->bi_iter.bi_size > PAGE_SIZE * 8)
>> + /*
>> + * If needed csum size is larger than a node, kick the readahead for
>> + * csum tree would be a good idea.
>> + */
>> + if (nblocks * csum_size > fs_info->nodesize)
>> path->reada = READA_FORWARD;
>
> Except if we have contiguous reads we could very well have all of our
> csums in a single item. It makes more sense to do something like
>
> if (nblocks * csum_size > MAX_CSUM_ITEMS() * csum_size)
Oh, thanks for this.
I was looking for things like that, but didn't find a handy one.
This indeed looks better.
>
> so that we're only readahead'ing when we're likely to need to look up
> multiple items. Thanks,
>
> Josef
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-10-29 23:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 7:12 [PATCH v2 0/3] btrfs: btrfs_lookup_bio_sums() related fixes Qu Wenruo
2020-10-29 7:12 ` [PATCH v2 1/3] btrfs: file-item: use nodesize to determine whether we need readhead for btrfs_lookup_bio_sums() Qu Wenruo
2020-10-29 18:57 ` Josef Bacik
2020-10-29 23:57 ` Qu Wenruo [this message]
2020-10-29 7:12 ` [PATCH v2 2/3] btrfs: file-item: remove the btrfs_find_ordered_sum() call in btrfs_lookup_bio_sums() Qu Wenruo
2020-10-29 7:47 ` Nikolay Borisov
2020-10-29 7:53 ` Qu Wenruo
2020-10-29 18:51 ` Josef Bacik
2020-10-29 7:12 ` [PATCH v2 3/3] btrfs: file-item: refactor btrfs_lookup_bio_sums() to handle out-of-order bvecs Qu Wenruo
2020-10-29 11:50 ` Nikolay Borisov
2020-10-29 12:43 ` Qu Wenruo
2020-10-29 13:54 ` David Sterba
2020-10-29 14:11 ` Qu Wenruo
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=a933c57a-7514-4db3-7fee-04af2e7becaf@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.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