public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Nikolay Borisov <nborisov@suse.com>
Cc: dsterba@suse.cz, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/7] btrfs: Don't call readpage_end_io_hook for the btree inode
Date: Wed, 23 Sep 2020 16:10:09 +0200	[thread overview]
Message-ID: <20200923141009.GN6756@twin.jikos.cz> (raw)
In-Reply-To: <f874055e-34d7-f972-9cfc-551dbbd023a8@suse.com>

On Wed, Sep 23, 2020 at 09:29:00AM +0300, Nikolay Borisov wrote:
> 
> 
> On 21.09.20 г. 20:45 ч., David Sterba wrote:
> > On Fri, Sep 18, 2020 at 04:34:33PM +0300, Nikolay Borisov wrote:
> >> Instead of relying on indirect calls to implement metadata buffer
> >> validation simply check if the inode whose page we are processing equals
> >> the btree inode. If it does call the necessary function.
> >>
> >> This is an improvement in 2 directions:
> >> 1. We aren't paying the penalty of indirect calls in a post-speculation
> >>    attacks world.
> >>
> >> 2. The function is now named more explicitly so it's obvious what's
> >>    going on
> > 
> > The new naming is not making things clear, btrfs_check_csum sounds very
> > generic while it does a very specific thing just by the number and type
> > of the parameters. Similar for btrfs_validate_metadata_buffer.
> > 
> >> --- a/fs/btrfs/extent_io.c
> >> +++ b/fs/btrfs/extent_io.c
> >> @@ -2851,9 +2851,12 @@ static void end_bio_extent_readpage(struct bio *bio)
> >>  
> >>  		mirror = io_bio->mirror_num;
> >>  		if (likely(uptodate)) {
> >> -			ret = tree->ops->readpage_end_io_hook(io_bio, offset,
> >> -							      page, start, end,
> >> -							      mirror);
> >> +			if (data_inode)
> >> +				ret = btrfs_check_csum(io_bio, offset, page,
> >> +						       start, end, mirror);
> >> +			else
> >> +				ret = btrfs_validate_metadata_buffer(io_bio,
> >> +					offset, page, start, end, mirror);
> > 
> > In the context where the functions are used I'd expect some symmetry,
> > data/metadata. Something like btrfs_validate_data_bio.
> > 
> 
> The reason for this naming is that btrfs_vlidate_metadata_buffer
> actually validates as in "tree-checker style validation" of the extent
> buffer not simply calculating the checksum. So to me it feels like a
> more complete,heavyweight operations hence "validating", whlist
> btrfs_check_csum just checks the csum of a single sector/blocksize in
> the bio. I think the metadata function's name conveys what it's doing in
> full:
> 
> 1. It's doing validation as per aforementioned explanation
> 2. It's doing it for a whole extent buffer and not just a chunk of it.

No problem with the metadata function name, I agree with the reasoning
above.

> I agree that the data function's name is somewhat generic, perhahps it
> could be renamed so that it points to the fact it's validating a single
> sector/blocksize? I.e btrfs_check_ blocksize_csum or something like that ?

Yeah, that the data have a simpler validation maybe does not deserve to
be called like that. We should not use 'sector' here as bios use that
too. So btrfs_check_data_block_csum or btrfs_check_block_csum?

  reply	other threads:[~2020-09-23 14:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-18 13:34 [PATCH 0/7] Remove struct extent_io_ops Nikolay Borisov
2020-09-18 13:34 ` [PATCH 1/7] btrfs: Don't call readpage_end_io_hook for the btree inode Nikolay Borisov
2020-09-18 13:41   ` Nikolay Borisov
2020-09-21 14:54   ` Johannes Thumshirn
2020-09-21 17:45   ` David Sterba
2020-09-23  6:29     ` Nikolay Borisov
2020-09-23 14:10       ` David Sterba [this message]
2020-09-18 13:34 ` [PATCH 2/7] btrfs: Remove extent_io_ops::readpage_end_io_hook Nikolay Borisov
2020-09-21 14:58   ` Johannes Thumshirn
2020-09-18 13:34 ` [PATCH 3/7] btrfs: Call submit_bio_hook directly in submit_one_bio Nikolay Borisov
2020-09-18 13:34 ` [PATCH 4/7] btrfs: Don't opencode is_data_inode in end_bio_extent_readpage Nikolay Borisov
2020-09-21 20:29   ` David Sterba
2020-09-23  6:23     ` Nikolay Borisov
2020-09-23 14:11       ` David Sterba
2020-09-18 13:34 ` [PATCH 5/7] btrfs: Stop calling submit_bio_hook for data inodes Nikolay Borisov
2020-09-18 13:34 ` [PATCH 6/7] btrfs: Call submit_bio_hook directly for metadata pages Nikolay Borisov
2020-09-21 15:04   ` Johannes Thumshirn
2020-09-21 20:32     ` David Sterba
2020-09-23  6:24       ` Nikolay Borisov
2020-09-18 13:34 ` [PATCH 7/7] btrfs: Remove struct extent_io_ops Nikolay Borisov
2020-09-21 20:38   ` David Sterba
2020-09-23  6:25     ` Nikolay Borisov
2020-09-23 14:19       ` David Sterba
2020-09-23 14:23         ` Nikolay Borisov
2020-09-23 15:09           ` David Sterba
2020-09-21 15:05 ` [PATCH 0/7] " Johannes Thumshirn
2020-09-24 11:35 ` David Sterba

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=20200923141009.GN6756@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox