diff options
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 5e789f4a3ed0..fb827d0d7181 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -338,7 +338,6 @@ static int csum_dirty_buffer(struct btrfs_root *root, struct page *page) | |||
338 | struct extent_io_tree *tree; | 338 | struct extent_io_tree *tree; |
339 | u64 start = (u64)page->index << PAGE_CACHE_SHIFT; | 339 | u64 start = (u64)page->index << PAGE_CACHE_SHIFT; |
340 | u64 found_start; | 340 | u64 found_start; |
341 | int found_level; | ||
342 | unsigned long len; | 341 | unsigned long len; |
343 | struct extent_buffer *eb; | 342 | struct extent_buffer *eb; |
344 | int ret; | 343 | int ret; |
@@ -369,8 +368,6 @@ static int csum_dirty_buffer(struct btrfs_root *root, struct page *page) | |||
369 | WARN_ON(1); | 368 | WARN_ON(1); |
370 | goto err; | 369 | goto err; |
371 | } | 370 | } |
372 | found_level = btrfs_header_level(eb); | ||
373 | |||
374 | csum_tree_block(root, eb, 0); | 371 | csum_tree_block(root, eb, 0); |
375 | err: | 372 | err: |
376 | free_extent_buffer(eb); | 373 | free_extent_buffer(eb); |
@@ -481,9 +478,12 @@ static void end_workqueue_bio(struct bio *bio, int err) | |||
481 | end_io_wq->work.flags = 0; | 478 | end_io_wq->work.flags = 0; |
482 | 479 | ||
483 | if (bio->bi_rw & REQ_WRITE) { | 480 | if (bio->bi_rw & REQ_WRITE) { |
484 | if (end_io_wq->metadata) | 481 | if (end_io_wq->metadata == 1) |
485 | btrfs_queue_worker(&fs_info->endio_meta_write_workers, | 482 | btrfs_queue_worker(&fs_info->endio_meta_write_workers, |
486 | &end_io_wq->work); | 483 | &end_io_wq->work); |
484 | else if (end_io_wq->metadata == 2) | ||
485 | btrfs_queue_worker(&fs_info->endio_freespace_worker, | ||
486 | &end_io_wq->work); | ||
487 | else | 487 | else |
488 | btrfs_queue_worker(&fs_info->endio_write_workers, | 488 | btrfs_queue_worker(&fs_info->endio_write_workers, |
489 | &end_io_wq->work); | 489 | &end_io_wq->work); |
@@ -497,6 +497,13 @@ static void end_workqueue_bio(struct bio *bio, int err) | |||
497 | } | 497 | } |
498 | } | 498 | } |
499 | 499 | ||
500 | /* | ||
501 | * For the metadata arg you want | ||
502 | * | ||
503 | * 0 - if data | ||
504 | * 1 - if normal metadta | ||
505 | * 2 - if writing to the free space cache area | ||
506 | */ | ||
500 | int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio, | 507 | int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio, |
501 | int metadata) | 508 | int metadata) |
502 | { | 509 | { |
@@ -533,11 +540,9 @@ int btrfs_congested_async(struct btrfs_fs_info *info, int iodone) | |||
533 | 540 | ||
534 | static void run_one_async_start(struct btrfs_work *work) | 541 | static void run_one_async_start(struct btrfs_work *work) |
535 | { | 542 | { |
536 | struct btrfs_fs_info *fs_info; | ||
537 | struct async_submit_bio *async; | 543 | struct async_submit_bio *async; |
538 | 544 | ||
539 | async = container_of(work, struct async_submit_bio, work); | 545 | async = container_of(work, struct async_submit_bio, work); |
540 | fs_info = BTRFS_I(async->inode)->root->fs_info; | ||
541 | async->submit_bio_start(async->inode, async->rw, async->bio, | 546 | async->submit_bio_start(async->inode, async->rw, async->bio, |
542 | async->mirror_num, async->bio_flags, | 547 | async->mirror_num, async->bio_flags, |
543 | async->bio_offset); | 548 | async->bio_offset); |
@@ -850,12 +855,8 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, | |||
850 | u32 blocksize, u64 parent_transid) | 855 | u32 blocksize, u64 parent_transid) |
851 | { | 856 | { |
852 | struct extent_buffer *buf = NULL; | 857 | struct extent_buffer *buf = NULL; |
853 | struct inode *btree_inode = root->fs_info->btree_inode; | ||
854 | struct extent_io_tree *io_tree; | ||
855 | int ret; | 858 | int ret; |
856 | 859 | ||
857 | io_tree = &BTRFS_I(btree_inode)->io_tree; | ||
858 | |||
859 | buf = btrfs_find_create_tree_block(root, bytenr, blocksize); | 860 | buf = btrfs_find_create_tree_block(root, bytenr, blocksize); |
860 | if (!buf) | 861 | if (!buf) |
861 | return NULL; | 862 | return NULL; |
@@ -1377,7 +1378,6 @@ static int bio_ready_for_csum(struct bio *bio) | |||
1377 | u64 start = 0; | 1378 | u64 start = 0; |
1378 | struct page *page; | 1379 | struct page *page; |
1379 | struct extent_io_tree *io_tree = NULL; | 1380 | struct extent_io_tree *io_tree = NULL; |
1380 | struct btrfs_fs_info *info = NULL; | ||
1381 | struct bio_vec *bvec; | 1381 | struct bio_vec *bvec; |
1382 | int i; | 1382 | int i; |
1383 | int ret; | 1383 | int ret; |
@@ -1396,7 +1396,6 @@ static int bio_ready_for_csum(struct bio *bio) | |||
1396 | buf_len = page->private >> 2; | 1396 | buf_len = page->private >> 2; |
1397 | start = page_offset(page) + bvec->bv_offset; | 1397 | start = page_offset(page) + bvec->bv_offset; |
1398 | io_tree = &BTRFS_I(page->mapping->host)->io_tree; | 1398 | io_tree = &BTRFS_I(page->mapping->host)->io_tree; |
1399 | info = BTRFS_I(page->mapping->host)->root->fs_info; | ||
1400 | } | 1399 | } |
1401 | /* are we fully contained in this bio? */ | 1400 | /* are we fully contained in this bio? */ |
1402 | if (buf_len <= length) | 1401 | if (buf_len <= length) |
@@ -1680,12 +1679,12 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1680 | 1679 | ||
1681 | init_waitqueue_head(&fs_info->transaction_throttle); | 1680 | init_waitqueue_head(&fs_info->transaction_throttle); |
1682 | init_waitqueue_head(&fs_info->transaction_wait); | 1681 | init_waitqueue_head(&fs_info->transaction_wait); |
1682 | init_waitqueue_head(&fs_info->transaction_blocked_wait); | ||
1683 | init_waitqueue_head(&fs_info->async_submit_wait); | 1683 | init_waitqueue_head(&fs_info->async_submit_wait); |
1684 | 1684 | ||
1685 | __setup_root(4096, 4096, 4096, 4096, tree_root, | 1685 | __setup_root(4096, 4096, 4096, 4096, tree_root, |
1686 | fs_info, BTRFS_ROOT_TREE_OBJECTID); | 1686 | fs_info, BTRFS_ROOT_TREE_OBJECTID); |
1687 | 1687 | ||
1688 | |||
1689 | bh = btrfs_read_dev_super(fs_devices->latest_bdev); | 1688 | bh = btrfs_read_dev_super(fs_devices->latest_bdev); |
1690 | if (!bh) | 1689 | if (!bh) |
1691 | goto fail_iput; | 1690 | goto fail_iput; |
@@ -1775,6 +1774,8 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1775 | btrfs_init_workers(&fs_info->endio_write_workers, "endio-write", | 1774 | btrfs_init_workers(&fs_info->endio_write_workers, "endio-write", |
1776 | fs_info->thread_pool_size, | 1775 | fs_info->thread_pool_size, |
1777 | &fs_info->generic_worker); | 1776 | &fs_info->generic_worker); |
1777 | btrfs_init_workers(&fs_info->endio_freespace_worker, "freespace-write", | ||
1778 | 1, &fs_info->generic_worker); | ||
1778 | 1779 | ||
1779 | /* | 1780 | /* |
1780 | * endios are largely parallel and should have a very | 1781 | * endios are largely parallel and should have a very |
@@ -1795,6 +1796,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1795 | btrfs_start_workers(&fs_info->endio_meta_workers, 1); | 1796 | btrfs_start_workers(&fs_info->endio_meta_workers, 1); |
1796 | btrfs_start_workers(&fs_info->endio_meta_write_workers, 1); | 1797 | btrfs_start_workers(&fs_info->endio_meta_write_workers, 1); |
1797 | btrfs_start_workers(&fs_info->endio_write_workers, 1); | 1798 | btrfs_start_workers(&fs_info->endio_write_workers, 1); |
1799 | btrfs_start_workers(&fs_info->endio_freespace_worker, 1); | ||
1798 | 1800 | ||
1799 | fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super); | 1801 | fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super); |
1800 | fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages, | 1802 | fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages, |
@@ -1993,6 +1995,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1993 | if (!(sb->s_flags & MS_RDONLY)) { | 1995 | if (!(sb->s_flags & MS_RDONLY)) { |
1994 | down_read(&fs_info->cleanup_work_sem); | 1996 | down_read(&fs_info->cleanup_work_sem); |
1995 | btrfs_orphan_cleanup(fs_info->fs_root); | 1997 | btrfs_orphan_cleanup(fs_info->fs_root); |
1998 | btrfs_orphan_cleanup(fs_info->tree_root); | ||
1996 | up_read(&fs_info->cleanup_work_sem); | 1999 | up_read(&fs_info->cleanup_work_sem); |
1997 | } | 2000 | } |
1998 | 2001 | ||
@@ -2035,6 +2038,7 @@ fail_sb_buffer: | |||
2035 | btrfs_stop_workers(&fs_info->endio_meta_workers); | 2038 | btrfs_stop_workers(&fs_info->endio_meta_workers); |
2036 | btrfs_stop_workers(&fs_info->endio_meta_write_workers); | 2039 | btrfs_stop_workers(&fs_info->endio_meta_write_workers); |
2037 | btrfs_stop_workers(&fs_info->endio_write_workers); | 2040 | btrfs_stop_workers(&fs_info->endio_write_workers); |
2041 | btrfs_stop_workers(&fs_info->endio_freespace_worker); | ||
2038 | btrfs_stop_workers(&fs_info->submit_workers); | 2042 | btrfs_stop_workers(&fs_info->submit_workers); |
2039 | fail_iput: | 2043 | fail_iput: |
2040 | invalidate_inode_pages2(fs_info->btree_inode->i_mapping); | 2044 | invalidate_inode_pages2(fs_info->btree_inode->i_mapping); |
@@ -2410,6 +2414,7 @@ int close_ctree(struct btrfs_root *root) | |||
2410 | fs_info->closing = 1; | 2414 | fs_info->closing = 1; |
2411 | smp_mb(); | 2415 | smp_mb(); |
2412 | 2416 | ||
2417 | btrfs_put_block_group_cache(fs_info); | ||
2413 | if (!(fs_info->sb->s_flags & MS_RDONLY)) { | 2418 | if (!(fs_info->sb->s_flags & MS_RDONLY)) { |
2414 | ret = btrfs_commit_super(root); | 2419 | ret = btrfs_commit_super(root); |
2415 | if (ret) | 2420 | if (ret) |
@@ -2456,6 +2461,7 @@ int close_ctree(struct btrfs_root *root) | |||
2456 | btrfs_stop_workers(&fs_info->endio_meta_workers); | 2461 | btrfs_stop_workers(&fs_info->endio_meta_workers); |
2457 | btrfs_stop_workers(&fs_info->endio_meta_write_workers); | 2462 | btrfs_stop_workers(&fs_info->endio_meta_write_workers); |
2458 | btrfs_stop_workers(&fs_info->endio_write_workers); | 2463 | btrfs_stop_workers(&fs_info->endio_write_workers); |
2464 | btrfs_stop_workers(&fs_info->endio_freespace_worker); | ||
2459 | btrfs_stop_workers(&fs_info->submit_workers); | 2465 | btrfs_stop_workers(&fs_info->submit_workers); |
2460 | 2466 | ||
2461 | btrfs_close_devices(fs_info->fs_devices); | 2467 | btrfs_close_devices(fs_info->fs_devices); |