aboutsummaryrefslogtreecommitdiffstats
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)
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 3c81f5eab155..caaf0bf0e059 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,
1986 unsigned long i) 1986 unsigned long i)
1987{ 1987{
1988 struct page *p; 1988 struct page *p;
1989 struct address_space *mapping;
1989 1990
1990 if (i == 0) 1991 if (i == 0)
1991 return eb->first_page; 1992 return eb->first_page;
1992 i += eb->start >> PAGE_CACHE_SHIFT; 1993 i += eb->start >> PAGE_CACHE_SHIFT;
1993 p = find_get_page(eb->first_page->mapping, i); 1994 mapping = eb->first_page->mapping;
1994 page_cache_release(p); 1995 read_lock_irq(&mapping->tree_lock);
1996 p = radix_tree_lookup(&mapping->page_tree, i);
1997 read_unlock_irq(&mapping->tree_lock);
1995 return p; 1998 return p;
1996} 1999}
1997 2000
@@ -2365,9 +2368,7 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv,
2365 WARN_ON(start > eb->len); 2368 WARN_ON(start > eb->len);
2366 WARN_ON(start + len > eb->start + eb->len); 2369 WARN_ON(start + len > eb->start + eb->len);
2367 2370
2368 offset = start & ((unsigned long)PAGE_CACHE_SIZE - 1); 2371 offset = (start_offset + start) & ((unsigned long)PAGE_CACHE_SIZE - 1);
2369 if (i == 0)
2370 offset += start_offset;
2371 2372
2372 while(len > 0) { 2373 while(len > 0) {
2373 page = extent_buffer_page(eb, i); 2374 page = extent_buffer_page(eb, i);
@@ -2475,9 +2476,7 @@ int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv,
2475 WARN_ON(start > eb->len); 2476 WARN_ON(start > eb->len);
2476 WARN_ON(start + len > eb->start + eb->len); 2477 WARN_ON(start + len > eb->start + eb->len);
2477 2478
2478 offset = start & ((unsigned long)PAGE_CACHE_SIZE - 1); 2479 offset = (start_offset + start) & ((unsigned long)PAGE_CACHE_SIZE - 1);
2479 if (i == 0)
2480 offset += start_offset;
2481 2480
2482 while(len > 0) { 2481 while(len > 0) {
2483 page = extent_buffer_page(eb, i); 2482 page = extent_buffer_page(eb, i);
@@ -2514,9 +2513,7 @@ void write_extent_buffer(struct extent_buffer *eb, const void *srcv,
2514 WARN_ON(start > eb->len); 2513 WARN_ON(start > eb->len);
2515 WARN_ON(start + len > eb->start + eb->len); 2514 WARN_ON(start + len > eb->start + eb->len);
2516 2515
2517 offset = start & ((unsigned long)PAGE_CACHE_SIZE - 1); 2516 offset = (start_offset + start) & ((unsigned long)PAGE_CACHE_SIZE - 1);
2518 if (i == 0)
2519 offset += start_offset;
2520 2517
2521 while(len > 0) { 2518 while(len > 0) {
2522 page = extent_buffer_page(eb, i); 2519 page = extent_buffer_page(eb, i);
@@ -2548,9 +2545,7 @@ void memset_extent_buffer(struct extent_buffer *eb, char c,
2548 WARN_ON(start > eb->len); 2545 WARN_ON(start > eb->len);
2549 WARN_ON(start + len > eb->start + eb->len); 2546 WARN_ON(start + len > eb->start + eb->len);
2550 2547
2551 offset = start & ((unsigned long)PAGE_CACHE_SIZE - 1); 2548 offset = (start_offset + start) & ((unsigned long)PAGE_CACHE_SIZE - 1);
2552 if (i == 0)
2553 offset += start_offset;
2554 2549
2555 while(len > 0) { 2550 while(len > 0) {
2556 page = extent_buffer_page(eb, i); 2551 page = extent_buffer_page(eb, i);
@@ -2582,9 +2577,8 @@ void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src,
2582 2577
2583 WARN_ON(src->len != dst_len); 2578 WARN_ON(src->len != dst_len);
2584 2579
2585 offset = dst_offset & ((unsigned long)PAGE_CACHE_SIZE - 1); 2580 offset = (start_offset + dst_offset) &
2586 if (i == 0) 2581 ((unsigned long)PAGE_CACHE_SIZE - 1);
2587 offset += start_offset;
2588 2582
2589 while(len > 0) { 2583 while(len > 0) {
2590 page = extent_buffer_page(dst, i); 2584 page = extent_buffer_page(dst, i);
@@ -2664,19 +2658,14 @@ void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
2664 } 2658 }
2665 2659
2666 while(len > 0) { 2660 while(len > 0) {
2667 dst_off_in_page = dst_offset & 2661 dst_off_in_page = (start_offset + dst_offset) &
2668 ((unsigned long)PAGE_CACHE_SIZE - 1); 2662 ((unsigned long)PAGE_CACHE_SIZE - 1);
2669 src_off_in_page = src_offset & 2663 src_off_in_page = (start_offset + src_offset) &
2670 ((unsigned long)PAGE_CACHE_SIZE - 1); 2664 ((unsigned long)PAGE_CACHE_SIZE - 1);
2671 2665
2672 dst_i = (start_offset + dst_offset) >> PAGE_CACHE_SHIFT; 2666 dst_i = (start_offset + dst_offset) >> PAGE_CACHE_SHIFT;
2673 src_i = (start_offset + src_offset) >> PAGE_CACHE_SHIFT; 2667 src_i = (start_offset + src_offset) >> PAGE_CACHE_SHIFT;
2674 2668
2675 if (src_i == 0)
2676 src_off_in_page += start_offset;
2677 if (dst_i == 0)
2678 dst_off_in_page += start_offset;
2679
2680 cur = min(len, (unsigned long)(PAGE_CACHE_SIZE - 2669 cur = min(len, (unsigned long)(PAGE_CACHE_SIZE -
2681 src_off_in_page)); 2670 src_off_in_page));
2682 cur = min_t(unsigned long, cur, 2671 cur = min_t(unsigned long, cur,
@@ -2723,14 +2712,10 @@ void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
2723 dst_i = (start_offset + dst_end) >> PAGE_CACHE_SHIFT; 2712 dst_i = (start_offset + dst_end) >> PAGE_CACHE_SHIFT;
2724 src_i = (start_offset + src_end) >> PAGE_CACHE_SHIFT; 2713 src_i = (start_offset + src_end) >> PAGE_CACHE_SHIFT;
2725 2714
2726 dst_off_in_page = dst_end & 2715 dst_off_in_page = (start_offset + dst_end) &
2727 ((unsigned long)PAGE_CACHE_SIZE - 1); 2716 ((unsigned long)PAGE_CACHE_SIZE - 1);
2728 src_off_in_page = src_end & 2717 src_off_in_page = (start_offset + src_end) &
2729 ((unsigned long)PAGE_CACHE_SIZE - 1); 2718 ((unsigned long)PAGE_CACHE_SIZE - 1);
2730 if (src_i == 0)
2731 src_off_in_page += start_offset;
2732 if (dst_i == 0)
2733 dst_off_in_page += start_offset;
2734 2719
2735 cur = min_t(unsigned long, len, src_off_in_page + 1); 2720 cur = min_t(unsigned long, len, src_off_in_page + 1);
2736 cur = min(cur, dst_off_in_page + 1); 2721 cur = min(cur, dst_off_in_page + 1);