summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_map.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-10-19 09:23:27 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:57 -0400
commit3685f791659c9f21b763ee1702ac8ca58bc20f81 (patch)
tree9cd9514f7689ee0dfaef1c6303308366f05e0d5e /fs/btrfs/extent_map.c
parent59d169e2b3d69ba0beca0fa0936789080c8d61a9 (diff)
downloadop-kernel-dev-3685f791659c9f21b763ee1702ac8ca58bc20f81.zip
op-kernel-dev-3685f791659c9f21b763ee1702ac8ca58bc20f81.tar.gz
Btrfs: CPU usage optimizations in push and the extent_map code
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent_map.c')
-rw-r--r--fs/btrfs/extent_map.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index 3c81f5e..caaf0bf 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -1986,12 +1986,15 @@ static inline struct page *extent_buffer_page(struct extent_buffer *eb,
unsigned long i)
{
struct page *p;
+ struct address_space *mapping;
if (i == 0)
return eb->first_page;
i += eb->start >> PAGE_CACHE_SHIFT;
- p = find_get_page(eb->first_page->mapping, i);
- page_cache_release(p);
+ mapping = eb->first_page->mapping;
+ read_lock_irq(&mapping->tree_lock);
+ p = radix_tree_lookup(&mapping->page_tree, i);
+ read_unlock_irq(&mapping->tree_lock);
return p;
}
@@ -2365,9 +2368,7 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv,
WARN_ON(start > eb->len);
WARN_ON(start + len > eb->start + eb->len);
- offset = start & ((unsigned long)PAGE_CACHE_SIZE - 1);
- if (i == 0)
- offset += start_offset;
+ offset = (start_offset + start) & ((unsigned long)PAGE_CACHE_SIZE - 1);
while(len > 0) {
page = extent_buffer_page(eb, i);
@@ -2475,9 +2476,7 @@ int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv,
WARN_ON(start > eb->len);
WARN_ON(start + len > eb->start + eb->len);
- offset = start & ((unsigned long)PAGE_CACHE_SIZE - 1);
- if (i == 0)
- offset += start_offset;
+ offset = (start_offset + start) & ((unsigned long)PAGE_CACHE_SIZE - 1);
while(len > 0) {
page = extent_buffer_page(eb, i);
@@ -2514,9 +2513,7 @@ void write_extent_buffer(struct extent_buffer *eb, const void *srcv,
WARN_ON(start > eb->len);
WARN_ON(start + len > eb->start + eb->len);
- offset = start & ((unsigned long)PAGE_CACHE_SIZE - 1);
- if (i == 0)
- offset += start_offset;
+ offset = (start_offset + start) & ((unsigned long)PAGE_CACHE_SIZE - 1);
while(len > 0) {
page = extent_buffer_page(eb, i);
@@ -2548,9 +2545,7 @@ void memset_extent_buffer(struct extent_buffer *eb, char c,
WARN_ON(start > eb->len);
WARN_ON(start + len > eb->start + eb->len);
- offset = start & ((unsigned long)PAGE_CACHE_SIZE - 1);
- if (i == 0)
- offset += start_offset;
+ offset = (start_offset + start) & ((unsigned long)PAGE_CACHE_SIZE - 1);
while(len > 0) {
page = extent_buffer_page(eb, i);
@@ -2582,9 +2577,8 @@ void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src,
WARN_ON(src->len != dst_len);
- offset = dst_offset & ((unsigned long)PAGE_CACHE_SIZE - 1);
- if (i == 0)
- offset += start_offset;
+ offset = (start_offset + dst_offset) &
+ ((unsigned long)PAGE_CACHE_SIZE - 1);
while(len > 0) {
page = extent_buffer_page(dst, i);
@@ -2664,19 +2658,14 @@ void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
}
while(len > 0) {
- dst_off_in_page = dst_offset &
+ dst_off_in_page = (start_offset + dst_offset) &
((unsigned long)PAGE_CACHE_SIZE - 1);
- src_off_in_page = src_offset &
+ src_off_in_page = (start_offset + src_offset) &
((unsigned long)PAGE_CACHE_SIZE - 1);
dst_i = (start_offset + dst_offset) >> PAGE_CACHE_SHIFT;
src_i = (start_offset + src_offset) >> PAGE_CACHE_SHIFT;
- if (src_i == 0)
- src_off_in_page += start_offset;
- if (dst_i == 0)
- dst_off_in_page += start_offset;
-
cur = min(len, (unsigned long)(PAGE_CACHE_SIZE -
src_off_in_page));
cur = min_t(unsigned long, cur,
@@ -2723,14 +2712,10 @@ void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
dst_i = (start_offset + dst_end) >> PAGE_CACHE_SHIFT;
src_i = (start_offset + src_end) >> PAGE_CACHE_SHIFT;
- dst_off_in_page = dst_end &
+ dst_off_in_page = (start_offset + dst_end) &
((unsigned long)PAGE_CACHE_SIZE - 1);
- src_off_in_page = src_end &
+ src_off_in_page = (start_offset + src_end) &
((unsigned long)PAGE_CACHE_SIZE - 1);
- if (src_i == 0)
- src_off_in_page += start_offset;
- if (dst_i == 0)
- dst_off_in_page += start_offset;
cur = min_t(unsigned long, len, src_off_in_page + 1);
cur = min(cur, dst_off_in_page + 1);
OpenPOWER on IntegriCloud