summaryrefslogtreecommitdiff
path: root/fs/btrfs/extent_map.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-10-15 16:18:55 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:56 -0400
commit810191ff3087e8143b41a944fcf4fd8c693f00e3 (patch)
tree9d23dd51458623eaac41bc8c89dd2998a2eda7ae /fs/btrfs/extent_map.c
parent3326d1b07c0cb6a2ff5b835b7a2cffa54124d074 (diff)
downloadlinux-3.10-810191ff3087e8143b41a944fcf4fd8c693f00e3.tar.gz
linux-3.10-810191ff3087e8143b41a944fcf4fd8c693f00e3.tar.bz2
linux-3.10-810191ff3087e8143b41a944fcf4fd8c693f00e3.zip
Btrfs: extent_map optimizations to cut down on CPU usage
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent_map.c')
-rw-r--r--fs/btrfs/extent_map.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index 85b28a6a4e0..f8aaba8a30a 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -1963,9 +1963,9 @@ static inline struct page *extent_buffer_page(struct extent_buffer *eb,
struct page *p;
if (i == 0)
- return eb->last_page;
+ return eb->first_page;
i += eb->start >> PAGE_CACHE_SHIFT;
- p = find_get_page(eb->last_page->mapping, i);
+ p = find_get_page(eb->first_page->mapping, i);
page_cache_release(p);
return p;
}
@@ -2037,7 +2037,7 @@ struct extent_buffer *alloc_extent_buffer(struct extent_map_tree *tree,
}
set_page_extent_mapped(p);
if (i == 0)
- eb->last_page = p;
+ eb->first_page = p;
if (!PageUptodate(p))
uptodate = 0;
unlock_page(p);
@@ -2083,7 +2083,7 @@ struct extent_buffer *find_extent_buffer(struct extent_map_tree *tree,
}
set_page_extent_mapped(p);
if (i == 0)
- eb->last_page = p;
+ eb->first_page = p;
if (!PageUptodate(p))
uptodate = 0;
unlock_page(p);
@@ -2169,7 +2169,15 @@ EXPORT_SYMBOL(wait_on_extent_buffer_writeback);
int set_extent_buffer_dirty(struct extent_map_tree *tree,
struct extent_buffer *eb)
{
- return set_range_dirty(tree, eb->start, eb->start + eb->len - 1);
+ unsigned long i;
+ unsigned long num_pages;
+
+ num_pages = num_extent_pages(eb->start, eb->len);
+ for (i = 0; i < num_pages; i++) {
+ __set_page_dirty_nobuffers(extent_buffer_page(eb, i));
+ }
+ return set_extent_dirty(tree, eb->start,
+ eb->start + eb->len - 1, GFP_NOFS);
}
EXPORT_SYMBOL(set_extent_buffer_dirty);
@@ -2317,16 +2325,11 @@ static int __map_extent_buffer(struct extent_buffer *eb, unsigned long start,
size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1);
unsigned long i = (start_offset + start) >> PAGE_CACHE_SHIFT;
unsigned long end_i = (start_offset + start + min_len) >>
- PAGE_CACHE_SHIFT;
+ PAGE_CACHE_SHIFT;
if (i != end_i)
return -EINVAL;
- if (start >= eb->len) {
- printk("bad start in map eb start %Lu len %lu caller start %lu min %lu\n", eb->start, eb->len, start, min_len);
- WARN_ON(1);
- }
-
if (i == 0) {
offset = start_offset;
*map_start = 0;
@@ -2353,14 +2356,6 @@ int map_extent_buffer(struct extent_buffer *eb, unsigned long start,
int err;
int save = 0;
if (eb->map_token) {
- if (start >= eb->map_start &&
- start + min_len <= eb->map_start + eb->map_len) {
- *token = eb->map_token;
- *map = eb->kaddr;
- *map_start = eb->map_start;
- *map_len = eb->map_len;
- return 0;
- }
unmap_extent_buffer(eb, eb->map_token, km);
eb->map_token = NULL;
save = 1;