All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Nikolay Borisov <nborisov@suse.com>
Cc: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 19/19] btrfs: update documentation of set/get helpers
Date: Mon, 11 May 2020 15:10:28 +0200	[thread overview]
Message-ID: <20200511131028.GQ18421@twin.jikos.cz> (raw)
In-Reply-To: <1cb28f67-1d0f-fe8d-af78-f0ebd3213172@suse.com>

On Fri, May 08, 2020 at 12:33:08AM +0300, Nikolay Borisov wrote:
> On 7.05.20 г. 23:20 ч., David Sterba wrote:
> > Signed-off-by: David Sterba <dsterba@suse.com>
> > ---
> >  fs/btrfs/struct-funcs.c | 29 ++++++++++++++++-------------
> >  1 file changed, 16 insertions(+), 13 deletions(-)
> > 
> > diff --git a/fs/btrfs/struct-funcs.c b/fs/btrfs/struct-funcs.c
> > index 225ef6d7e949..1021b80f70db 100644
> > --- a/fs/btrfs/struct-funcs.c
> > +++ b/fs/btrfs/struct-funcs.c
> > @@ -39,23 +39,26 @@ static bool check_setget_bounds(const struct extent_buffer *eb,
> >  }
> >  
> >  /*
> > - * this is some deeply nasty code.
> > + * Macro templates that define helpers to read/write extent buffer data of a
> > + * given size, that are also used via ctree.h for access to item members via
> > + * specialized helpers.
> >   *
> > - * The end result is that anyone who #includes ctree.h gets a
> > - * declaration for the btrfs_set_foo functions and btrfs_foo functions,
> > - * which are wrappers of btrfs_set_token_#bits functions and
> > - * btrfs_get_token_#bits functions, which are defined in this file.
> > + * Generic helpers:
> > + * - btrfs_set_8 (for 8/16/32/64)
> > + * - btrfs_get_8 (for 8/16/32/64)
> >   *
> > - * These setget functions do all the extent_buffer related mapping
> > - * required to efficiently read and write specific fields in the extent
> > - * buffers.  Every pointer to metadata items in btrfs is really just
> > - * an unsigned long offset into the extent buffer which has been
> > - * cast to a specific type.  This gives us all the gcc type checking.
> > + * Generic helpes with a token, caching last page address:
> 
> nit: missing 'r' in 'helpers'. Without having looked into the code It's
> not obvious what a "token" is in this context, is it worth it perhaps
> documenting? ( I will take a look later and see if it's self-evident).

I could write it as

"Generic helpers with a token (a structure caching the address of most
recently accessed page)"

The use of 'last' is confusing as it's not the last as in the array.

> > + * - btrfs_set_token_8 (for 8/16/32/64)
> > + * - btrfs_get_token_8 (for 8/16/32/64)
> >   *
> > - * The extent buffer api is used to do the page spanning work required to
> > - * have a metadata blocksize different from the page size.
> > + * The set/get functions handle data spanning two pages transparently, in case
> > + * metadata block size is larger than page.  Every pointer to metadata items is
>        ^^^^^
> nit: s/metadata/btree/?

The terms should be interchangeable, but in the previous sentence it's 'metadata'
and this one continues, so I wonder how would 'btree' fit here.

All the structures here are on the higher level, so metadata etc, while
b-tree node is the storage.

> > + * an offset into the extent buffer page array, cast to a specific type.  This
> > + * gives us all the type checking.
> >   *
> > - * There are 2 variants defined, one with a token pointer and one without.
> > + * The extent buffer pages stored in the array pages do not form a contiguous
> > + * range, but the API functions assume the linear offset to the range from
> 
> nit: "contiguous physical range"

Ok.

> > + * 0 to metadata node size.
> >   */
> >  
> >  #define DEFINE_BTRFS_SETGET_BITS(bits)					\
> > 

  reply	other threads:[~2020-05-11 13:11 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07 20:19 [PATCH 00/19] Set/get helpers speedups and cleanups David Sterba
2020-05-07 20:19 ` [PATCH 01/19] btrfs: use the token::eb for all set/get helpers David Sterba
2020-05-08 12:05   ` Johannes Thumshirn
2020-05-07 20:19 ` [PATCH 02/19] btrfs: drop eb parameter from set/get token helpers David Sterba
2020-05-08 12:09   ` Johannes Thumshirn
2020-05-11 13:02     ` David Sterba
2020-05-11 14:41       ` Johannes Thumshirn
2020-05-07 20:19 ` [PATCH 03/19] btrfs: don't use set/get token for single assignment in overwrite_item David Sterba
2020-05-08 13:25   ` Johannes Thumshirn
2020-05-07 20:19 ` [PATCH 04/19] btrfs: don't use set/get token in leaf_space_used David Sterba
2020-05-08 13:27   ` Johannes Thumshirn
2020-05-07 20:19 ` [PATCH 05/19] btrfs: preset set/get token with first page and drop condition David Sterba
2020-05-08 13:37   ` Johannes Thumshirn
2020-05-07 20:19 ` [PATCH 06/19] btrfs: add separate bounds checker for set/get helpers David Sterba
2020-05-08 13:39   ` Johannes Thumshirn
2020-05-07 20:19 ` [PATCH 07/19] btrfs: speed up btrfs_get_##bits helpers David Sterba
2020-05-08 13:42   ` Johannes Thumshirn
2020-05-07 20:19 ` [PATCH 08/19] btrfs: speed up btrfs_get_token_##bits helpers David Sterba
2020-05-08 13:46   ` Johannes Thumshirn
2020-05-07 20:19 ` [PATCH 09/19] btrfs: speed up btrfs_set_##bits helpers David Sterba
2020-05-08 13:48   ` Johannes Thumshirn
2020-05-07 20:19 ` [PATCH 10/19] btrfs: speed up btrfs_set_token_##bits helpers David Sterba
2020-05-08 13:50   ` Johannes Thumshirn
2020-05-11 13:17     ` David Sterba
2020-05-07 20:19 ` [PATCH 11/19] btrfs: speed up and simplify generic_bin_search David Sterba
2020-05-08 14:04   ` Johannes Thumshirn
2020-05-07 20:19 ` [PATCH 12/19] btrfs: remove unused map_private_extent_buffer David Sterba
2020-05-08 14:05   ` Johannes Thumshirn
2020-05-07 20:19 ` [PATCH 13/19] btrfs: constify extent_buffer in the API functions David Sterba
2020-05-08 14:07   ` Johannes Thumshirn
2020-05-07 20:20 ` [PATCH 14/19] btrfs: drop unnecessary offset_in_page in extent buffer helpers David Sterba
2020-05-08 14:13   ` Johannes Thumshirn
2020-05-07 20:20 ` [PATCH 15/19] btrfs: optimize split page read in btrfs_get_##bits David Sterba
2020-05-08 14:17   ` Johannes Thumshirn
2020-05-07 20:20 ` [PATCH 16/19] btrfs: optimize split page read in btrfs_get_token_##bits David Sterba
2020-05-08 14:18   ` Johannes Thumshirn
2020-05-07 20:20 ` [PATCH 17/19] btrfs: optimize split page write in btrfs_set_##bits David Sterba
2020-05-08 14:20   ` Johannes Thumshirn
2020-05-07 20:20 ` [PATCH 18/19] btrfs: optimize split page write in btrfs_set_token_##bits David Sterba
2020-05-08 14:21   ` Johannes Thumshirn
2020-05-07 20:20 ` [PATCH 19/19] btrfs: update documentation of set/get helpers David Sterba
2020-05-07 21:33   ` Nikolay Borisov
2020-05-11 13:10     ` David Sterba [this message]
2020-05-11 14:16       ` Nikolay Borisov

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=20200511131028.GQ18421@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=dsterba@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.