All of lore.kernel.org
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org,
	Dave Chinner <david@fromorbit.com>, Jann Horn <jannh@google.com>,
	Amir Goldstein <amir73il@gmail.com>,
	Aleksa Sarai <cyphar@cyphar.com>,
	linux-api@vger.kernel.org, kernel-team@fb.com
Subject: Re: [RFC PATCH v3 04/12] btrfs: get rid of trivial __btrfs_lookup_bio_sums() wrappers
Date: Tue, 26 Nov 2019 09:42:31 -0800	[thread overview]
Message-ID: <20191126174131.GB657777@vader> (raw)
In-Reply-To: <dc600214-0f19-b321-8573-6193b5f47e16@suse.com>

On Tue, Nov 26, 2019 at 03:56:31PM +0200, Nikolay Borisov wrote:
> 
> 
> On 20.11.19 г. 20:24 ч., Omar Sandoval wrote:
> > From: Omar Sandoval <osandov@fb.com>
> > 
> > Currently, we have two wrappers for __btrfs_lookup_bio_sums():
> > btrfs_lookup_bio_sums_dio(), which is used for direct I/O, and
> > btrfs_lookup_bio_sums(), which is used everywhere else. The only
> > difference is that the _dio variant looks up csums starting at the given
> > offset instead of using the page index, which isn't actually direct
> > I/O-specific. Let's clean up the signature and return value of
> > __btrfs_lookup_bio_sums(), rename it to btrfs_lookup_bio_sums(), and get
> > rid of the trivial helpers.
> > 
> > Signed-off-by: Omar Sandoval <osandov@fb.com>
> 
> Overall looks good but 2 nits, see below.
> 
> In any case:
> 
> Reviewed-by: Nikolay Borisov <nborisov@suse.com>

Thanks!

> > ---
> >  fs/btrfs/compression.c |  4 ++--
> >  fs/btrfs/ctree.h       |  4 +---
> >  fs/btrfs/file-item.c   | 35 +++++++++++++++++------------------
> >  fs/btrfs/inode.c       |  6 +++---
> >  4 files changed, 23 insertions(+), 26 deletions(-)
> > 
> > diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
> > index b05b361e2062..4df6f0c58dc9 100644
> > --- a/fs/btrfs/compression.c
> > +++ b/fs/btrfs/compression.c
> > @@ -660,7 +660,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
> >  
> >  			if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
> >  				ret = btrfs_lookup_bio_sums(inode, comp_bio,
> > -							    sums);
> > +							    false, 0, sums);
> >  				BUG_ON(ret); /* -ENOMEM */
> >  			}
> >  
> > @@ -689,7 +689,7 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
> >  	BUG_ON(ret); /* -ENOMEM */
> >  
> >  	if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
> > -		ret = btrfs_lookup_bio_sums(inode, comp_bio, sums);
> > +		ret = btrfs_lookup_bio_sums(inode, comp_bio, false, 0, sums);
> >  		BUG_ON(ret); /* -ENOMEM */
> >  	}
> >  
> > diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> > index fe2b8765d9e6..4bc40bf49b0e 100644
> > --- a/fs/btrfs/ctree.h
> > +++ b/fs/btrfs/ctree.h
> > @@ -2787,9 +2787,7 @@ struct btrfs_dio_private;
> >  int btrfs_del_csums(struct btrfs_trans_handle *trans,
> >  		    struct btrfs_fs_info *fs_info, u64 bytenr, u64 len);
> >  blk_status_t btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
> > -				   u8 *dst);
> > -blk_status_t btrfs_lookup_bio_sums_dio(struct inode *inode, struct bio *bio,
> > -			      u64 logical_offset);
> > +				   bool at_offset, u64 offset, u8 *dst);
> >  int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
> >  			     struct btrfs_root *root,
> >  			     u64 objectid, u64 pos,
> > diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
> > index 1a599f50837b..a87c40502267 100644
> > --- a/fs/btrfs/file-item.c
> > +++ b/fs/btrfs/file-item.c
> > @@ -148,8 +148,21 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
> >  	return ret;
> >  }
> >  
> > -static blk_status_t __btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
> > -				   u64 logical_offset, u8 *dst, int dio)
> > +/**
> > + * btrfs_lookup_bio_sums - Look up checksums for a bio.
> > + * @inode: inode that the bio is for.
> > + * @bio: bio embedded in btrfs_io_bio.
> > + * @at_offset: If true, look up checksums for the extent at @c offset.
> 
> nit: that @c is an editing artifact?

Oops, I mixed up kernel-doc with Doxygen. Fixed, thanks.

> On the other hand rather than
> having an explicit bool signifying whether we want a specific offset
> can't we simply check if offset is != 0 ?

Zero is a perfectly valid offset to have an extent at, but we could do
(u64)-1 instead. I'm not sure what's cleaner.

  reply	other threads:[~2019-11-26 17:42 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-20 18:24 [RFC PATCH v3 00/12] fs: interface for directly reading/writing compressed data Omar Sandoval
2019-11-20 18:24 ` [PATCH man-pages v2] Document encoded I/O Omar Sandoval
2019-11-20 18:24 ` [RFC PATCH v3 01/12] iov_iter: add copy_struct_from_iter() Omar Sandoval
2019-11-20 18:24 ` [RFC PATCH v3 02/12] fs: add O_ALLOW_ENCODED open flag Omar Sandoval
2019-11-20 18:24 ` [RFC PATCH v3 03/12] fs: add RWF_ENCODED for reading/writing compressed data Omar Sandoval
2019-11-26 13:53   ` Nikolay Borisov
2019-11-26 17:36     ` Omar Sandoval
2019-11-27  9:00       ` Nikolay Borisov
2019-11-27  9:10         ` Omar Sandoval
2019-11-20 18:24 ` [RFC PATCH v3 04/12] btrfs: get rid of trivial __btrfs_lookup_bio_sums() wrappers Omar Sandoval
2019-11-26 13:56   ` Nikolay Borisov
2019-11-26 17:42     ` Omar Sandoval [this message]
2019-11-20 18:24 ` [RFC PATCH v3 05/12] btrfs: don't advance offset for compressed bios in btrfs_csum_one_bio() Omar Sandoval
2019-11-26 14:18   ` Nikolay Borisov
2019-11-26 17:50     ` Omar Sandoval
2019-11-20 18:24 ` [RFC PATCH v3 06/12] btrfs: remove dead snapshot-aware defrag code Omar Sandoval
2019-11-26 15:13   ` Nikolay Borisov
2019-11-20 18:24 ` [RFC PATCH v3 07/12] btrfs: make btrfs_ordered_extent naming consistent with btrfs_file_extent_item Omar Sandoval
2019-11-20 18:24 ` [RFC PATCH v3 08/12] btrfs: add ram_bytes and offset to btrfs_ordered_extent Omar Sandoval
2019-11-27 10:13   ` Nikolay Borisov
2019-11-20 18:24 ` [RFC PATCH v3 09/12] btrfs: support different disk extent size for delalloc Omar Sandoval
2019-11-27 10:33   ` Nikolay Borisov
2019-11-20 18:24 ` [RFC PATCH v3 10/12] btrfs: optionally extend i_size in cow_file_range_inline() Omar Sandoval
2019-11-20 18:24 ` [RFC PATCH v3 11/12] btrfs: implement RWF_ENCODED reads Omar Sandoval
2019-11-20 18:24 ` [RFC PATCH v3 12/12] btrfs: implement RWF_ENCODED writes Omar Sandoval
2019-12-05 18:58 ` [RFC PATCH v3 00/12] fs: interface for directly reading/writing compressed data Omar Sandoval

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=20191126174131.GB657777@vader \
    --to=osandov@osandov.com \
    --cc=amir73il@gmail.com \
    --cc=cyphar@cyphar.com \
    --cc=david@fromorbit.com \
    --cc=jannh@google.com \
    --cc=kernel-team@fb.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@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.