aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2010-07-02 12:14:14 -0400
committerChris Mason <chris.mason@oracle.com>2010-10-29 09:26:29 -0400
commit0cb59c9953171e9adf6da8142a5c85ceb77bb60d (patch)
treef72af47fa18815491814290a1b4907082bd9316d /fs/btrfs/disk-io.c
parent0af3d00bad38d3bb9912a60928ad0669f17bdb76 (diff)
Btrfs: write out free space cache
This is a simple bit, just dump the free space cache out to our preallocated inode when we're writing out dirty block groups. There are a bunch of changes in inode.c in order to account for special cases. Mostly when we're doing the writeout we're holding trans_mutex, so we need to use the nolock transacation functions. Also we can't do asynchronous completions since the async thread could be blocked on already completed IO waiting for the transaction lock. This has been tested with xfstests and btrfs filesystem balance, as well as my ENOSPC tests. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 45cf64fc1e3e..77e5dabfd45a 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -481,9 +481,12 @@ static void end_workqueue_bio(struct bio *bio, int err)
481 end_io_wq->work.flags = 0; 481 end_io_wq->work.flags = 0;
482 482
483 if (bio->bi_rw & REQ_WRITE) { 483 if (bio->bi_rw & REQ_WRITE) {
484 if (end_io_wq->metadata) 484 if (end_io_wq->metadata == 1)
485 btrfs_queue_worker(&fs_info->endio_meta_write_workers, 485 btrfs_queue_worker(&fs_info->endio_meta_write_workers,
486 &end_io_wq->work); 486 &end_io_wq->work);
487 else if (end_io_wq->metadata == 2)
488 btrfs_queue_worker(&fs_info->endio_freespace_worker,
489 &end_io_wq->work);
487 else 490 else
488 btrfs_queue_worker(&fs_info->endio_write_workers, 491 btrfs_queue_worker(&fs_info->endio_write_workers,
489 &end_io_wq->work); 492 &end_io_wq->work);
@@ -497,6 +500,13 @@ static void end_workqueue_bio(struct bio *bio, int err)
497 } 500 }
498} 501}
499 502
503/*
504 * For the metadata arg you want
505 *
506 * 0 - if data
507 * 1 - if normal metadta
508 * 2 - if writing to the free space cache area
509 */
500int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio, 510int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio,
501 int metadata) 511 int metadata)
502{ 512{
@@ -1774,6 +1784,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1774 btrfs_init_workers(&fs_info->endio_write_workers, "endio-write", 1784 btrfs_init_workers(&fs_info->endio_write_workers, "endio-write",
1775 fs_info->thread_pool_size, 1785 fs_info->thread_pool_size,
1776 &fs_info->generic_worker); 1786 &fs_info->generic_worker);
1787 btrfs_init_workers(&fs_info->endio_freespace_worker, "freespace-write",
1788 1, &fs_info->generic_worker);
1777 1789
1778 /* 1790 /*
1779 * endios are largely parallel and should have a very 1791 * endios are largely parallel and should have a very
@@ -1794,6 +1806,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1794 btrfs_start_workers(&fs_info->endio_meta_workers, 1); 1806 btrfs_start_workers(&fs_info->endio_meta_workers, 1);
1795 btrfs_start_workers(&fs_info->endio_meta_write_workers, 1); 1807 btrfs_start_workers(&fs_info->endio_meta_write_workers, 1);
1796 btrfs_start_workers(&fs_info->endio_write_workers, 1); 1808 btrfs_start_workers(&fs_info->endio_write_workers, 1);
1809 btrfs_start_workers(&fs_info->endio_freespace_worker, 1);
1797 1810
1798 fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super); 1811 fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super);
1799 fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages, 1812 fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages,
@@ -2035,6 +2048,7 @@ fail_sb_buffer:
2035 btrfs_stop_workers(&fs_info->endio_meta_workers); 2048 btrfs_stop_workers(&fs_info->endio_meta_workers);
2036 btrfs_stop_workers(&fs_info->endio_meta_write_workers); 2049 btrfs_stop_workers(&fs_info->endio_meta_write_workers);
2037 btrfs_stop_workers(&fs_info->endio_write_workers); 2050 btrfs_stop_workers(&fs_info->endio_write_workers);
2051 btrfs_stop_workers(&fs_info->endio_freespace_worker);
2038 btrfs_stop_workers(&fs_info->submit_workers); 2052 btrfs_stop_workers(&fs_info->submit_workers);
2039fail_iput: 2053fail_iput:
2040 invalidate_inode_pages2(fs_info->btree_inode->i_mapping); 2054 invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
@@ -2468,6 +2482,7 @@ int close_ctree(struct btrfs_root *root)
2468 btrfs_stop_workers(&fs_info->endio_meta_workers); 2482 btrfs_stop_workers(&fs_info->endio_meta_workers);
2469 btrfs_stop_workers(&fs_info->endio_meta_write_workers); 2483 btrfs_stop_workers(&fs_info->endio_meta_write_workers);
2470 btrfs_stop_workers(&fs_info->endio_write_workers); 2484 btrfs_stop_workers(&fs_info->endio_write_workers);
2485 btrfs_stop_workers(&fs_info->endio_freespace_worker);
2471 btrfs_stop_workers(&fs_info->submit_workers); 2486 btrfs_stop_workers(&fs_info->submit_workers);
2472 2487
2473 btrfs_close_devices(fs_info->fs_devices); 2488 btrfs_close_devices(fs_info->fs_devices);