* [PATCH] Btrfs: try to avoid acquiring free space ctl's lock
@ 2017-02-13 23:42 Liu Bo
2017-02-14 15:53 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Liu Bo @ 2017-02-13 23:42 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
We don't need to take the lock if the block group has not been cached.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
fs/btrfs/extent-tree.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index b2b0b82..6832047 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7715,18 +7715,19 @@ static noinline int find_free_extent(struct btrfs_root *orig_root,
last_ptr->fragmented = 1;
spin_unlock(&last_ptr->lock);
}
- spin_lock(&block_group->free_space_ctl->tree_lock);
- if (cached &&
- block_group->free_space_ctl->free_space <
- num_bytes + empty_cluster + empty_size) {
- if (block_group->free_space_ctl->free_space >
- max_extent_size)
- max_extent_size =
- block_group->free_space_ctl->free_space;
- spin_unlock(&block_group->free_space_ctl->tree_lock);
- goto loop;
+ if (cached) {
+ struct btrfs_free_space_ctl *ctl =
+ block_group->free_space_ctl;
+ spin_lock(&ctl->tree_lock);
+ if (ctl->free_space <
+ num_bytes + empty_cluster + empty_size) {
+ if (ctl->free_space > max_extent_size)
+ max_extent_size = ctl->free_space;
+ spin_unlock(&ctl->tree_lock);
+ goto loop;
+ }
+ spin_unlock(&ctl->tree_lock);
}
- spin_unlock(&block_group->free_space_ctl->tree_lock);
offset = btrfs_find_space_for_alloc(block_group, search_start,
num_bytes, empty_size,
--
2.5.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Btrfs: try to avoid acquiring free space ctl's lock
2017-02-13 23:42 [PATCH] Btrfs: try to avoid acquiring free space ctl's lock Liu Bo
@ 2017-02-14 15:53 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2017-02-14 15:53 UTC (permalink / raw)
To: Liu Bo; +Cc: linux-btrfs, David Sterba
On Mon, Feb 13, 2017 at 03:42:30PM -0800, Liu Bo wrote:
> We don't need to take the lock if the block group has not been cached.
>
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-02-14 15:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-13 23:42 [PATCH] Btrfs: try to avoid acquiring free space ctl's lock Liu Bo
2017-02-14 15:53 ` David Sterba
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.