aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-09-23 13:14:12 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:07 -0400
commitce3ed71a58094544da1e1dc4723f1f553bb5b2d5 (patch)
tree8622438279a58a424782a5267eac73a0983144ad /fs/btrfs/disk-io.c
parent0f9dd46cda36b8de3b9f48bc42bd09d20b9c3b52 (diff)
Btrfs: Checksum tree blocks in the background
Tree blocks were using async bio submission, but the sum was still being done directly during writepage. This moves the checksumming into the worker thread. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 535bd0fe1a71..25be96946a2f 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -315,14 +315,6 @@ out:
315 return 0; 315 return 0;
316} 316}
317 317
318static int btree_writepage_io_hook(struct page *page, u64 start, u64 end)
319{
320 struct btrfs_root *root = BTRFS_I(page->mapping->host)->root;
321
322 csum_dirty_buffer(root, page);
323 return 0;
324}
325
326int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end, 318int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
327 struct extent_state *state) 319 struct extent_state *state)
328{ 320{
@@ -501,6 +493,22 @@ int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode,
501 return 0; 493 return 0;
502} 494}
503 495
496static int btree_csum_one_bio(struct bio *bio)
497{
498 struct bio_vec *bvec = bio->bi_io_vec;
499 int bio_index = 0;
500 struct btrfs_root *root;
501
502 WARN_ON(bio->bi_vcnt <= 0);
503 while(bio_index < bio->bi_vcnt) {
504 root = BTRFS_I(bvec->bv_page->mapping->host)->root;
505 csum_dirty_buffer(root, bvec->bv_page);
506 bio_index++;
507 bvec++;
508 }
509 return 0;
510}
511
504static int __btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, 512static int __btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
505 int mirror_num) 513 int mirror_num)
506{ 514{
@@ -515,6 +523,7 @@ static int __btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
515 * submission context. Just jump into btrfs_map_bio 523 * submission context. Just jump into btrfs_map_bio
516 */ 524 */
517 if (rw & (1 << BIO_RW)) { 525 if (rw & (1 << BIO_RW)) {
526 btree_csum_one_bio(bio);
518 return btrfs_map_bio(BTRFS_I(inode)->root, rw, bio, 527 return btrfs_map_bio(BTRFS_I(inode)->root, rw, bio,
519 mirror_num, 1); 528 mirror_num, 1);
520 } 529 }
@@ -2040,7 +2049,6 @@ out:
2040 2049
2041static struct extent_io_ops btree_extent_io_ops = { 2050static struct extent_io_ops btree_extent_io_ops = {
2042 .write_cache_pages_lock_hook = btree_lock_page_hook, 2051 .write_cache_pages_lock_hook = btree_lock_page_hook,
2043 .writepage_io_hook = btree_writepage_io_hook,
2044 .readpage_end_io_hook = btree_readpage_end_io_hook, 2052 .readpage_end_io_hook = btree_readpage_end_io_hook,
2045 .submit_bio_hook = btree_submit_bio_hook, 2053 .submit_bio_hook = btree_submit_bio_hook,
2046 /* note we're sharing with inode.c for the merge bio hook */ 2054 /* note we're sharing with inode.c for the merge bio hook */