aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_map.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-10-15 16:14:27 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:56 -0400
commit479965d66e320f1a095bb76027171daa675a9c72 (patch)
treee8b57bf49e2c0eb37e5dbd389f716e4dc21d54dc /fs/btrfs/extent_map.c
parent5f39d397dfbe140a14edecd4e73c34ce23c4f9ee (diff)
Btrfs: Optimizations for the extent_buffer 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.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index 55fefdfab84c..8bef309e1b37 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -2140,14 +2140,20 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv,
2140EXPORT_SYMBOL(read_extent_buffer); 2140EXPORT_SYMBOL(read_extent_buffer);
2141 2141
2142int map_extent_buffer(struct extent_buffer *eb, unsigned long start, 2142int map_extent_buffer(struct extent_buffer *eb, unsigned long start,
2143 unsigned long min_len,
2143 char **token, char **map, 2144 char **token, char **map,
2144 unsigned long *map_start, 2145 unsigned long *map_start,
2145 unsigned long *map_len, int km) 2146 unsigned long *map_len, int km)
2146{ 2147{
2147 size_t offset; 2148 size_t offset = start & (PAGE_CACHE_SIZE - 1);
2148 char *kaddr; 2149 char *kaddr;
2149 size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1); 2150 size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1);
2150 unsigned long i = (start_offset + start) >> PAGE_CACHE_SHIFT; 2151 unsigned long i = (start_offset + start) >> PAGE_CACHE_SHIFT;
2152 unsigned long end_i = (start_offset + start + min_len) >>
2153 PAGE_CACHE_SHIFT;
2154
2155 if (i != end_i)
2156 return -EINVAL;
2151 2157
2152 WARN_ON(start > eb->len); 2158 WARN_ON(start > eb->len);
2153 2159
@@ -2155,8 +2161,7 @@ int map_extent_buffer(struct extent_buffer *eb, unsigned long start,
2155 offset = start_offset; 2161 offset = start_offset;
2156 *map_start = 0; 2162 *map_start = 0;
2157 } else { 2163 } else {
2158 offset = 0; 2164 *map_start = (i << PAGE_CACHE_SHIFT) - start_offset;
2159 *map_start = (i << PAGE_CACHE_SHIFT) - offset;
2160 } 2165 }
2161 2166
2162 // kaddr = kmap_atomic(eb->pages[i], km); 2167 // kaddr = kmap_atomic(eb->pages[i], km);