btrfs-progs/kernel-shared/locking.c
Josef Bacik ba01aadff1 btrfs-progs: take a ref in the root locking code
This code in the kernel not only returns the locked root, but also takes
a reference on the node.  This is important for when we sync ctree.c
into btrfs-progs, it expects that references are held on the root node
after calling these helpers.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-08-28 17:24:25 +02:00

23 lines
464 B
C

/* SPDX-License-Identifier: GPL-2.0 */
#include "kernel-shared/ctree.h"
#include "kernel-shared/locking.h"
struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root)
{
root->node->refs++;
return root->node;
}
struct extent_buffer *btrfs_try_read_lock_root_node(struct btrfs_root *root)
{
root->node->refs++;
return root->node;
}
struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root)
{
root->node->refs++;
return root->node;
}