All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 8/9] btrfs: make btrfs_submit_compressed_read() to determine stripe boundary at bio allocation time
Date: Fri, 11 Jun 2021 16:16:36 +0800	[thread overview]
Message-ID: <3542ce4c-f2ce-c834-6866-eee6c28a967e@gmx.com> (raw)
In-Reply-To: <PH0PR04MB741678D81425B3F3E24DD28D9B349@PH0PR04MB7416.namprd04.prod.outlook.com>



On 2021/6/11 下午3:49, Johannes Thumshirn wrote:
> On 11/06/2021 03:32, Qu Wenruo wrote:
>> +		/* Allocate new bio if not allocated or already submitted */
>> +		if (!bio) {
>> +			bio = alloc_compressed_bio(cb, cur_disk_bytenr,
>> +				bio_op | write_flags,
>> +				end_compressed_bio_write,
>> +				&next_stripe_start);
>> +			if (IS_ERR(bio)) {
>> +				ret = errno_to_blk_status(PTR_ERR(bio));
>> +				bio = NULL;
>> +				goto finish_cb;
>> +			}
>> +		}
>> +		/*
>> +		 * We should never reach next_stripe_start, as if we reach the
>> +		 * boundary we will submit the bio immediately.
>> +		 */
>> +		ASSERT(cur_disk_bytenr != next_stripe_start);
>> +
>> +		/*
>> +		 * We have various limit on the real read size:
>> +		 * - stripe boundary
>> +		 * - page boundary
>> +		 * - compressed length boundary
>> +		 */
>> +		real_size = min_t(u64, U32_MAX,
>> +				  next_stripe_start - cur_disk_bytenr);
>> +		real_size = min_t(u64, real_size,
>> +				  PAGE_SIZE - offset_in_page(offset));
>> +		real_size = min_t(u64, real_size,
>> +				  compressed_len - offset);
>> +		ASSERT(IS_ALIGNED(real_size, fs_info->sectorsize));
>>
>> -	/* create and submit bios for the compressed pages */
>> -	bytes_left = compressed_len;
>> -	for (pg_index = 0; pg_index < cb->nr_pages; pg_index++) {
>> -		int submit = 0;
>> -		int len;
>> +		added = bio_add_page(bio, page, real_size,
>> +				     offset_in_page(offset));
>> +		/*
>> +		 * Maximum compressed extent size is 128K, we should never
>> +		 * reach bio size limit.
>> +		 */
>> +		ASSERT(added == real_size);
>>
>> -		page = compressed_pages[pg_index];
>> -		page->mapping = inode->vfs_inode.i_mapping;
>> -		if (bio->bi_iter.bi_size)
>> -			submit = btrfs_bio_fits_in_stripe(page, PAGE_SIZE, bio,
>> -							  0);
>> +		cur_disk_bytenr += added;
>>
>> -		if (pg_index == 0 && use_append)
>> -			len = bio_add_zone_append_page(bio, page, PAGE_SIZE, 0);
>> -		else
>> -			len = bio_add_page(bio, page, PAGE_SIZE, 0);
>
> I think you still need to distinguish between normal write and zone append here,
> as you adding pages to an already created bio.

Oh, my bad, forgot to handle the zoned append differently.

> Adding one page to an empty bio
> will always succeed but when adding more than one page to a zone append bio, you
> have to take the device's maximum zone append limit into account, as zone append
> bios can't be split. This is also the reason why we do the device
> lookup/bio_set_dev() for the zone append bios, so bio_add_zone_append_page() can
> look at the device's limitations when adding the pages.

Did you mean that for the bio_add_zone_append_page(), it may return less
bytes than we expected?
Even if our compressed write is ensured to be smaller than 128K?

Thanks,
Qu

  reply	other threads:[~2021-06-11  8:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-11  1:31 [PATCH 0/9] btrfs: compression: refactor and enhancement preparing for subpage compression support Qu Wenruo
2021-06-11  1:31 ` [PATCH 1/9] btrfs: remove a dead comment for btrfs_decompress_bio() Qu Wenruo
2021-06-11  3:26   ` Anand Jain
2021-06-11  1:31 ` [PATCH 2/9] btrfs: add compressed_bio::io_sectors to trace compressed bio more elegantly Qu Wenruo
2021-06-11  4:18   ` Anand Jain
2021-06-11  6:02     ` Qu Wenruo
2021-06-11  7:28   ` Johannes Thumshirn
2021-06-11  1:31 ` [PATCH 3/9] btrfs: hunt down the BUG_ON()s inside btrfs_submit_compressed_read() Qu Wenruo
2021-06-11  1:31 ` [PATCH 4/9] btrfs: hunt down the BUG_ON()s inside btrfs_submit_compressed_write() Qu Wenruo
2021-06-11  7:36   ` Johannes Thumshirn
2021-06-11  7:46     ` Qu Wenruo
2021-06-11  1:31 ` [PATCH 5/9] btrfs: introduce submit_compressed_bio() for compression Qu Wenruo
2021-06-11  1:31 ` [PATCH 6/9] btrfs: introduce alloc_submit_compressed_bio() " Qu Wenruo
2021-06-11  1:31 ` [PATCH 7/9] btrfs: make btrfs_submit_compressed_read() to determine stripe boundary at bio allocation time Qu Wenruo
2021-06-11  7:42   ` Johannes Thumshirn
2021-06-11  1:31 ` [PATCH 8/9] " Qu Wenruo
2021-06-11  7:49   ` Johannes Thumshirn
2021-06-11  8:16     ` Qu Wenruo [this message]
2021-06-11  8:19       ` Johannes Thumshirn
2021-06-11  8:26         ` Qu Wenruo
2021-06-11 12:40         ` Qu Wenruo
2021-06-11 12:43           ` Johannes Thumshirn
2021-06-11  1:31 ` [PATCH 9/9] btrfs: remove unused function btrfs_bio_fits_in_stripe() 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=3542ce4c-f2ce-c834-6866-eee6c28a967e@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=Johannes.Thumshirn@wdc.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.