All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: Nikolay Borisov <nborisov@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 13/17] btrfs: extent_io: only require sector size alignment for page read
Date: Tue, 15 Sep 2020 09:54:48 +0800	[thread overview]
Message-ID: <6a515ae8-7357-7383-9501-e876b905248f@suse.com> (raw)
In-Reply-To: <89fd9545-c539-3f58-e48a-218a9b111edd@suse.com>



On 2020/9/11 下午9:55, Nikolay Borisov wrote:
> 
> 
> On 8.09.20 г. 10:52 ч., Qu Wenruo wrote:
>> If we're reading partial page, btrfs will warn about this as our
>> read/write are always done in sector size, which equals page size.
>>
>> But for the incoming subpage RO support, our data read is only aligned
>> to sectorsize, which can be smaller than page size.
>>
>> Thus here we change the warning condition to check it against
>> sectorsize, thus the behavior is not changed for regular sectorsize ==
>> PAGE_SIZE case, while won't report error for subpage read.
>>
>> Also, pass the proper start/end with bv_offset for check_data_csum() to
>> handle.
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>>  fs/btrfs/extent_io.c | 19 ++++++++++++-------
>>  1 file changed, 12 insertions(+), 7 deletions(-)
>>
>> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
>> index 81e43d99feda..a83b63ecc5f8 100644
>> --- a/fs/btrfs/extent_io.c
>> +++ b/fs/btrfs/extent_io.c
>> @@ -2819,6 +2819,7 @@ static void end_bio_extent_readpage(struct bio *bio)
>>  		struct page *page = bvec->bv_page;
>>  		struct inode *inode = page->mapping->host;
>>  		struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
>> +		u32 sectorsize = fs_info->sectorsize;
>>  		bool data_inode = btrfs_ino(BTRFS_I(inode))
>>  			!= BTRFS_BTREE_INODE_OBJECTID;
>>  
>> @@ -2829,13 +2830,17 @@ static void end_bio_extent_readpage(struct bio *bio)
>>  		tree = &BTRFS_I(inode)->io_tree;
>>  		failure_tree = &BTRFS_I(inode)->io_failure_tree;
>>  
>> -		/* We always issue full-page reads, but if some block
>> +		/*
>> +		 * We always issue full-sector reads, but if some block
>>  		 * in a page fails to read, blk_update_request() will
>>  		 * advance bv_offset and adjust bv_len to compensate.
>> -		 * Print a warning for nonzero offsets, and an error
>> -		 * if they don't add up to a full page.  */
>> -		if (bvec->bv_offset || bvec->bv_len != PAGE_SIZE) {
>> -			if (bvec->bv_offset + bvec->bv_len != PAGE_SIZE)
>> +		 * Print a warning for unaligned offsets, and an error
>> +		 * if they don't add up to a full sector.
>> +		 */
>> +		if (!IS_ALIGNED(bvec->bv_offset, sectorsize) ||
>> +		    !IS_ALIGNED(bvec->bv_offset + bvec->bv_len, sectorsize)) {
>> +			if (!IS_ALIGNED(bvec->bv_offset + bvec->bv_len,
>> +					sectorsize))
> 
> Duplicated check ...

BTW, this is not duplicated, it's to distinguish two different error
patterns...
One for read request which doesn't end at sector boundary, and the other
one for which doesn't start at sector boundary.

> 
>>  				btrfs_err(fs_info,
>>  					"partial page read in btrfs with offset %u and length %u",
>>  					bvec->bv_offset, bvec->bv_len);
>> @@ -2845,8 +2850,8 @@ static void end_bio_extent_readpage(struct bio *bio)
>>  					bvec->bv_offset, bvec->bv_len);
>>  		}
>>  
>> -		start = page_offset(page);
>> -		end = start + bvec->bv_offset + bvec->bv_len - 1;
>> +		start = page_offset(page) + bvec->bv_offset;
>> +		end = start + bvec->bv_len - 1;
> 
> nit: 'start' and 'end' must really be renamed - to file_offset and
> file_end because they represent values in the logical namespace of the
> file. And given the context they are used i.e endio handler where we
> also deal with extent starts and physical offsets such a rename is long
> over due. Perhaps you can create a separate patch when  you are
> resending the series alternatively I'll make a sweep across those
> low-level functions to clean that up.

I guess we could do that in another patchset.

The naming is really aweful, but there are tons of other similar
situations across the code base.

It may be a big batch of work to properly unify the naming.

And the naming itself will take some time to mature.

We have a lot of different terms which share the similar meanings but
still slightly different:
- bytenr
  btrfs logical bytenr

- file_offset
  the offset inside a file

And in this particular case, for btree inode, bytenr == file_offset,
which may make things more complex.

While for regualr file inodes, file_offset is different from the extent
bytenr.

So we really need to come out with a proper term table for this...

Thanks,
Qu

> 
>>  		len = bvec->bv_len;
>>  
>>  		mirror = io_bio->mirror_num;
>>
> 


  reply	other threads:[~2020-09-15  1:55 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08  7:52 [PATCH 00/17] btrfs: add read-only support for subpage sector size Qu Wenruo
2020-09-08  7:52 ` [PATCH 01/17] btrfs: extent-io-tests: remove invalid tests Qu Wenruo
2020-09-09 12:26   ` Nikolay Borisov
2020-09-09 13:06     ` Qu Wenruo
2020-09-08  7:52 ` [PATCH 02/17] btrfs: calculate inline extent buffer page size based on page size Qu Wenruo
2020-09-11  9:56   ` Nikolay Borisov
2020-09-11 10:13     ` Qu Wenruo
2020-09-08  7:52 ` [PATCH 03/17] btrfs: remove the open-code to read disk-key Qu Wenruo
2020-09-11 10:07   ` Nikolay Borisov
2020-09-08  7:52 ` [PATCH 04/17] btrfs: make btrfs_fs_info::buffer_radix to take sector size devided values Qu Wenruo
2020-09-08 18:03   ` kernel test robot
2020-09-11 10:11   ` Nikolay Borisov
2020-09-11 10:15     ` Qu Wenruo
2020-09-08  7:52 ` [PATCH 05/17] btrfs: don't allow tree block to cross page boundary for subpage support Qu Wenruo
2020-09-11 10:26   ` Nikolay Borisov
2020-09-11 11:36     ` Qu Wenruo
2020-09-11 12:08       ` Nikolay Borisov
2020-09-08  7:52 ` [PATCH 06/17] btrfs: handle sectorsize < PAGE_SIZE case for extent buffer accessors Qu Wenruo
2020-09-08  7:52 ` [PATCH 07/17] btrfs: make csum_tree_block() handle sectorsize smaller than page size Qu Wenruo
2020-09-11 11:10   ` Nikolay Borisov
2020-09-08  7:52 ` [PATCH 08/17] btrfs: refactor how we extract extent buffer from page for alloc_extent_buffer() Qu Wenruo
2020-09-11 11:14   ` Nikolay Borisov
2020-09-08  7:52 ` [PATCH 09/17] btrfs: refactor btrfs_release_extent_buffer_pages() Qu Wenruo
2020-09-11 11:17   ` Nikolay Borisov
2020-09-11 11:39     ` Qu Wenruo
2020-09-08  7:52 ` [PATCH 10/17] btrfs: add assert_spin_locked() for attach_extent_buffer_page() Qu Wenruo
2020-09-11 11:22   ` Nikolay Borisov
2020-09-08  7:52 ` [PATCH 11/17] btrfs: extract the extent buffer verification from btree_readpage_end_io_hook() Qu Wenruo
2020-09-11 13:00   ` Nikolay Borisov
2020-09-08  7:52 ` [PATCH 12/17] btrfs: remove the unnecessary parameter @start and @len for check_data_csum() Qu Wenruo
2020-09-11 13:50   ` Nikolay Borisov
2020-09-08  7:52 ` [PATCH 13/17] btrfs: extent_io: only require sector size alignment for page read Qu Wenruo
2020-09-11 13:55   ` Nikolay Borisov
2020-09-15  1:54     ` Qu Wenruo [this message]
2020-09-08  7:52 ` [PATCH 14/17] btrfs: make btrfs_readpage_end_io_hook() follow sector size Qu Wenruo
2020-09-09 17:34   ` Goldwyn Rodrigues
2020-09-10  0:05     ` Qu Wenruo
2020-09-10 14:26       ` Goldwyn Rodrigues
2020-09-08  7:52 ` [PATCH 15/17] btrfs: introduce subpage_eb_mapping for extent buffers Qu Wenruo
2020-09-08 10:22   ` kernel test robot
2020-09-08 10:22     ` kernel test robot
2020-09-08 12:11   ` kernel test robot
2020-09-08 14:24   ` Dan Carpenter
2020-09-08 14:24     ` Dan Carpenter
2020-09-08 14:24     ` Dan Carpenter
2020-09-08  7:52 ` [PATCH 16/17] btrfs: handle extent buffer verification proper for subpage size Qu Wenruo
2020-09-08  7:52 ` [PATCH 17/17] btrfs: allow RO mount of 4K sector size fs on 64K page system Qu Wenruo
2020-09-08  8:03 ` [PATCH 00/17] btrfs: add read-only support for subpage sector size Qu Wenruo
2020-09-11 10:24 ` 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=6a515ae8-7357-7383-9501-e876b905248f@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@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 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.