aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2013-05-15 03:48:28 -0400
committerJosef Bacik <jbacik@fusionio.com>2013-06-14 11:29:47 -0400
commit824366177aa108eb7b778dc67e4f38b9e01df93f (patch)
tree973dcc26b4af6720102522027132fc4d8545c9c6
parent0860adfdb21c87c73afab4d143e7195603b3e883 (diff)
Btrfs: don't flush the delalloc inodes in the while loop if flushoncommit is set
It is unnecessary to flush the delalloc inodes again and again because we don't care the dirty pages which are introduced after the flush, and they will be flush in the transaction commit. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
-rw-r--r--fs/btrfs/transaction.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index fd319b2ecd84..265db57b3341 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1518,16 +1518,8 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans,
1518static int btrfs_flush_all_pending_stuffs(struct btrfs_trans_handle *trans, 1518static int btrfs_flush_all_pending_stuffs(struct btrfs_trans_handle *trans,
1519 struct btrfs_root *root) 1519 struct btrfs_root *root)
1520{ 1520{
1521 int flush_on_commit = btrfs_test_opt(root, FLUSHONCOMMIT);
1522 int ret; 1521 int ret;
1523 1522
1524 if (flush_on_commit) {
1525 ret = btrfs_start_all_delalloc_inodes(root->fs_info, 1);
1526 if (ret)
1527 return ret;
1528 btrfs_wait_all_ordered_extents(root->fs_info, 1);
1529 }
1530
1531 ret = btrfs_run_delayed_items(trans, root); 1523 ret = btrfs_run_delayed_items(trans, root);
1532 if (ret) 1524 if (ret)
1533 return ret; 1525 return ret;
@@ -1551,6 +1543,19 @@ static int btrfs_flush_all_pending_stuffs(struct btrfs_trans_handle *trans,
1551 return ret; 1543 return ret;
1552} 1544}
1553 1545
1546static inline int btrfs_start_delalloc_flush(struct btrfs_fs_info *fs_info)
1547{
1548 if (btrfs_test_opt(fs_info->tree_root, FLUSHONCOMMIT))
1549 return btrfs_start_all_delalloc_inodes(fs_info, 1);
1550 return 0;
1551}
1552
1553static inline void btrfs_wait_delalloc_flush(struct btrfs_fs_info *fs_info)
1554{
1555 if (btrfs_test_opt(fs_info->tree_root, FLUSHONCOMMIT))
1556 btrfs_wait_all_ordered_extents(fs_info, 1);
1557}
1558
1554/* 1559/*
1555 * btrfs_transaction state sequence: 1560 * btrfs_transaction state sequence:
1556 * in_commit = 0, blocked = 0 (initial) 1561 * in_commit = 0, blocked = 0 (initial)
@@ -1654,6 +1659,10 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
1654 1659
1655 extwriter_counter_dec(cur_trans, trans->type); 1660 extwriter_counter_dec(cur_trans, trans->type);
1656 1661
1662 ret = btrfs_start_delalloc_flush(root->fs_info);
1663 if (ret)
1664 goto cleanup_transaction;
1665
1657 if (!btrfs_test_opt(root, SSD) && 1666 if (!btrfs_test_opt(root, SSD) &&
1658 (now < cur_trans->start_time || now - cur_trans->start_time < 1)) 1667 (now < cur_trans->start_time || now - cur_trans->start_time < 1))
1659 should_grow = 1; 1668 should_grow = 1;
@@ -1683,6 +1692,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
1683 if (ret) 1692 if (ret)
1684 goto cleanup_transaction; 1693 goto cleanup_transaction;
1685 1694
1695 btrfs_wait_delalloc_flush(root->fs_info);
1686 /* 1696 /*
1687 * Ok now we need to make sure to block out any other joins while we 1697 * Ok now we need to make sure to block out any other joins while we
1688 * commit the transaction. We could have started a join before setting 1698 * commit the transaction. We could have started a join before setting