diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-10-15 16:18:55 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:03:56 -0400 |
commit | 810191ff3087e8143b41a944fcf4fd8c693f00e3 (patch) | |
tree | 9d23dd51458623eaac41bc8c89dd2998a2eda7ae /fs/btrfs/extent_map.c | |
parent | 3326d1b07c0cb6a2ff5b835b7a2cffa54124d074 (diff) |
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.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c index 85b28a6a4e05..f8aaba8a30a2 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, | |||
1963 | struct page *p; | 1963 | struct page *p; |
1964 | 1964 | ||
1965 | if (i == 0) | 1965 | if (i == 0) |
1966 | return eb->last_page; | 1966 | return eb->first_page; |
1967 | i += eb->start >> PAGE_CACHE_SHIFT; | 1967 | i += eb->start >> PAGE_CACHE_SHIFT; |
1968 | p = find_get_page(eb->last_page->mapping, i); | 1968 | p = find_get_page(eb->first_page->mapping, i); |
1969 | page_cache_release(p); | 1969 | page_cache_release(p); |
1970 | return p; | 1970 | return p; |
1971 | } | 1971 | } |
@@ -2037,7 +2037,7 @@ struct extent_buffer *alloc_extent_buffer(struct extent_map_tree *tree, | |||
2037 | } | 2037 | } |
2038 | set_page_extent_mapped(p); | 2038 | set_page_extent_mapped(p); |
2039 | if (i == 0) | 2039 | if (i == 0) |
2040 | eb->last_page = p; | 2040 | eb->first_page = p; |
2041 | if (!PageUptodate(p)) | 2041 | if (!PageUptodate(p)) |
2042 | uptodate = 0; | 2042 | uptodate = 0; |
2043 | unlock_page(p); | 2043 | unlock_page(p); |
@@ -2083,7 +2083,7 @@ struct extent_buffer *find_extent_buffer(struct extent_map_tree *tree, | |||
2083 | } | 2083 | } |
2084 | set_page_extent_mapped(p); | 2084 | set_page_extent_mapped(p); |
2085 | if (i == 0) | 2085 | if (i == 0) |
2086 | eb->last_page = p; | 2086 | eb->first_page = p; |
2087 | if (!PageUptodate(p)) | 2087 | if (!PageUptodate(p)) |
2088 | uptodate = 0; | 2088 | uptodate = 0; |
2089 | unlock_page(p); | 2089 | unlock_page(p); |
@@ -2169,7 +2169,15 @@ EXPORT_SYMBOL(wait_on_extent_buffer_writeback); | |||
2169 | int set_extent_buffer_dirty(struct extent_map_tree *tree, | 2169 | int set_extent_buffer_dirty(struct extent_map_tree *tree, |
2170 | struct extent_buffer *eb) | 2170 | struct extent_buffer *eb) |
2171 | { | 2171 | { |
2172 | return set_range_dirty(tree, eb->start, eb->start + eb->len - 1); | 2172 | unsigned long i; |
2173 | unsigned long num_pages; | ||
2174 | |||
2175 | num_pages = num_extent_pages(eb->start, eb->len); | ||
2176 | for (i = 0; i < num_pages; i++) { | ||
2177 | __set_page_dirty_nobuffers(extent_buffer_page(eb, i)); | ||
2178 | } | ||
2179 | return set_extent_dirty(tree, eb->start, | ||
2180 | eb->start + eb->len - 1, GFP_NOFS); | ||
2173 | } | 2181 | } |
2174 | EXPORT_SYMBOL(set_extent_buffer_dirty); | 2182 | EXPORT_SYMBOL(set_extent_buffer_dirty); |
2175 | 2183 | ||
@@ -2317,16 +2325,11 @@ static int __map_extent_buffer(struct extent_buffer *eb, unsigned long start, | |||
2317 | size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1); | 2325 | size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1); |
2318 | unsigned long i = (start_offset + start) >> PAGE_CACHE_SHIFT; | 2326 | unsigned long i = (start_offset + start) >> PAGE_CACHE_SHIFT; |
2319 | unsigned long end_i = (start_offset + start + min_len) >> | 2327 | unsigned long end_i = (start_offset + start + min_len) >> |
2320 | PAGE_CACHE_SHIFT; | 2328 | PAGE_CACHE_SHIFT; |
2321 | 2329 | ||
2322 | if (i != end_i) | 2330 | if (i != end_i) |
2323 | return -EINVAL; | 2331 | return -EINVAL; |
2324 | 2332 | ||
2325 | if (start >= eb->len) { | ||
2326 | printk("bad start in map eb start %Lu len %lu caller start %lu min %lu\n", eb->start, eb->len, start, min_len); | ||
2327 | WARN_ON(1); | ||
2328 | } | ||
2329 | |||
2330 | if (i == 0) { | 2333 | if (i == 0) { |
2331 | offset = start_offset; | 2334 | offset = start_offset; |
2332 | *map_start = 0; | 2335 | *map_start = 0; |
@@ -2353,14 +2356,6 @@ int map_extent_buffer(struct extent_buffer *eb, unsigned long start, | |||
2353 | int err; | 2356 | int err; |
2354 | int save = 0; | 2357 | int save = 0; |
2355 | if (eb->map_token) { | 2358 | if (eb->map_token) { |
2356 | if (start >= eb->map_start && | ||
2357 | start + min_len <= eb->map_start + eb->map_len) { | ||
2358 | *token = eb->map_token; | ||
2359 | *map = eb->kaddr; | ||
2360 | *map_start = eb->map_start; | ||
2361 | *map_len = eb->map_len; | ||
2362 | return 0; | ||
2363 | } | ||
2364 | unmap_extent_buffer(eb, eb->map_token, km); | 2359 | unmap_extent_buffer(eb, eb->map_token, km); |
2365 | eb->map_token = NULL; | 2360 | eb->map_token = NULL; |
2366 | save = 1; | 2361 | save = 1; |