Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 128702
b: refs/heads/master
c: 728131d
h: refs/heads/master
v: v3
  • Loading branch information
Chris Mason committed Sep 25, 2008
1 parent 287fc9e commit c5e8881
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cea9e4452ebaf18dd0951e90dc84d82a5dee40b2
refs/heads/master: 728131d8e40c2a47c59ca91a806299c4708029f9
3 changes: 2 additions & 1 deletion trunk/fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ static int btree_releasepage(struct page *page, gfp_t gfp_flags)
map = &BTRFS_I(page->mapping->host)->extent_tree;
ret = try_release_extent_mapping(map, tree, page, gfp_flags);
if (ret == 1) {
invalidate_extent_lru(tree, page_offset(page), PAGE_CACHE_SIZE);
ClearPagePrivate(page);
set_page_private(page, 0);
page_cache_release(page);
Expand Down Expand Up @@ -376,14 +377,14 @@ int btrfs_verify_block_csum(struct btrfs_root *root,
buf->flags |= EXTENT_CSUM;
return 0;
}

lock_extent(io_tree, buf->start, end, GFP_NOFS);

if (test_range_bit(io_tree, buf->start, end, EXTENT_CSUM, 1)) {
buf->flags |= EXTENT_CSUM;
ret = 0;
goto out_unlock;
}
WARN_ON(buf->flags & EXTENT_CSUM);

ret = csum_tree_block(root, buf, 1);
set_extent_bits(io_tree, buf->start, end, EXTENT_CSUM, GFP_NOFS);
Expand Down
54 changes: 51 additions & 3 deletions trunk/fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2592,6 +2592,33 @@ static inline struct page *extent_buffer_page(struct extent_buffer *eb,
return p;
}

int invalidate_extent_lru(struct extent_io_tree *tree, u64 start,
unsigned long len)
{
struct list_head *lru = &tree->buffer_lru;
struct list_head *cur = lru->next;
struct extent_buffer *eb;
int found = 0;

spin_lock(&tree->lru_lock);
if (list_empty(lru))
goto out;

do {
eb = list_entry(cur, struct extent_buffer, lru);
if (eb->start <= start && eb->start + eb->len > start) {
eb->flags &= ~EXTENT_UPTODATE;
}
if (eb->start == start) {
eb->flags &= ~EXTENT_CSUM;
}
cur = cur->next;
} while (cur != lru);
out:
spin_unlock(&tree->lru_lock);
return found;
}

static struct extent_buffer *__alloc_extent_buffer(struct extent_io_tree *tree,
u64 start,
unsigned long len,
Expand Down Expand Up @@ -2909,10 +2936,32 @@ EXPORT_SYMBOL(set_extent_buffer_uptodate);
int extent_buffer_uptodate(struct extent_io_tree *tree,
struct extent_buffer *eb)
{
int ret = 0;
int ret2;
int num_pages;
int i;
struct page *page;
int pg_uptodate = 1;

if (eb->flags & EXTENT_UPTODATE)
return 1;
return test_range_bit(tree, eb->start, eb->start + eb->len - 1,
ret = 1;

ret2 = test_range_bit(tree, eb->start, eb->start + eb->len - 1,
EXTENT_UPTODATE, 1);

num_pages = num_extent_pages(eb->start, eb->len);
for (i = 0; i < num_pages; i++) {
page = extent_buffer_page(eb, i);
if (!PageUptodate(page)) {
pg_uptodate = 0;
break;
}
}
if ((ret || ret2) && !pg_uptodate) {
printk("uptodate error2 eb %Lu ret %d ret2 %d pg_uptodate %d\n", eb->start, ret, ret2, pg_uptodate);
WARN_ON(1);
}
return (ret || ret2);
}
EXPORT_SYMBOL(extent_buffer_uptodate);

Expand All @@ -2929,7 +2978,6 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
unsigned long num_pages;
struct bio *bio = NULL;


if (eb->flags & EXTENT_UPTODATE)
return 0;

Expand Down
2 changes: 2 additions & 0 deletions trunk/fs/btrfs/extent_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,6 @@ int map_private_extent_buffer(struct extent_buffer *eb, unsigned long offset,
unsigned long *map_start,
unsigned long *map_len, int km);
void unmap_extent_buffer(struct extent_buffer *eb, char *token, int km);
int invalidate_extent_lru(struct extent_io_tree *tree, u64 start,
unsigned long len);
#endif

0 comments on commit c5e8881

Please sign in to comment.