aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2013-05-28 06:05:39 -0400
committerJosef Bacik <jbacik@fusionio.com>2013-06-14 11:30:05 -0400
commitc6adc9cc082e3cffda153999c9b9f8a8baaaaf45 (patch)
tree45502fe9f6d6468f17dbbe7b7aa83d261626d65c /fs/btrfs/tree-log.c
parenta96fbc72884fcb0367c6c838357b841b8f10a531 (diff)
Btrfs: merge pending IO for tree log write back
Before applying this patch, we flushed the log tree of the fs/file tree firstly, and then flushed the log root tree. It is ineffective, especially on the hard disk. This patch improved this problem by wrapping the above two flushes by the same blk_plug. By test, the performance of the sync write went up ~60%(2.9MB/s -> 4.6MB/s) on my scsi disk whose disk buffer was enabled. Test step: # mkfs.btrfs -f -m single <disk> # mount <disk> <mnt> # dd if=/dev/zero of=<mnt>/file0 bs=32K count=1024 oflag=sync Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 965d5e64b480..831ddd4bf897 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/blkdev.h>
21#include <linux/list_sort.h> 22#include <linux/list_sort.h>
22#include "ctree.h" 23#include "ctree.h"
23#include "transaction.h" 24#include "transaction.h"
@@ -2353,6 +2354,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2353 struct btrfs_root *log = root->log_root; 2354 struct btrfs_root *log = root->log_root;
2354 struct btrfs_root *log_root_tree = root->fs_info->log_root_tree; 2355 struct btrfs_root *log_root_tree = root->fs_info->log_root_tree;
2355 unsigned long log_transid = 0; 2356 unsigned long log_transid = 0;
2357 struct blk_plug plug;
2356 2358
2357 mutex_lock(&root->log_mutex); 2359 mutex_lock(&root->log_mutex);
2358 log_transid = root->log_transid; 2360 log_transid = root->log_transid;
@@ -2396,8 +2398,10 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2396 /* we start IO on all the marked extents here, but we don't actually 2398 /* we start IO on all the marked extents here, but we don't actually
2397 * wait for them until later. 2399 * wait for them until later.
2398 */ 2400 */
2401 blk_start_plug(&plug);
2399 ret = btrfs_write_marked_extents(log, &log->dirty_log_pages, mark); 2402 ret = btrfs_write_marked_extents(log, &log->dirty_log_pages, mark);
2400 if (ret) { 2403 if (ret) {
2404 blk_finish_plug(&plug);
2401 btrfs_abort_transaction(trans, root, ret); 2405 btrfs_abort_transaction(trans, root, ret);
2402 btrfs_free_logged_extents(log, log_transid); 2406 btrfs_free_logged_extents(log, log_transid);
2403 mutex_unlock(&root->log_mutex); 2407 mutex_unlock(&root->log_mutex);
@@ -2432,6 +2436,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2432 } 2436 }
2433 2437
2434 if (ret) { 2438 if (ret) {
2439 blk_finish_plug(&plug);
2435 if (ret != -ENOSPC) { 2440 if (ret != -ENOSPC) {
2436 btrfs_abort_transaction(trans, root, ret); 2441 btrfs_abort_transaction(trans, root, ret);
2437 mutex_unlock(&log_root_tree->log_mutex); 2442 mutex_unlock(&log_root_tree->log_mutex);
@@ -2447,6 +2452,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2447 2452
2448 index2 = log_root_tree->log_transid % 2; 2453 index2 = log_root_tree->log_transid % 2;
2449 if (atomic_read(&log_root_tree->log_commit[index2])) { 2454 if (atomic_read(&log_root_tree->log_commit[index2])) {
2455 blk_finish_plug(&plug);
2450 btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark); 2456 btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark);
2451 wait_log_commit(trans, log_root_tree, 2457 wait_log_commit(trans, log_root_tree,
2452 log_root_tree->log_transid); 2458 log_root_tree->log_transid);
@@ -2469,6 +2475,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2469 * check the full commit flag again 2475 * check the full commit flag again
2470 */ 2476 */
2471 if (root->fs_info->last_trans_log_full_commit == trans->transid) { 2477 if (root->fs_info->last_trans_log_full_commit == trans->transid) {
2478 blk_finish_plug(&plug);
2472 btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark); 2479 btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark);
2473 btrfs_free_logged_extents(log, log_transid); 2480 btrfs_free_logged_extents(log, log_transid);
2474 mutex_unlock(&log_root_tree->log_mutex); 2481 mutex_unlock(&log_root_tree->log_mutex);
@@ -2476,9 +2483,10 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2476 goto out_wake_log_root; 2483 goto out_wake_log_root;
2477 } 2484 }
2478 2485
2479 ret = btrfs_write_and_wait_marked_extents(log_root_tree, 2486 ret = btrfs_write_marked_extents(log_root_tree,
2480 &log_root_tree->dirty_log_pages, 2487 &log_root_tree->dirty_log_pages,
2481 EXTENT_DIRTY | EXTENT_NEW); 2488 EXTENT_DIRTY | EXTENT_NEW);
2489 blk_finish_plug(&plug);
2482 if (ret) { 2490 if (ret) {
2483 btrfs_abort_transaction(trans, root, ret); 2491 btrfs_abort_transaction(trans, root, ret);
2484 btrfs_free_logged_extents(log, log_transid); 2492 btrfs_free_logged_extents(log, log_transid);
@@ -2486,6 +2494,9 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2486 goto out_wake_log_root; 2494 goto out_wake_log_root;
2487 } 2495 }
2488 btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark); 2496 btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark);
2497 btrfs_wait_marked_extents(log_root_tree,
2498 &log_root_tree->dirty_log_pages,
2499 EXTENT_NEW | EXTENT_DIRTY);
2489 btrfs_wait_logged_extents(log, log_transid); 2500 btrfs_wait_logged_extents(log, log_transid);
2490 2501
2491 btrfs_set_super_log_root(root->fs_info->super_for_commit, 2502 btrfs_set_super_log_root(root->fs_info->super_for_commit,