summaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-08-20 15:44:52 +0200
committerChris Mason <chris.mason@oracle.com>2008-09-25 17:04:06 +0200
commit4d1b5fb4d7075f862848dbff8873e22382abd482 (patch)
tree2b68d05910f50c9e385890816e78eda6e8e6e55a /fs/btrfs
parentBtrfs: Fix add_extent_mapping to check for duplicates across the whole range (diff)
downloadlinux-4d1b5fb4d7075f862848dbff8873e22382abd482.tar.xz
linux-4d1b5fb4d7075f862848dbff8873e22382abd482.zip
Btrfs: Lookup readpage checksums on bio submission again
This optimization had been removed because I thought it was triggering csum errors. The real cause of the errors was elsewhere, and so this optimization is back. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/file-item.c4
-rw-r--r--fs/btrfs/inode.c62
2 files changed, 6 insertions, 60 deletions
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 9454e0a07c89..f861bd506928 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -134,7 +134,6 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
return ret;
}
-#if 0 /* broken */
int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode,
struct bio *bio)
{
@@ -151,6 +150,8 @@ int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode,
struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
path = btrfs_alloc_path();
+ if (bio->bi_size > PAGE_CACHE_SIZE * 8)
+ path->reada = 2;
WARN_ON(bio->bi_vcnt <= 0);
@@ -211,7 +212,6 @@ found:
btrfs_free_path(path);
return 0;
}
-#endif
int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode,
struct bio *bio)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 6c778043207d..38d7a81763cd 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -389,15 +389,15 @@ int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
BUG_ON(ret);
- if (!(rw & (1 << BIO_RW))) {
- goto mapit;
- }
-
if (btrfs_test_opt(root, NODATASUM) ||
btrfs_test_flag(inode, NODATASUM)) {
goto mapit;
}
+ if (!(rw & (1 << BIO_RW))) {
+ btrfs_lookup_bio_sums(root, inode, bio);
+ goto mapit;
+ }
return btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info,
inode, rw, bio, mirror_num,
__btrfs_submit_bio_hook);
@@ -603,59 +603,6 @@ int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end,
return btrfs_finish_ordered_io(page->mapping->host, start, end);
}
-int btrfs_readpage_io_hook(struct page *page, u64 start, u64 end)
-{
- int ret = 0;
- struct inode *inode = page->mapping->host;
- struct btrfs_root *root = BTRFS_I(inode)->root;
- struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
- struct btrfs_csum_item *item;
- struct btrfs_path *path = NULL;
- u32 csum;
-
- if (btrfs_test_opt(root, NODATASUM) ||
- btrfs_test_flag(inode, NODATASUM))
- return 0;
-
- /*
- * It is possible there is an ordered extent that has
- * not yet finished for this range in the file. If so,
- * that extent will have a csum cached, and it will insert
- * the sum after all the blocks in the extent are fully
- * on disk. So, look for an ordered extent and use the
- * sum if found. We have to do this before looking in the
- * btree because csum items are pre-inserted based on
- * the file size. btrfs_lookup_csum might find an item
- * that still hasn't been fully filled.
- */
- ret = btrfs_find_ordered_sum(inode, start, &csum);
- if (ret == 0)
- goto found;
-
- ret = 0;
- path = btrfs_alloc_path();
- item = btrfs_lookup_csum(NULL, root, path, inode->i_ino, start, 0);
- if (IS_ERR(item)) {
- ret = PTR_ERR(item);
- /* a csum that isn't present is a preallocated region. */
- if (ret == -ENOENT || ret == -EFBIG)
- ret = 0;
- csum = 0;
- if (printk_ratelimit())
- printk("no csum found for inode %lu start %Lu\n", inode->i_ino,
- start);
- goto out;
- }
- read_extent_buffer(path->nodes[0], &csum, (unsigned long)item,
- BTRFS_CRC32_SIZE);
-found:
- set_state_private(io_tree, start, csum);
-out:
- if (path)
- btrfs_free_path(path);
- return ret;
-}
-
struct io_failure_record {
struct page *page;
u64 start;
@@ -3669,7 +3616,6 @@ static struct extent_io_ops btrfs_extent_io_ops = {
.fill_delalloc = run_delalloc_range,
.submit_bio_hook = btrfs_submit_bio_hook,
.merge_bio_hook = btrfs_merge_bio_hook,
- .readpage_io_hook = btrfs_readpage_io_hook,
.readpage_end_io_hook = btrfs_readpage_end_io_hook,
.writepage_end_io_hook = btrfs_writepage_end_io_hook,
.writepage_start_hook = btrfs_writepage_start_hook,