Skip to content

Commit a71561b

Browse files
kdavegregkh
authored andcommitted
btrfs: remove trivial locking wrappers of tree mod log
[ Upstream commit b1a09f1 ] The wrappers are trivial and do not bring any extra value on top of the plain locking primitives. Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent fb8c812 commit a71561b

File tree

1 file changed

+19
-39
lines changed

1 file changed

+19
-39
lines changed

fs/btrfs/ctree.c

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -331,26 +331,6 @@ struct tree_mod_elem {
331331
struct tree_mod_root old_root;
332332
};
333333

334-
static inline void tree_mod_log_read_lock(struct btrfs_fs_info *fs_info)
335-
{
336-
read_lock(&fs_info->tree_mod_log_lock);
337-
}
338-
339-
static inline void tree_mod_log_read_unlock(struct btrfs_fs_info *fs_info)
340-
{
341-
read_unlock(&fs_info->tree_mod_log_lock);
342-
}
343-
344-
static inline void tree_mod_log_write_lock(struct btrfs_fs_info *fs_info)
345-
{
346-
write_lock(&fs_info->tree_mod_log_lock);
347-
}
348-
349-
static inline void tree_mod_log_write_unlock(struct btrfs_fs_info *fs_info)
350-
{
351-
write_unlock(&fs_info->tree_mod_log_lock);
352-
}
353-
354334
/*
355335
* Pull a new tree mod seq number for our operation.
356336
*/
@@ -370,14 +350,14 @@ static inline u64 btrfs_inc_tree_mod_seq(struct btrfs_fs_info *fs_info)
370350
u64 btrfs_get_tree_mod_seq(struct btrfs_fs_info *fs_info,
371351
struct seq_list *elem)
372352
{
373-
tree_mod_log_write_lock(fs_info);
353+
write_lock(&fs_info->tree_mod_log_lock);
374354
spin_lock(&fs_info->tree_mod_seq_lock);
375355
if (!elem->seq) {
376356
elem->seq = btrfs_inc_tree_mod_seq(fs_info);
377357
list_add_tail(&elem->list, &fs_info->tree_mod_seq_list);
378358
}
379359
spin_unlock(&fs_info->tree_mod_seq_lock);
380-
tree_mod_log_write_unlock(fs_info);
360+
write_unlock(&fs_info->tree_mod_log_lock);
381361

382362
return elem->seq;
383363
}
@@ -419,7 +399,7 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
419399
* anything that's lower than the lowest existing (read: blocked)
420400
* sequence number can be removed from the tree.
421401
*/
422-
tree_mod_log_write_lock(fs_info);
402+
write_lock(&fs_info->tree_mod_log_lock);
423403
tm_root = &fs_info->tree_mod_log;
424404
for (node = rb_first(tm_root); node; node = next) {
425405
next = rb_next(node);
@@ -429,7 +409,7 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
429409
rb_erase(node, tm_root);
430410
kfree(tm);
431411
}
432-
tree_mod_log_write_unlock(fs_info);
412+
write_unlock(&fs_info->tree_mod_log_lock);
433413
}
434414

435415
/*
@@ -440,7 +420,7 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
440420
* for root replace operations, or the logical address of the affected
441421
* block for all other operations.
442422
*
443-
* Note: must be called with write lock (tree_mod_log_write_lock).
423+
* Note: must be called with write lock for fs_info::tree_mod_log_lock.
444424
*/
445425
static noinline int
446426
__tree_mod_log_insert(struct btrfs_fs_info *fs_info, struct tree_mod_elem *tm)
@@ -480,7 +460,7 @@ __tree_mod_log_insert(struct btrfs_fs_info *fs_info, struct tree_mod_elem *tm)
480460
* Determines if logging can be omitted. Returns 1 if it can. Otherwise, it
481461
* returns zero with the tree_mod_log_lock acquired. The caller must hold
482462
* this until all tree mod log insertions are recorded in the rb tree and then
483-
* call tree_mod_log_write_unlock() to release.
463+
* write unlock fs_info::tree_mod_log_lock.
484464
*/
485465
static inline int tree_mod_dont_log(struct btrfs_fs_info *fs_info,
486466
struct extent_buffer *eb) {
@@ -490,9 +470,9 @@ static inline int tree_mod_dont_log(struct btrfs_fs_info *fs_info,
490470
if (eb && btrfs_header_level(eb) == 0)
491471
return 1;
492472

493-
tree_mod_log_write_lock(fs_info);
473+
write_lock(&fs_info->tree_mod_log_lock);
494474
if (list_empty(&(fs_info)->tree_mod_seq_list)) {
495-
tree_mod_log_write_unlock(fs_info);
475+
write_unlock(&fs_info->tree_mod_log_lock);
496476
return 1;
497477
}
498478

@@ -556,7 +536,7 @@ tree_mod_log_insert_key(struct btrfs_fs_info *fs_info,
556536
}
557537

558538
ret = __tree_mod_log_insert(fs_info, tm);
559-
tree_mod_log_write_unlock(fs_info);
539+
write_unlock(&eb->fs_info->tree_mod_log_lock);
560540
if (ret)
561541
kfree(tm);
562542

@@ -620,7 +600,7 @@ tree_mod_log_insert_move(struct btrfs_fs_info *fs_info,
620600
ret = __tree_mod_log_insert(fs_info, tm);
621601
if (ret)
622602
goto free_tms;
623-
tree_mod_log_write_unlock(fs_info);
603+
write_unlock(&eb->fs_info->tree_mod_log_lock);
624604
kfree(tm_list);
625605

626606
return 0;
@@ -631,7 +611,7 @@ tree_mod_log_insert_move(struct btrfs_fs_info *fs_info,
631611
kfree(tm_list[i]);
632612
}
633613
if (locked)
634-
tree_mod_log_write_unlock(fs_info);
614+
write_unlock(&eb->fs_info->tree_mod_log_lock);
635615
kfree(tm_list);
636616
kfree(tm);
637617

@@ -712,7 +692,7 @@ tree_mod_log_insert_root(struct btrfs_fs_info *fs_info,
712692
if (!ret)
713693
ret = __tree_mod_log_insert(fs_info, tm);
714694

715-
tree_mod_log_write_unlock(fs_info);
695+
write_unlock(&fs_info->tree_mod_log_lock);
716696
if (ret)
717697
goto free_tms;
718698
kfree(tm_list);
@@ -739,7 +719,7 @@ __tree_mod_log_search(struct btrfs_fs_info *fs_info, u64 start, u64 min_seq,
739719
struct tree_mod_elem *cur = NULL;
740720
struct tree_mod_elem *found = NULL;
741721

742-
tree_mod_log_read_lock(fs_info);
722+
read_lock(&fs_info->tree_mod_log_lock);
743723
tm_root = &fs_info->tree_mod_log;
744724
node = tm_root->rb_node;
745725
while (node) {
@@ -767,7 +747,7 @@ __tree_mod_log_search(struct btrfs_fs_info *fs_info, u64 start, u64 min_seq,
767747
break;
768748
}
769749
}
770-
tree_mod_log_read_unlock(fs_info);
750+
read_unlock(&fs_info->tree_mod_log_lock);
771751

772752
return found;
773753
}
@@ -848,7 +828,7 @@ tree_mod_log_eb_copy(struct btrfs_fs_info *fs_info, struct extent_buffer *dst,
848828
goto free_tms;
849829
}
850830

851-
tree_mod_log_write_unlock(fs_info);
831+
write_unlock(&fs_info->tree_mod_log_lock);
852832
kfree(tm_list);
853833

854834
return 0;
@@ -860,7 +840,7 @@ tree_mod_log_eb_copy(struct btrfs_fs_info *fs_info, struct extent_buffer *dst,
860840
kfree(tm_list[i]);
861841
}
862842
if (locked)
863-
tree_mod_log_write_unlock(fs_info);
843+
write_unlock(&fs_info->tree_mod_log_lock);
864844
kfree(tm_list);
865845

866846
return ret;
@@ -920,7 +900,7 @@ tree_mod_log_free_eb(struct btrfs_fs_info *fs_info, struct extent_buffer *eb)
920900
goto free_tms;
921901

922902
ret = __tree_mod_log_free_eb(fs_info, tm_list, nritems);
923-
tree_mod_log_write_unlock(fs_info);
903+
write_unlock(&eb->fs_info->tree_mod_log_lock);
924904
if (ret)
925905
goto free_tms;
926906
kfree(tm_list);
@@ -1271,7 +1251,7 @@ __tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct extent_buffer *eb,
12711251
unsigned long p_size = sizeof(struct btrfs_key_ptr);
12721252

12731253
n = btrfs_header_nritems(eb);
1274-
tree_mod_log_read_lock(fs_info);
1254+
read_lock(&fs_info->tree_mod_log_lock);
12751255
while (tm && tm->seq >= time_seq) {
12761256
/*
12771257
* all the operations are recorded with the operator used for
@@ -1326,7 +1306,7 @@ __tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct extent_buffer *eb,
13261306
if (tm->logical != first_tm->logical)
13271307
break;
13281308
}
1329-
tree_mod_log_read_unlock(fs_info);
1309+
read_unlock(&fs_info->tree_mod_log_lock);
13301310
btrfs_set_header_nritems(eb, n);
13311311
}
13321312

0 commit comments

Comments
 (0)