diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-07-17 12:53:50 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:04 -0400 |
commit | e6dcd2dc9c489108648e2ed543315dd134d50a9a (patch) | |
tree | cddf6f588b65e28c5feb8bff89b22d8ff70f8a50 /fs/btrfs/disk-io.c | |
parent | 77a41afb7d0dd0f27b6f2f1a5bc701929c7034de (diff) |
Btrfs: New data=ordered implementation
The old data=ordered code would force commit to wait until
all the data extents from the transaction were fully on disk. This
introduced large latencies into the commit and stalled new writers
in the transaction for a long time.
The new code changes the way data allocations and extents work:
* When delayed allocation is filled, data extents are reserved, and
the extent bit EXTENT_ORDERED is set on the entire range of the extent.
A struct btrfs_ordered_extent is allocated an inserted into a per-inode
rbtree to track the pending extents.
* As each page is written EXTENT_ORDERED is cleared on the bytes corresponding
to that page.
* When all of the bytes corresponding to a single struct btrfs_ordered_extent
are written, The previously reserved extent is inserted into the FS
btree and into the extent allocation trees. The checksums for the file
data are also updated.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index b01b3f4f92a9..4a5ebafb935a 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -407,7 +407,11 @@ static int end_workqueue_bio(struct bio *bio, | |||
407 | end_io_wq->error = err; | 407 | end_io_wq->error = err; |
408 | end_io_wq->work.func = end_workqueue_fn; | 408 | end_io_wq->work.func = end_workqueue_fn; |
409 | end_io_wq->work.flags = 0; | 409 | end_io_wq->work.flags = 0; |
410 | btrfs_queue_worker(&fs_info->endio_workers, &end_io_wq->work); | 410 | if (bio->bi_rw & (1 << BIO_RW)) |
411 | btrfs_queue_worker(&fs_info->endio_write_workers, | ||
412 | &end_io_wq->work); | ||
413 | else | ||
414 | btrfs_queue_worker(&fs_info->endio_workers, &end_io_wq->work); | ||
411 | 415 | ||
412 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) | 416 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) |
413 | return 0; | 417 | return 0; |
@@ -1286,6 +1290,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1286 | mutex_init(&fs_info->transaction_kthread_mutex); | 1290 | mutex_init(&fs_info->transaction_kthread_mutex); |
1287 | mutex_init(&fs_info->cleaner_mutex); | 1291 | mutex_init(&fs_info->cleaner_mutex); |
1288 | mutex_init(&fs_info->volume_mutex); | 1292 | mutex_init(&fs_info->volume_mutex); |
1293 | init_waitqueue_head(&fs_info->transaction_throttle); | ||
1289 | 1294 | ||
1290 | #if 0 | 1295 | #if 0 |
1291 | ret = add_hasher(fs_info, "crc32c"); | 1296 | ret = add_hasher(fs_info, "crc32c"); |
@@ -1325,9 +1330,13 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1325 | btrfs_init_workers(&fs_info->workers, fs_info->thread_pool_size); | 1330 | btrfs_init_workers(&fs_info->workers, fs_info->thread_pool_size); |
1326 | btrfs_init_workers(&fs_info->submit_workers, fs_info->thread_pool_size); | 1331 | btrfs_init_workers(&fs_info->submit_workers, fs_info->thread_pool_size); |
1327 | btrfs_init_workers(&fs_info->endio_workers, fs_info->thread_pool_size); | 1332 | btrfs_init_workers(&fs_info->endio_workers, fs_info->thread_pool_size); |
1333 | btrfs_init_workers(&fs_info->endio_write_workers, | ||
1334 | fs_info->thread_pool_size); | ||
1328 | btrfs_start_workers(&fs_info->workers, 1); | 1335 | btrfs_start_workers(&fs_info->workers, 1); |
1329 | btrfs_start_workers(&fs_info->submit_workers, 1); | 1336 | btrfs_start_workers(&fs_info->submit_workers, 1); |
1330 | btrfs_start_workers(&fs_info->endio_workers, fs_info->thread_pool_size); | 1337 | btrfs_start_workers(&fs_info->endio_workers, fs_info->thread_pool_size); |
1338 | btrfs_start_workers(&fs_info->endio_write_workers, | ||
1339 | fs_info->thread_pool_size); | ||
1331 | 1340 | ||
1332 | err = -EINVAL; | 1341 | err = -EINVAL; |
1333 | if (btrfs_super_num_devices(disk_super) > fs_devices->open_devices) { | 1342 | if (btrfs_super_num_devices(disk_super) > fs_devices->open_devices) { |
@@ -1447,6 +1456,7 @@ fail_sb_buffer: | |||
1447 | extent_io_tree_empty_lru(&BTRFS_I(fs_info->btree_inode)->io_tree); | 1456 | extent_io_tree_empty_lru(&BTRFS_I(fs_info->btree_inode)->io_tree); |
1448 | btrfs_stop_workers(&fs_info->workers); | 1457 | btrfs_stop_workers(&fs_info->workers); |
1449 | btrfs_stop_workers(&fs_info->endio_workers); | 1458 | btrfs_stop_workers(&fs_info->endio_workers); |
1459 | btrfs_stop_workers(&fs_info->endio_write_workers); | ||
1450 | btrfs_stop_workers(&fs_info->submit_workers); | 1460 | btrfs_stop_workers(&fs_info->submit_workers); |
1451 | fail_iput: | 1461 | fail_iput: |
1452 | iput(fs_info->btree_inode); | 1462 | iput(fs_info->btree_inode); |
@@ -1702,6 +1712,7 @@ int close_ctree(struct btrfs_root *root) | |||
1702 | 1712 | ||
1703 | btrfs_stop_workers(&fs_info->workers); | 1713 | btrfs_stop_workers(&fs_info->workers); |
1704 | btrfs_stop_workers(&fs_info->endio_workers); | 1714 | btrfs_stop_workers(&fs_info->endio_workers); |
1715 | btrfs_stop_workers(&fs_info->endio_write_workers); | ||
1705 | btrfs_stop_workers(&fs_info->submit_workers); | 1716 | btrfs_stop_workers(&fs_info->submit_workers); |
1706 | 1717 | ||
1707 | iput(fs_info->btree_inode); | 1718 | iput(fs_info->btree_inode); |