Commit ffeb03cf authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: cleanup the locking in btrfs_next_old_leaf

We are carrying around this next_rw_lock from when we would do spinning
vs blocking read locks.  Now that we have the rwsem locking we can
simply use the read lock flag unconditionally and the read lock helpers.
Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent b2598edf
......@@ -5272,7 +5272,6 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path,
struct btrfs_key key;
u32 nritems;
int ret;
int next_rw_lock = 0;
nritems = btrfs_header_nritems(path->nodes[0]);
if (nritems == 0)
......@@ -5282,7 +5281,6 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path,
again:
level = 1;
next = NULL;
next_rw_lock = 0;
btrfs_release_path(path);
path->keep_locks = 1;
......@@ -5346,12 +5344,11 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path,
}
if (next) {
btrfs_tree_unlock_rw(next, next_rw_lock);
btrfs_tree_read_unlock(next);
free_extent_buffer(next);
}
next = c;
next_rw_lock = path->locks[level];
ret = read_block_for_search(root, path, &next, level,
slot, &key);
if (ret == -EAGAIN)
......@@ -5382,7 +5379,6 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path,
BTRFS_NESTING_RIGHT,
path->recurse);
}
next_rw_lock = BTRFS_READ_LOCK;
}
break;
}
......@@ -5391,13 +5387,13 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path,
level--;
c = path->nodes[level];
if (path->locks[level])
btrfs_tree_unlock_rw(c, path->locks[level]);
btrfs_tree_read_unlock(c);
free_extent_buffer(c);
path->nodes[level] = next;
path->slots[level] = 0;
if (!path->skip_locking)
path->locks[level] = next_rw_lock;
path->locks[level] = BTRFS_READ_LOCK;
if (!level)
break;
......@@ -5411,11 +5407,9 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path,
goto done;
}
if (!path->skip_locking) {
if (!path->skip_locking)
__btrfs_tree_read_lock(next, BTRFS_NESTING_RIGHT,
path->recurse);
next_rw_lock = BTRFS_READ_LOCK;
}
}
ret = 0;
done:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment