btrfs: remove trivial locking wrappers of tree mod log
[ Upstream commit b1a09f1ec540408abf3a50d15dff5d9506932693 ] The wrappers are trivial and do not bring any extra value on top of the plain locking primitives. Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
19ef703ec4
commit
1aa4c9cdd4
|
@ -332,26 +332,6 @@ struct tree_mod_elem {
|
||||||
struct tree_mod_root old_root;
|
struct tree_mod_root old_root;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void tree_mod_log_read_lock(struct btrfs_fs_info *fs_info)
|
|
||||||
{
|
|
||||||
read_lock(&fs_info->tree_mod_log_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void tree_mod_log_read_unlock(struct btrfs_fs_info *fs_info)
|
|
||||||
{
|
|
||||||
read_unlock(&fs_info->tree_mod_log_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void tree_mod_log_write_lock(struct btrfs_fs_info *fs_info)
|
|
||||||
{
|
|
||||||
write_lock(&fs_info->tree_mod_log_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void tree_mod_log_write_unlock(struct btrfs_fs_info *fs_info)
|
|
||||||
{
|
|
||||||
write_unlock(&fs_info->tree_mod_log_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pull a new tree mod seq number for our operation.
|
* Pull a new tree mod seq number for our operation.
|
||||||
*/
|
*/
|
||||||
|
@ -371,14 +351,14 @@ static inline u64 btrfs_inc_tree_mod_seq(struct btrfs_fs_info *fs_info)
|
||||||
u64 btrfs_get_tree_mod_seq(struct btrfs_fs_info *fs_info,
|
u64 btrfs_get_tree_mod_seq(struct btrfs_fs_info *fs_info,
|
||||||
struct seq_list *elem)
|
struct seq_list *elem)
|
||||||
{
|
{
|
||||||
tree_mod_log_write_lock(fs_info);
|
write_lock(&fs_info->tree_mod_log_lock);
|
||||||
spin_lock(&fs_info->tree_mod_seq_lock);
|
spin_lock(&fs_info->tree_mod_seq_lock);
|
||||||
if (!elem->seq) {
|
if (!elem->seq) {
|
||||||
elem->seq = btrfs_inc_tree_mod_seq(fs_info);
|
elem->seq = btrfs_inc_tree_mod_seq(fs_info);
|
||||||
list_add_tail(&elem->list, &fs_info->tree_mod_seq_list);
|
list_add_tail(&elem->list, &fs_info->tree_mod_seq_list);
|
||||||
}
|
}
|
||||||
spin_unlock(&fs_info->tree_mod_seq_lock);
|
spin_unlock(&fs_info->tree_mod_seq_lock);
|
||||||
tree_mod_log_write_unlock(fs_info);
|
write_unlock(&fs_info->tree_mod_log_lock);
|
||||||
|
|
||||||
return elem->seq;
|
return elem->seq;
|
||||||
}
|
}
|
||||||
|
@ -420,7 +400,7 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
|
||||||
* anything that's lower than the lowest existing (read: blocked)
|
* anything that's lower than the lowest existing (read: blocked)
|
||||||
* sequence number can be removed from the tree.
|
* sequence number can be removed from the tree.
|
||||||
*/
|
*/
|
||||||
tree_mod_log_write_lock(fs_info);
|
write_lock(&fs_info->tree_mod_log_lock);
|
||||||
tm_root = &fs_info->tree_mod_log;
|
tm_root = &fs_info->tree_mod_log;
|
||||||
for (node = rb_first(tm_root); node; node = next) {
|
for (node = rb_first(tm_root); node; node = next) {
|
||||||
next = rb_next(node);
|
next = rb_next(node);
|
||||||
|
@ -430,7 +410,7 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
|
||||||
rb_erase(node, tm_root);
|
rb_erase(node, tm_root);
|
||||||
kfree(tm);
|
kfree(tm);
|
||||||
}
|
}
|
||||||
tree_mod_log_write_unlock(fs_info);
|
write_unlock(&fs_info->tree_mod_log_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -441,7 +421,7 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
|
||||||
* operations, or the shifted logical of the affected block for all other
|
* operations, or the shifted logical of the affected block for all other
|
||||||
* operations.
|
* operations.
|
||||||
*
|
*
|
||||||
* Note: must be called with write lock (tree_mod_log_write_lock).
|
* Note: must be called with write lock for fs_info::tree_mod_log_lock.
|
||||||
*/
|
*/
|
||||||
static noinline int
|
static noinline int
|
||||||
__tree_mod_log_insert(struct btrfs_fs_info *fs_info, struct tree_mod_elem *tm)
|
__tree_mod_log_insert(struct btrfs_fs_info *fs_info, struct tree_mod_elem *tm)
|
||||||
|
@ -481,7 +461,7 @@ __tree_mod_log_insert(struct btrfs_fs_info *fs_info, struct tree_mod_elem *tm)
|
||||||
* Determines if logging can be omitted. Returns 1 if it can. Otherwise, it
|
* Determines if logging can be omitted. Returns 1 if it can. Otherwise, it
|
||||||
* returns zero with the tree_mod_log_lock acquired. The caller must hold
|
* returns zero with the tree_mod_log_lock acquired. The caller must hold
|
||||||
* this until all tree mod log insertions are recorded in the rb tree and then
|
* this until all tree mod log insertions are recorded in the rb tree and then
|
||||||
* call tree_mod_log_write_unlock() to release.
|
* write unlock fs_info::tree_mod_log_lock.
|
||||||
*/
|
*/
|
||||||
static inline int tree_mod_dont_log(struct btrfs_fs_info *fs_info,
|
static inline int tree_mod_dont_log(struct btrfs_fs_info *fs_info,
|
||||||
struct extent_buffer *eb) {
|
struct extent_buffer *eb) {
|
||||||
|
@ -491,9 +471,9 @@ static inline int tree_mod_dont_log(struct btrfs_fs_info *fs_info,
|
||||||
if (eb && btrfs_header_level(eb) == 0)
|
if (eb && btrfs_header_level(eb) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
tree_mod_log_write_lock(fs_info);
|
write_lock(&fs_info->tree_mod_log_lock);
|
||||||
if (list_empty(&(fs_info)->tree_mod_seq_list)) {
|
if (list_empty(&(fs_info)->tree_mod_seq_list)) {
|
||||||
tree_mod_log_write_unlock(fs_info);
|
write_unlock(&fs_info->tree_mod_log_lock);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,7 +537,7 @@ tree_mod_log_insert_key(struct btrfs_fs_info *fs_info,
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = __tree_mod_log_insert(fs_info, tm);
|
ret = __tree_mod_log_insert(fs_info, tm);
|
||||||
tree_mod_log_write_unlock(fs_info);
|
write_unlock(&eb->fs_info->tree_mod_log_lock);
|
||||||
if (ret)
|
if (ret)
|
||||||
kfree(tm);
|
kfree(tm);
|
||||||
|
|
||||||
|
@ -621,7 +601,7 @@ tree_mod_log_insert_move(struct btrfs_fs_info *fs_info,
|
||||||
ret = __tree_mod_log_insert(fs_info, tm);
|
ret = __tree_mod_log_insert(fs_info, tm);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto free_tms;
|
goto free_tms;
|
||||||
tree_mod_log_write_unlock(fs_info);
|
write_unlock(&eb->fs_info->tree_mod_log_lock);
|
||||||
kfree(tm_list);
|
kfree(tm_list);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -632,7 +612,7 @@ free_tms:
|
||||||
kfree(tm_list[i]);
|
kfree(tm_list[i]);
|
||||||
}
|
}
|
||||||
if (locked)
|
if (locked)
|
||||||
tree_mod_log_write_unlock(fs_info);
|
write_unlock(&eb->fs_info->tree_mod_log_lock);
|
||||||
kfree(tm_list);
|
kfree(tm_list);
|
||||||
kfree(tm);
|
kfree(tm);
|
||||||
|
|
||||||
|
@ -713,7 +693,7 @@ tree_mod_log_insert_root(struct btrfs_fs_info *fs_info,
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = __tree_mod_log_insert(fs_info, tm);
|
ret = __tree_mod_log_insert(fs_info, tm);
|
||||||
|
|
||||||
tree_mod_log_write_unlock(fs_info);
|
write_unlock(&fs_info->tree_mod_log_lock);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto free_tms;
|
goto free_tms;
|
||||||
kfree(tm_list);
|
kfree(tm_list);
|
||||||
|
@ -741,7 +721,7 @@ __tree_mod_log_search(struct btrfs_fs_info *fs_info, u64 start, u64 min_seq,
|
||||||
struct tree_mod_elem *found = NULL;
|
struct tree_mod_elem *found = NULL;
|
||||||
u64 index = start >> PAGE_CACHE_SHIFT;
|
u64 index = start >> PAGE_CACHE_SHIFT;
|
||||||
|
|
||||||
tree_mod_log_read_lock(fs_info);
|
read_lock(&fs_info->tree_mod_log_lock);
|
||||||
tm_root = &fs_info->tree_mod_log;
|
tm_root = &fs_info->tree_mod_log;
|
||||||
node = tm_root->rb_node;
|
node = tm_root->rb_node;
|
||||||
while (node) {
|
while (node) {
|
||||||
|
@ -769,7 +749,7 @@ __tree_mod_log_search(struct btrfs_fs_info *fs_info, u64 start, u64 min_seq,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tree_mod_log_read_unlock(fs_info);
|
read_unlock(&fs_info->tree_mod_log_lock);
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
@ -850,7 +830,7 @@ tree_mod_log_eb_copy(struct btrfs_fs_info *fs_info, struct extent_buffer *dst,
|
||||||
goto free_tms;
|
goto free_tms;
|
||||||
}
|
}
|
||||||
|
|
||||||
tree_mod_log_write_unlock(fs_info);
|
write_unlock(&fs_info->tree_mod_log_lock);
|
||||||
kfree(tm_list);
|
kfree(tm_list);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -862,7 +842,7 @@ free_tms:
|
||||||
kfree(tm_list[i]);
|
kfree(tm_list[i]);
|
||||||
}
|
}
|
||||||
if (locked)
|
if (locked)
|
||||||
tree_mod_log_write_unlock(fs_info);
|
write_unlock(&fs_info->tree_mod_log_lock);
|
||||||
kfree(tm_list);
|
kfree(tm_list);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -922,7 +902,7 @@ tree_mod_log_free_eb(struct btrfs_fs_info *fs_info, struct extent_buffer *eb)
|
||||||
goto free_tms;
|
goto free_tms;
|
||||||
|
|
||||||
ret = __tree_mod_log_free_eb(fs_info, tm_list, nritems);
|
ret = __tree_mod_log_free_eb(fs_info, tm_list, nritems);
|
||||||
tree_mod_log_write_unlock(fs_info);
|
write_unlock(&eb->fs_info->tree_mod_log_lock);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto free_tms;
|
goto free_tms;
|
||||||
kfree(tm_list);
|
kfree(tm_list);
|
||||||
|
@ -1284,7 +1264,7 @@ __tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct extent_buffer *eb,
|
||||||
unsigned long p_size = sizeof(struct btrfs_key_ptr);
|
unsigned long p_size = sizeof(struct btrfs_key_ptr);
|
||||||
|
|
||||||
n = btrfs_header_nritems(eb);
|
n = btrfs_header_nritems(eb);
|
||||||
tree_mod_log_read_lock(fs_info);
|
read_lock(&fs_info->tree_mod_log_lock);
|
||||||
while (tm && tm->seq >= time_seq) {
|
while (tm && tm->seq >= time_seq) {
|
||||||
/*
|
/*
|
||||||
* all the operations are recorded with the operator used for
|
* all the operations are recorded with the operator used for
|
||||||
|
@ -1339,7 +1319,7 @@ __tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct extent_buffer *eb,
|
||||||
if (tm->index != first_tm->index)
|
if (tm->index != first_tm->index)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tree_mod_log_read_unlock(fs_info);
|
read_unlock(&fs_info->tree_mod_log_lock);
|
||||||
btrfs_set_header_nritems(eb, n);
|
btrfs_set_header_nritems(eb, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user