aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2009-09-02 16:24:52 -0400
committerChris Mason <chris.mason@oracle.com>2009-09-11 13:31:05 -0400
commit890871be854b5f5e43e7ba2475f706209906cc24 (patch)
tree9d087adf7a28bb910992d07d93ea2a992e394110 /fs/btrfs/file.c
parent57fd5a5ff8b48b99e90b22fc143082aba755c6c0 (diff)
Btrfs: switch extent_map to a rw lock
There are two main users of the extent_map tree. The first is regular file inodes, where it is evenly spread between readers and writers. The second is the chunk allocation tree, which maps blocks from logical addresses to phyiscal ones, and it is 99.99% reads. The mapping tree is a point of lock contention during heavy IO workloads, so this commit switches things to a rw lock. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index a760d97279ac..8a9c76aecdf3 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -188,15 +188,15 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
188 if (!split2) 188 if (!split2)
189 split2 = alloc_extent_map(GFP_NOFS); 189 split2 = alloc_extent_map(GFP_NOFS);
190 190
191 spin_lock(&em_tree->lock); 191 write_lock(&em_tree->lock);
192 em = lookup_extent_mapping(em_tree, start, len); 192 em = lookup_extent_mapping(em_tree, start, len);
193 if (!em) { 193 if (!em) {
194 spin_unlock(&em_tree->lock); 194 write_unlock(&em_tree->lock);
195 break; 195 break;
196 } 196 }
197 flags = em->flags; 197 flags = em->flags;
198 if (skip_pinned && test_bit(EXTENT_FLAG_PINNED, &em->flags)) { 198 if (skip_pinned && test_bit(EXTENT_FLAG_PINNED, &em->flags)) {
199 spin_unlock(&em_tree->lock); 199 write_unlock(&em_tree->lock);
200 if (em->start <= start && 200 if (em->start <= start &&
201 (!testend || em->start + em->len >= start + len)) { 201 (!testend || em->start + em->len >= start + len)) {
202 free_extent_map(em); 202 free_extent_map(em);
@@ -259,7 +259,7 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
259 free_extent_map(split); 259 free_extent_map(split);
260 split = NULL; 260 split = NULL;
261 } 261 }
262 spin_unlock(&em_tree->lock); 262 write_unlock(&em_tree->lock);
263 263
264 /* once for us */ 264 /* once for us */
265 free_extent_map(em); 265 free_extent_map(em);