diff options
author | Josef Bacik <josef@redhat.com> | 2010-02-03 14:33:23 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-03-15 11:00:13 -0400 |
commit | 2ac55d41b5d6bf49e76bc85db5431240617e2f8f (patch) | |
tree | ee8e2a716ef0b50388ef5e4a86387ec0499bca89 /fs/btrfs/extent-tree.c | |
parent | 5a1a3df1f6c86926cfe8657e6f9b4b4c2f467d60 (diff) |
Btrfs: cache the extent state everywhere we possibly can V2
This patch just goes through and fixes everybody that does
lock_extent()
blah
unlock_extent()
to use
lock_extent_bits()
blah
unlock_extent_cached()
and pass around a extent_state so we only have to do the searches once per
function. This gives me about a 3 mb/s boots on my random write test. I have
not converted some things, like the relocation and ioctl's, since they aren't
heavily used and the relocation stuff is in the middle of being re-written. I
also changed the clear_extent_bit() to only unset the cached state if we are
clearing EXTENT_LOCKED and related stuff, so we can do things like this
lock_extent_bits()
clear delalloc bits
unlock_extent_cached()
without losing our cached state. I tested this thoroughly and turned on
LEAK_DEBUG to make sure we weren't leaking extent states, everything worked out
fine.
Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 559f72489b3b..1727b26fb194 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -6561,6 +6561,7 @@ static noinline int invalidate_extent_cache(struct btrfs_root *root, | |||
6561 | struct btrfs_key key; | 6561 | struct btrfs_key key; |
6562 | struct inode *inode = NULL; | 6562 | struct inode *inode = NULL; |
6563 | struct btrfs_file_extent_item *fi; | 6563 | struct btrfs_file_extent_item *fi; |
6564 | struct extent_state *cached_state = NULL; | ||
6564 | u64 num_bytes; | 6565 | u64 num_bytes; |
6565 | u64 skip_objectid = 0; | 6566 | u64 skip_objectid = 0; |
6566 | u32 nritems; | 6567 | u32 nritems; |
@@ -6589,12 +6590,14 @@ static noinline int invalidate_extent_cache(struct btrfs_root *root, | |||
6589 | } | 6590 | } |
6590 | num_bytes = btrfs_file_extent_num_bytes(leaf, fi); | 6591 | num_bytes = btrfs_file_extent_num_bytes(leaf, fi); |
6591 | 6592 | ||
6592 | lock_extent(&BTRFS_I(inode)->io_tree, key.offset, | 6593 | lock_extent_bits(&BTRFS_I(inode)->io_tree, key.offset, |
6593 | key.offset + num_bytes - 1, GFP_NOFS); | 6594 | key.offset + num_bytes - 1, 0, &cached_state, |
6595 | GFP_NOFS); | ||
6594 | btrfs_drop_extent_cache(inode, key.offset, | 6596 | btrfs_drop_extent_cache(inode, key.offset, |
6595 | key.offset + num_bytes - 1, 1); | 6597 | key.offset + num_bytes - 1, 1); |
6596 | unlock_extent(&BTRFS_I(inode)->io_tree, key.offset, | 6598 | unlock_extent_cached(&BTRFS_I(inode)->io_tree, key.offset, |
6597 | key.offset + num_bytes - 1, GFP_NOFS); | 6599 | key.offset + num_bytes - 1, &cached_state, |
6600 | GFP_NOFS); | ||
6598 | cond_resched(); | 6601 | cond_resched(); |
6599 | } | 6602 | } |
6600 | iput(inode); | 6603 | iput(inode); |