diff options
author | Liu Bo <bo.li.liu@oracle.com> | 2017-01-30 15:24:37 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-02-14 09:50:59 -0500 |
commit | f72ad18e996338a8033aeb981e645f8dbf4e22c1 (patch) | |
tree | e1f9d0f9937fe7ee3212918aa421f11159b2cc6f | |
parent | d07b85284f83dee7955cb43dc66a37542a725c12 (diff) |
Btrfs: pass delayed_refs directly to btrfs_find_delayed_ref_head
All we need is @delayed_refs, all callers have get it ahead of calling
btrfs_find_delayed_ref_head since lock needs to be acquired firstly,
there is no reason to deference it again inside the function.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/backref.c | 2 | ||||
-rw-r--r-- | fs/btrfs/delayed-ref.c | 5 | ||||
-rw-r--r-- | fs/btrfs/delayed-ref.h | 3 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 6 |
4 files changed, 7 insertions, 9 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 8299601a3549..db706595e631 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c | |||
@@ -1284,7 +1284,7 @@ again: | |||
1284 | */ | 1284 | */ |
1285 | delayed_refs = &trans->transaction->delayed_refs; | 1285 | delayed_refs = &trans->transaction->delayed_refs; |
1286 | spin_lock(&delayed_refs->lock); | 1286 | spin_lock(&delayed_refs->lock); |
1287 | head = btrfs_find_delayed_ref_head(trans, bytenr); | 1287 | head = btrfs_find_delayed_ref_head(delayed_refs, bytenr); |
1288 | if (head) { | 1288 | if (head) { |
1289 | if (!mutex_trylock(&head->mutex)) { | 1289 | if (!mutex_trylock(&head->mutex)) { |
1290 | atomic_inc(&head->node.refs); | 1290 | atomic_inc(&head->node.refs); |
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index c66f487b76a7..a1b9ef2dfc4a 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c | |||
@@ -909,11 +909,8 @@ int btrfs_add_delayed_extent_op(struct btrfs_fs_info *fs_info, | |||
909 | * the head node if any where found, or NULL if not. | 909 | * the head node if any where found, or NULL if not. |
910 | */ | 910 | */ |
911 | struct btrfs_delayed_ref_head * | 911 | struct btrfs_delayed_ref_head * |
912 | btrfs_find_delayed_ref_head(struct btrfs_trans_handle *trans, u64 bytenr) | 912 | btrfs_find_delayed_ref_head(struct btrfs_delayed_ref_root *delayed_refs, u64 bytenr) |
913 | { | 913 | { |
914 | struct btrfs_delayed_ref_root *delayed_refs; | ||
915 | |||
916 | delayed_refs = &trans->transaction->delayed_refs; | ||
917 | return find_ref_head(&delayed_refs->href_root, bytenr, 0); | 914 | return find_ref_head(&delayed_refs->href_root, bytenr, 0); |
918 | } | 915 | } |
919 | 916 | ||
diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h index 8a0220fb703c..0e537f98f1a1 100644 --- a/fs/btrfs/delayed-ref.h +++ b/fs/btrfs/delayed-ref.h | |||
@@ -261,7 +261,8 @@ void btrfs_merge_delayed_refs(struct btrfs_trans_handle *trans, | |||
261 | struct btrfs_delayed_ref_head *head); | 261 | struct btrfs_delayed_ref_head *head); |
262 | 262 | ||
263 | struct btrfs_delayed_ref_head * | 263 | struct btrfs_delayed_ref_head * |
264 | btrfs_find_delayed_ref_head(struct btrfs_trans_handle *trans, u64 bytenr); | 264 | btrfs_find_delayed_ref_head(struct btrfs_delayed_ref_root *delayed_refs, |
265 | u64 bytenr); | ||
265 | int btrfs_delayed_ref_lock(struct btrfs_trans_handle *trans, | 266 | int btrfs_delayed_ref_lock(struct btrfs_trans_handle *trans, |
266 | struct btrfs_delayed_ref_head *head); | 267 | struct btrfs_delayed_ref_head *head); |
267 | static inline void btrfs_delayed_ref_unlock(struct btrfs_delayed_ref_head *head) | 268 | static inline void btrfs_delayed_ref_unlock(struct btrfs_delayed_ref_head *head) |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 7dd71fcc1051..be235b30a798 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -888,7 +888,7 @@ search_again: | |||
888 | 888 | ||
889 | delayed_refs = &trans->transaction->delayed_refs; | 889 | delayed_refs = &trans->transaction->delayed_refs; |
890 | spin_lock(&delayed_refs->lock); | 890 | spin_lock(&delayed_refs->lock); |
891 | head = btrfs_find_delayed_ref_head(trans, bytenr); | 891 | head = btrfs_find_delayed_ref_head(delayed_refs, bytenr); |
892 | if (head) { | 892 | if (head) { |
893 | if (!mutex_trylock(&head->mutex)) { | 893 | if (!mutex_trylock(&head->mutex)) { |
894 | atomic_inc(&head->node.refs); | 894 | atomic_inc(&head->node.refs); |
@@ -3041,7 +3041,7 @@ static noinline int check_delayed_ref(struct btrfs_trans_handle *trans, | |||
3041 | 3041 | ||
3042 | delayed_refs = &trans->transaction->delayed_refs; | 3042 | delayed_refs = &trans->transaction->delayed_refs; |
3043 | spin_lock(&delayed_refs->lock); | 3043 | spin_lock(&delayed_refs->lock); |
3044 | head = btrfs_find_delayed_ref_head(trans, bytenr); | 3044 | head = btrfs_find_delayed_ref_head(delayed_refs, bytenr); |
3045 | if (!head) { | 3045 | if (!head) { |
3046 | spin_unlock(&delayed_refs->lock); | 3046 | spin_unlock(&delayed_refs->lock); |
3047 | return 0; | 3047 | return 0; |
@@ -7091,7 +7091,7 @@ static noinline int check_ref_cleanup(struct btrfs_trans_handle *trans, | |||
7091 | 7091 | ||
7092 | delayed_refs = &trans->transaction->delayed_refs; | 7092 | delayed_refs = &trans->transaction->delayed_refs; |
7093 | spin_lock(&delayed_refs->lock); | 7093 | spin_lock(&delayed_refs->lock); |
7094 | head = btrfs_find_delayed_ref_head(trans, bytenr); | 7094 | head = btrfs_find_delayed_ref_head(delayed_refs, bytenr); |
7095 | if (!head) | 7095 | if (!head) |
7096 | goto out_delayed_unlock; | 7096 | goto out_delayed_unlock; |
7097 | 7097 | ||