All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: move root node locking helpers to locking.c
@ 2020-02-05 16:26 David Sterba
  2020-02-06  3:58 ` Anand Jain
  2020-02-06 15:45 ` Josef Bacik
  0 siblings, 2 replies; 3+ messages in thread
From: David Sterba @ 2020-02-05 16:26 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The helpers are related to locking so move them there, update comments.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ctree.c   | 38 --------------------------------------
 fs/btrfs/locking.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 38 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 968faaec0e39..b62721ac5ee8 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -143,44 +143,6 @@ struct extent_buffer *btrfs_root_node(struct btrfs_root *root)
 	return eb;
 }
 
-/* loop around taking references on and locking the root node of the
- * tree until you end up with a lock on the root.  A locked buffer
- * is returned, with a reference held.
- */
-struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root)
-{
-	struct extent_buffer *eb;
-
-	while (1) {
-		eb = btrfs_root_node(root);
-		btrfs_tree_lock(eb);
-		if (eb == root->node)
-			break;
-		btrfs_tree_unlock(eb);
-		free_extent_buffer(eb);
-	}
-	return eb;
-}
-
-/* loop around taking references on and locking the root node of the
- * tree until you end up with a lock on the root.  A locked buffer
- * is returned, with a reference held.
- */
-struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root)
-{
-	struct extent_buffer *eb;
-
-	while (1) {
-		eb = btrfs_root_node(root);
-		btrfs_tree_read_lock(eb);
-		if (eb == root->node)
-			break;
-		btrfs_tree_read_unlock(eb);
-		free_extent_buffer(eb);
-	}
-	return eb;
-}
-
 /* cowonly root (everything not a reference counted cow subvolume), just get
  * put onto a simple dirty list.  transaction.c walks this to make sure they
  * get properly updated on disk.
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index 571c4826c428..e713900f96b6 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -523,3 +523,45 @@ void btrfs_unlock_up_safe(struct btrfs_path *path, int level)
 		path->locks[i] = 0;
 	}
 }
+
+/*
+ * Loop around taking references on and locking the root node of the tree until
+ * we end up with a lock on the root node.
+ *
+ * Return: root extent buffer with write lock held
+ */
+struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root)
+{
+	struct extent_buffer *eb;
+
+	while (1) {
+		eb = btrfs_root_node(root);
+		btrfs_tree_lock(eb);
+		if (eb == root->node)
+			break;
+		btrfs_tree_unlock(eb);
+		free_extent_buffer(eb);
+	}
+	return eb;
+}
+
+/*
+ * Loop around taking references on and locking the root node of the tree until
+ * we end up with a lock on the root node.
+ *
+ * Return: root extent buffer with read lock held
+ */
+struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root)
+{
+	struct extent_buffer *eb;
+
+	while (1) {
+		eb = btrfs_root_node(root);
+		btrfs_tree_read_lock(eb);
+		if (eb == root->node)
+			break;
+		btrfs_tree_read_unlock(eb);
+		free_extent_buffer(eb);
+	}
+	return eb;
+}
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: move root node locking helpers to locking.c
  2020-02-05 16:26 [PATCH] btrfs: move root node locking helpers to locking.c David Sterba
@ 2020-02-06  3:58 ` Anand Jain
  2020-02-06 15:45 ` Josef Bacik
  1 sibling, 0 replies; 3+ messages in thread
From: Anand Jain @ 2020-02-06  3:58 UTC (permalink / raw)
  To: David Sterba, linux-btrfs

On 2/6/20 12:26 AM, David Sterba wrote:
> The helpers are related to locking so move them there, update comments.
> 
> Signed-off-by: David Sterba <dsterba@suse.com>

Reviewed-by: Anand Jain <anand.jain@oracle.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: move root node locking helpers to locking.c
  2020-02-05 16:26 [PATCH] btrfs: move root node locking helpers to locking.c David Sterba
  2020-02-06  3:58 ` Anand Jain
@ 2020-02-06 15:45 ` Josef Bacik
  1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2020-02-06 15:45 UTC (permalink / raw)
  To: David Sterba, linux-btrfs

On 2/5/20 11:26 AM, David Sterba wrote:
> The helpers are related to locking so move them there, update comments.
> 
> Signed-off-by: David Sterba <dsterba@suse.com>

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-06 15:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-05 16:26 [PATCH] btrfs: move root node locking helpers to locking.c David Sterba
2020-02-06  3:58 ` Anand Jain
2020-02-06 15:45 ` Josef Bacik

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.