Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Christoph Hellwig <hch@lst.de>, Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org,
	Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
Subject: Re: [PATCH] btrfs: don't merge pages into bio if their page offset is not continuous
Date: Sat, 13 Aug 2022 15:43:49 +0800	[thread overview]
Message-ID: <1f71de8a-2292-054e-913b-15e41b409de6@gmx.com> (raw)
In-Reply-To: <20220813073909.GA11586@lst.de>



On 2022/8/13 15:39, Christoph Hellwig wrote:
>> +	if (bio_ctrl->compress_type != BTRFS_COMPRESS_NONE) {
>>   		contig = bio->bi_iter.bi_sector == sector;
>> -	else
>> -		contig = bio_end_sector(bio) == sector;
>> +	} else {
>
> I don't tink we can lose the bio_end_sector check here.
>
> Also if you touch this, invrting the check so that it is
>
> 	if (bio_ctrl->compress_type == BTRFS_COMPRESS_NONE) {
> 		/* main version here */
> 	} else {
> 		/* compressed special case */
> 	}
>
> might make it a bit readable.

Indeed.

>
>> +		struct bio_vec *bvec;
>> +
>> +		/* Empty bio, we can always add page into it. */
>> +		if (bio->bi_iter.bi_size == 0) {
>
> This is also true for the compressed case, isn't it?

That is already implied in the "contig = bio->bi_iter.bi_sector ==
sector;" check.

Remember for compressed IO, we always set the the disk_bytenr to
whatever the bytenr of the extent start.

>
> So maybe:
>
> 	if (bio->bi_iter.bi_size == 0) {
> 		contig = true;
> 	} else if (bio_ctrl->compress_type == BTRFS_COMPRESS_NONE) {
> 		struct bio_vec *bvec = bio_last_bvec_all(bio);
>
> 		/*
> 		 * The contig check requires the following conditions to be met:
> 		 * 1) The pages are belonging to the same inode
> 		 * 2) The range has adjacent logical bytenr
> 		 * 3) The range has adjacent file offset (NEW)
> 		 *    This is required for the usage of btrfs_bio->file_offset.
> 		 */
> 		contig = bio_end_sector(bio) == sector &&
> 			    page_offset(bvec->bv_page) + bvec->bv_offset +
> 			    bvec->bv_len == page_offset(page) + pg_offset);
> 	} else {
> 		contig = bio->bi_iter.bi_sector == sector;
> 	}

This indeed looks better.

>
> (we don't need the mapping check, as all the submit_extent_page
> always loops over the same mapping)

Yep, that mapping check is already implied by the call chain.

BTW, I'll also update the commit message to mention some future
cleanups, as now a btrfs_bio is completely a continous range, thus
things like endio_readpage_release_extent() related infrastructure can
also be removed.

Thanks,
Qu

  reply	other threads:[~2022-08-13  7:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-13  7:28 [PATCH] btrfs: don't merge pages into bio if their page offset is not continuous Qu Wenruo
2022-08-13  7:39 ` Christoph Hellwig
2022-08-13  7:43   ` Qu Wenruo [this message]
2022-08-13  7:46     ` Christoph Hellwig

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=1f71de8a-2292-054e-913b-15e41b409de6@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=ce3g8jdj@umail.furryterror.org \
    --cc=hch@lst.de \
    --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