aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_map.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-10-15 16:16:28 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:56 -0400
commit14048ed0c415b8729b194e92c16d31c61628d216 (patch)
tree26e9700f0da1795dc2667f70c21ef2c70c6157db /fs/btrfs/extent_map.c
parentdb94535db75e67fab12ccbb7f5ee548e33fed891 (diff)
Btrfs: Cache extent buffer mappings
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent_map.c')
-rw-r--r--fs/btrfs/extent_map.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index f658703c42e6..ea6ee68ef53c 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -2037,6 +2037,7 @@ struct extent_buffer *find_extent_buffer(struct extent_map_tree *tree,
2037 struct extent_buffer *eb; 2037 struct extent_buffer *eb;
2038 struct page *p; 2038 struct page *p;
2039 struct address_space *mapping = tree->mapping; 2039 struct address_space *mapping = tree->mapping;
2040 int uptodate = 1;
2040 2041
2041 eb = __alloc_extent_buffer(mask); 2042 eb = __alloc_extent_buffer(mask);
2042 if (!eb || IS_ERR(eb)) 2043 if (!eb || IS_ERR(eb))
@@ -2048,7 +2049,7 @@ struct extent_buffer *find_extent_buffer(struct extent_map_tree *tree,
2048 atomic_set(&eb->refs, 1); 2049 atomic_set(&eb->refs, 1);
2049 2050
2050 for (i = 0; i < num_pages; i++, index++) { 2051 for (i = 0; i < num_pages; i++, index++) {
2051 p = find_get_page(mapping, index); 2052 p = find_lock_page(mapping, index);
2052 if (!p) { 2053 if (!p) {
2053 /* make sure the free only frees the pages we've 2054 /* make sure the free only frees the pages we've
2054 * grabbed a reference on 2055 * grabbed a reference on
@@ -2060,7 +2061,12 @@ struct extent_buffer *find_extent_buffer(struct extent_map_tree *tree,
2060 set_page_extent_mapped(p); 2061 set_page_extent_mapped(p);
2061 if (i == 0) 2062 if (i == 0)
2062 eb->first_page = p; 2063 eb->first_page = p;
2064 if (!PageUptodate(p))
2065 uptodate = 0;
2066 unlock_page(p);
2063 } 2067 }
2068 if (uptodate)
2069 eb->flags |= EXTENT_UPTODATE;
2064 return eb; 2070 return eb;
2065fail: 2071fail:
2066 free_extent_buffer(eb); 2072 free_extent_buffer(eb);
@@ -2192,7 +2198,7 @@ int read_extent_buffer_pages(struct extent_map_tree *tree,
2192 if (eb->flags & EXTENT_UPTODATE) 2198 if (eb->flags & EXTENT_UPTODATE)
2193 return 0; 2199 return 0;
2194 2200
2195 if (test_range_bit(tree, eb->start, eb->start + eb->len - 1, 2201 if (0 && test_range_bit(tree, eb->start, eb->start + eb->len - 1,
2196 EXTENT_UPTODATE, 1)) { 2202 EXTENT_UPTODATE, 1)) {
2197 return 0; 2203 return 0;
2198 } 2204 }
@@ -2247,6 +2253,7 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv,
2247 char *dst = (char *)dstv; 2253 char *dst = (char *)dstv;
2248 size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1); 2254 size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1);
2249 unsigned long i = (start_offset + start) >> PAGE_CACHE_SHIFT; 2255 unsigned long i = (start_offset + start) >> PAGE_CACHE_SHIFT;
2256 unsigned long num_pages = num_extent_pages(eb->start, eb->len);
2250 2257
2251 WARN_ON(start > eb->len); 2258 WARN_ON(start > eb->len);
2252 WARN_ON(start + len > eb->start + eb->len); 2259 WARN_ON(start + len > eb->start + eb->len);
@@ -2257,6 +2264,10 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv,
2257 2264
2258 while(len > 0) { 2265 while(len > 0) {
2259 page = extent_buffer_page(eb, i); 2266 page = extent_buffer_page(eb, i);
2267 if (!PageUptodate(page)) {
2268 printk("page %lu not up to date i %lu, total %lu, len %lu\n", page->index, i, num_pages, eb->len);
2269 WARN_ON(1);
2270 }
2260 WARN_ON(!PageUptodate(page)); 2271 WARN_ON(!PageUptodate(page));
2261 2272
2262 cur = min(len, (PAGE_CACHE_SIZE - offset)); 2273 cur = min(len, (PAGE_CACHE_SIZE - offset));