mbox series

[0/6] Turn delayed_nodes_tree into XArray and adjust usages

Message ID 20220407153855.21089-1-gniebler@suse.com (mailing list archive)
Headers show
Series Turn delayed_nodes_tree into XArray and adjust usages | expand

Message

Gabriel Niebler April 7, 2022, 3:38 p.m. UTC
XArrays offer a somewhat nicer API than radix trees and were implemented
specifically to replace the latter. They utilize the exact same underlying
data structure, but their API is notionally easier to use, as it provides
array semantics to the user of radix trees. The higher level API also
takes care of locking, adding even more ease of use.

The btrfs code uses radix trees directly in several places, such as for the
`delayed_nodes_radix` member of the btrfs_root struct.

This patchset converts `delayed_nodes_radix` into an XArray, renames it
accordingly and adjusts all usages of this object to the XArray API.
It survived a complete fstests run.

Gabriel Niebler (6):
  Turn delayed_nodes_tree into delayed_nodes_xarray in btrfs_root
  btrfs_get_delayed_node: convert to using XArray API
  btrfs_get_or_create_delayed_node: convert to using XArray API
  __btrfs_release_delayed_node: convert to using XArray API
  btrfs_kill_all_delayed_nodes: convert to using XArray API
  __setup_root: convert to using XArray API for delayed_nodes_xarray

 fs/btrfs/ctree.h         |  4 ++--
 fs/btrfs/delayed-inode.c | 48 ++++++++++++++++++----------------------
 fs/btrfs/disk-io.c       |  2 +-
 fs/btrfs/inode.c         |  2 +-
 4 files changed, 26 insertions(+), 30 deletions(-)

Comments

David Sterba April 7, 2022, 4:44 p.m. UTC | #1
On Thu, Apr 07, 2022 at 05:38:48PM +0200, Gabriel Niebler wrote:
> XArrays offer a somewhat nicer API than radix trees and were implemented
> specifically to replace the latter. They utilize the exact same underlying
> data structure, but their API is notionally easier to use, as it provides
> array semantics to the user of radix trees. The higher level API also
> takes care of locking, adding even more ease of use.
> 
> The btrfs code uses radix trees directly in several places, such as for the
> `delayed_nodes_radix` member of the btrfs_root struct.
> 
> This patchset converts `delayed_nodes_radix` into an XArray, renames it
> accordingly and adjusts all usages of this object to the XArray API.
> It survived a complete fstests run.

So it converts just one structure, it would be better do it in one
patch otherwise it leaves the conversion half way and it's confusing to
see xarray structure in the radix-tree API.

> Gabriel Niebler (6):
>   Turn delayed_nodes_tree into delayed_nodes_xarray in btrfs_root
>   btrfs_get_delayed_node: convert to using XArray API
>   btrfs_get_or_create_delayed_node: convert to using XArray API
>   __btrfs_release_delayed_node: convert to using XArray API
>   btrfs_kill_all_delayed_nodes: convert to using XArray API
>   __setup_root: convert to using XArray API for delayed_nodes_xarray

The subject(s) should start with "btrfs: ..."
Gabriel Niebler April 11, 2022, 7:41 a.m. UTC | #2
Am 07.04.22 um 18:44 schrieb David Sterba:
> On Thu, Apr 07, 2022 at 05:38:48PM +0200, Gabriel Niebler wrote:
>> [...]
>> This patchset converts `delayed_nodes_radix` into an XArray, renames it
>> accordingly and adjusts all usages of this object to the XArray API.
>> It survived a complete fstests run.
> 
> So it converts just one structure, it would be better do it in one
> patch otherwise it leaves the conversion half way and it's confusing to
> see xarray structure in the radix-tree API.

Yes, I figured that converting each structure separately is easier to 
achieve for me, since the changes in this patch set are done, but 
changes to other structures are not (yet).

As for splitting the changes, as I did: My thought was that it's easier 
to review this way, patch-by-patch and that the important thing is that 
the conversion be done by the end of the patch set. But I do see the 
point that - even in a patch set - each patch should stand on its own 
and that does leave the code in an inconsistent (albeit working) state. 
Folding it all into one commit is not a problem and I will do that for 
resubmission.

> 
>> Gabriel Niebler (6):
>>    Turn delayed_nodes_tree into delayed_nodes_xarray in btrfs_root
>>    btrfs_get_delayed_node: convert to using XArray API
>>    btrfs_get_or_create_delayed_node: convert to using XArray API
>>    __btrfs_release_delayed_node: convert to using XArray API
>>    btrfs_kill_all_delayed_nodes: convert to using XArray API
>>    __setup_root: convert to using XArray API for delayed_nodes_xarray
> 
> The subject(s) should start with "btrfs: ..."
> 

OK, will fix.

I will also take the suggestions from the response to patch 1/6 on board.

Best,
gabe
David Sterba April 11, 2022, 2:17 p.m. UTC | #3
On Mon, Apr 11, 2022 at 09:41:54AM +0200, Gabriel Niebler wrote:
> Am 07.04.22 um 18:44 schrieb David Sterba:
> > On Thu, Apr 07, 2022 at 05:38:48PM +0200, Gabriel Niebler wrote:
> >> [...]
> >> This patchset converts `delayed_nodes_radix` into an XArray, renames it
> >> accordingly and adjusts all usages of this object to the XArray API.
> >> It survived a complete fstests run.
> > 
> > So it converts just one structure, it would be better do it in one
> > patch otherwise it leaves the conversion half way and it's confusing to
> > see xarray structure in the radix-tree API.
> 
> Yes, I figured that converting each structure separately is easier to 
> achieve for me, since the changes in this patch set are done, but 
> changes to other structures are not (yet).
> 
> As for splitting the changes, as I did: My thought was that it's easier 
> to review this way, patch-by-patch and that the important thing is that 
> the conversion be done by the end of the patch set.

The change splitting should be on the logical level and with focus on
a selected context, but there's no universal advice. In this case the
scope is one structure per patch, all actions with the structure are the
context that often remains same for all the API calls, splitting that
per patch does not help the review. Switching all structures in one
patch would mean that each call site is using a different structure so
the context is changing too often and that's adding to the congnitive
load.  Which leads to oversights and review quality goes down.