diff mbox series

[1/6] Turn delayed_nodes_tree into delayed_nodes_xarray in btrfs_root

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

Commit Message

Gabriel Niebler April 7, 2022, 3:38 p.m. UTC
… but don't use the XArray API yet.

This works, since the radix_tree_root struct has already been turned into an xarray behind the scenes, via a macro.

Signed-off-by: Gabriel Niebler <gniebler@suse.com>
---
 fs/btrfs/ctree.h         | 4 ++--
 fs/btrfs/delayed-inode.c | 8 ++++----
 fs/btrfs/disk-io.c       | 2 +-
 fs/btrfs/inode.c         | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

Comments

David Sterba April 7, 2022, 4:12 p.m. UTC | #1
On Thu, Apr 07, 2022 at 05:38:49PM +0200, Gabriel Niebler wrote:
> … but don't use the XArray API yet.
> 
> This works, since the radix_tree_root struct has already been turned into an xarray behind the scenes, via a macro.

Please align the text to 74 chars.

> Signed-off-by: Gabriel Niebler <gniebler@suse.com>
> ---
>  fs/btrfs/ctree.h         | 4 ++--
>  fs/btrfs/delayed-inode.c | 8 ++++----
>  fs/btrfs/disk-io.c       | 2 +-
>  fs/btrfs/inode.c         | 2 +-
>  4 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index b7631b88426e..ccd42a1638b1 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -1224,10 +1224,10 @@ struct btrfs_root {
>  	struct rb_root inode_tree;
>  
>  	/*
> -	 * radix tree that keeps track of delayed nodes of every inode,
> +	 * XArray that keeps track of delayed nodes of every inode,
>  	 * protected by inode_lock
>  	 */
> -	struct radix_tree_root delayed_nodes_tree;
> +	struct xarray delayed_nodes_xarray;

I'd rather not rename the variable, it's an implementation detail and
maybe dropping the _tree completely is a better idea.
diff mbox series

Patch

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index b7631b88426e..ccd42a1638b1 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1224,10 +1224,10 @@  struct btrfs_root {
 	struct rb_root inode_tree;
 
 	/*
-	 * radix tree that keeps track of delayed nodes of every inode,
+	 * XArray that keeps track of delayed nodes of every inode,
 	 * protected by inode_lock
 	 */
-	struct radix_tree_root delayed_nodes_tree;
+	struct xarray delayed_nodes_xarray;
 	/*
 	 * right now this just gets used so that a root has its own devid
 	 * for stat.  It may be used for more later
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 748bf6b0d860..14d95ed62ac3 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -78,7 +78,7 @@  static struct btrfs_delayed_node *btrfs_get_delayed_node(
 	}
 
 	spin_lock(&root->inode_lock);
-	node = radix_tree_lookup(&root->delayed_nodes_tree, ino);
+	node = radix_tree_lookup(&root->delayed_nodes_xarray, ino);
 
 	if (node) {
 		if (btrfs_inode->delayed_node) {
@@ -148,7 +148,7 @@  static struct btrfs_delayed_node *btrfs_get_or_create_delayed_node(
 	}
 
 	spin_lock(&root->inode_lock);
-	ret = radix_tree_insert(&root->delayed_nodes_tree, ino, node);
+	ret = radix_tree_insert(&root->delayed_nodes_xarray, ino, node);
 	if (ret == -EEXIST) {
 		spin_unlock(&root->inode_lock);
 		kmem_cache_free(delayed_node_cache, node);
@@ -276,7 +276,7 @@  static void __btrfs_release_delayed_node(
 		 * back up.  We can delete it now.
 		 */
 		ASSERT(refcount_read(&delayed_node->refs) == 0);
-		radix_tree_delete(&root->delayed_nodes_tree,
+		radix_tree_delete(&root->delayed_nodes_xarray,
 				  delayed_node->inode_id);
 		spin_unlock(&root->inode_lock);
 		kmem_cache_free(delayed_node_cache, delayed_node);
@@ -1876,7 +1876,7 @@  void btrfs_kill_all_delayed_nodes(struct btrfs_root *root)
 
 	while (1) {
 		spin_lock(&root->inode_lock);
-		n = radix_tree_gang_lookup(&root->delayed_nodes_tree,
+		n = radix_tree_gang_lookup(&root->delayed_nodes_xarray,
 					   (void **)delayed_nodes, inode_id,
 					   ARRAY_SIZE(delayed_nodes));
 		if (!n) {
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index b30309f187cf..efe8b37c9504 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1164,7 +1164,7 @@  static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info,
 	root->nr_delalloc_inodes = 0;
 	root->nr_ordered_extents = 0;
 	root->inode_tree = RB_ROOT;
-	INIT_RADIX_TREE(&root->delayed_nodes_tree, GFP_ATOMIC);
+	INIT_RADIX_TREE(&root->delayed_nodes_xarray, GFP_ATOMIC);
 
 	btrfs_init_root_block_rsv(root);
 
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 17d5557f98ec..1db667088380 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3827,7 +3827,7 @@  static int btrfs_read_locked_inode(struct inode *inode,
 	 * cache.
 	 *
 	 * This is required for both inode re-read from disk and delayed inode
-	 * in delayed_nodes_tree.
+	 * in delayed_nodes_xarray.
 	 */
 	if (BTRFS_I(inode)->last_trans == fs_info->generation)
 		set_bit(BTRFS_INODE_NEEDS_FULL_SYNC,