mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 09:16:33 +00:00
btrfs: pass fs_info to functions that search for delayed ref heads
One of the following patches in the series will need to access fs_info in the function find_ref_head(), so pass a fs_info argument to it as well as to the functions btrfs_select_ref_head() and btrfs_find_delayed_ref_head() which call find_ref_head(). Reviewed-by: Boris Burkov <boris@bur.io> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
58a4391810
commit
765f828902
@ -1442,7 +1442,8 @@ static int find_parent_nodes(struct btrfs_backref_walk_ctx *ctx,
|
||||
*/
|
||||
delayed_refs = &ctx->trans->transaction->delayed_refs;
|
||||
spin_lock(&delayed_refs->lock);
|
||||
head = btrfs_find_delayed_ref_head(delayed_refs, ctx->bytenr);
|
||||
head = btrfs_find_delayed_ref_head(ctx->fs_info, delayed_refs,
|
||||
ctx->bytenr);
|
||||
if (head) {
|
||||
if (!mutex_trylock(&head->mutex)) {
|
||||
refcount_inc(&head->refs);
|
||||
|
@ -399,6 +399,7 @@ static struct btrfs_delayed_ref_head *find_first_ref_head(
|
||||
* is given, the next bigger entry is returned if no exact match is found.
|
||||
*/
|
||||
static struct btrfs_delayed_ref_head *find_ref_head(
|
||||
const struct btrfs_fs_info *fs_info,
|
||||
struct btrfs_delayed_ref_root *dr, u64 bytenr,
|
||||
bool return_bigger)
|
||||
{
|
||||
@ -558,6 +559,7 @@ int btrfs_check_delayed_seq(struct btrfs_fs_info *fs_info, u64 seq)
|
||||
}
|
||||
|
||||
struct btrfs_delayed_ref_head *btrfs_select_ref_head(
|
||||
const struct btrfs_fs_info *fs_info,
|
||||
struct btrfs_delayed_ref_root *delayed_refs)
|
||||
{
|
||||
struct btrfs_delayed_ref_head *head;
|
||||
@ -565,8 +567,8 @@ struct btrfs_delayed_ref_head *btrfs_select_ref_head(
|
||||
|
||||
spin_lock(&delayed_refs->lock);
|
||||
again:
|
||||
head = find_ref_head(delayed_refs, delayed_refs->run_delayed_start,
|
||||
true);
|
||||
head = find_ref_head(fs_info, delayed_refs,
|
||||
delayed_refs->run_delayed_start, true);
|
||||
if (!head && delayed_refs->run_delayed_start != 0) {
|
||||
delayed_refs->run_delayed_start = 0;
|
||||
head = find_first_ref_head(delayed_refs);
|
||||
@ -1188,11 +1190,13 @@ void btrfs_put_delayed_ref(struct btrfs_delayed_ref_node *ref)
|
||||
* head node if found, or NULL if not.
|
||||
*/
|
||||
struct btrfs_delayed_ref_head *
|
||||
btrfs_find_delayed_ref_head(struct btrfs_delayed_ref_root *delayed_refs, u64 bytenr)
|
||||
btrfs_find_delayed_ref_head(const struct btrfs_fs_info *fs_info,
|
||||
struct btrfs_delayed_ref_root *delayed_refs,
|
||||
u64 bytenr)
|
||||
{
|
||||
lockdep_assert_held(&delayed_refs->lock);
|
||||
|
||||
return find_ref_head(delayed_refs, bytenr, false);
|
||||
return find_ref_head(fs_info, delayed_refs, bytenr, false);
|
||||
}
|
||||
|
||||
static int find_comp(struct btrfs_delayed_ref_node *entry, u64 root, u64 parent)
|
||||
|
@ -367,7 +367,8 @@ void btrfs_merge_delayed_refs(struct btrfs_fs_info *fs_info,
|
||||
struct btrfs_delayed_ref_head *head);
|
||||
|
||||
struct btrfs_delayed_ref_head *
|
||||
btrfs_find_delayed_ref_head(struct btrfs_delayed_ref_root *delayed_refs,
|
||||
btrfs_find_delayed_ref_head(const struct btrfs_fs_info *fs_info,
|
||||
struct btrfs_delayed_ref_root *delayed_refs,
|
||||
u64 bytenr);
|
||||
static inline void btrfs_delayed_ref_unlock(struct btrfs_delayed_ref_head *head)
|
||||
{
|
||||
@ -377,6 +378,7 @@ void btrfs_delete_ref_head(struct btrfs_delayed_ref_root *delayed_refs,
|
||||
struct btrfs_delayed_ref_head *head);
|
||||
|
||||
struct btrfs_delayed_ref_head *btrfs_select_ref_head(
|
||||
const struct btrfs_fs_info *fs_info,
|
||||
struct btrfs_delayed_ref_root *delayed_refs);
|
||||
void btrfs_unselect_ref_head(struct btrfs_delayed_ref_root *delayed_refs,
|
||||
struct btrfs_delayed_ref_head *head);
|
||||
|
@ -182,7 +182,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
|
||||
|
||||
delayed_refs = &trans->transaction->delayed_refs;
|
||||
spin_lock(&delayed_refs->lock);
|
||||
head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
|
||||
head = btrfs_find_delayed_ref_head(fs_info, delayed_refs, bytenr);
|
||||
if (head) {
|
||||
if (!mutex_trylock(&head->mutex)) {
|
||||
refcount_inc(&head->refs);
|
||||
@ -2049,7 +2049,7 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
|
||||
|
||||
do {
|
||||
if (!locked_ref) {
|
||||
locked_ref = btrfs_select_ref_head(delayed_refs);
|
||||
locked_ref = btrfs_select_ref_head(fs_info, delayed_refs);
|
||||
if (IS_ERR_OR_NULL(locked_ref)) {
|
||||
if (PTR_ERR(locked_ref) == -EAGAIN) {
|
||||
continue;
|
||||
@ -2251,7 +2251,7 @@ static noinline int check_delayed_ref(struct btrfs_root *root,
|
||||
|
||||
delayed_refs = &cur_trans->delayed_refs;
|
||||
spin_lock(&delayed_refs->lock);
|
||||
head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
|
||||
head = btrfs_find_delayed_ref_head(root->fs_info, delayed_refs, bytenr);
|
||||
if (!head) {
|
||||
spin_unlock(&delayed_refs->lock);
|
||||
btrfs_put_transaction(cur_trans);
|
||||
@ -3359,7 +3359,7 @@ static noinline int check_ref_cleanup(struct btrfs_trans_handle *trans,
|
||||
|
||||
delayed_refs = &trans->transaction->delayed_refs;
|
||||
spin_lock(&delayed_refs->lock);
|
||||
head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
|
||||
head = btrfs_find_delayed_ref_head(trans->fs_info, delayed_refs, bytenr);
|
||||
if (!head)
|
||||
goto out_delayed_unlock;
|
||||
|
||||
@ -5494,7 +5494,7 @@ static int check_ref_exists(struct btrfs_trans_handle *trans,
|
||||
*/
|
||||
delayed_refs = &trans->transaction->delayed_refs;
|
||||
spin_lock(&delayed_refs->lock);
|
||||
head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
|
||||
head = btrfs_find_delayed_ref_head(root->fs_info, delayed_refs, bytenr);
|
||||
if (!head)
|
||||
goto out;
|
||||
if (!mutex_trylock(&head->mutex)) {
|
||||
|
Loading…
Reference in New Issue
Block a user