aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2013-05-15 03:48:30 -0400
committerJosef Bacik <jbacik@fusionio.com>2013-06-14 11:29:50 -0400
commit581227d0d2b8735f899182f50b3a05089d02fa24 (patch)
treeea387833d4596ff1cfe78503ba3615da948583d5 /fs/btrfs/transaction.c
parent3f1e3fa65c44b8ecdf2d6f14956c2cfe3a462a03 (diff)
Btrfs: remove the time check in btrfs_commit_transaction()
We checked the commit time to avoid committing the transaction frequently, but it is unnecessary because: - It made the transaction commit spend more time, and delayed the operation of the external writers(TRANS_START/TRANS_USERSPACE). - Except the space that we have to commit transaction, such as snapshot creation, btrfs doesn't commit the transaction on its own initiative. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 75e7b150eb54..5e75ff486daf 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1566,10 +1566,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
1566{ 1566{
1567 struct btrfs_transaction *cur_trans = trans->transaction; 1567 struct btrfs_transaction *cur_trans = trans->transaction;
1568 struct btrfs_transaction *prev_trans = NULL; 1568 struct btrfs_transaction *prev_trans = NULL;
1569 DEFINE_WAIT(wait);
1570 int ret; 1569 int ret;
1571 int should_grow = 0;
1572 unsigned long now = get_seconds();
1573 1570
1574 ret = btrfs_run_ordered_operations(trans, root, 0); 1571 ret = btrfs_run_ordered_operations(trans, root, 0);
1575 if (ret) { 1572 if (ret) {
@@ -1660,28 +1657,14 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
1660 if (ret) 1657 if (ret)
1661 goto cleanup_transaction; 1658 goto cleanup_transaction;
1662 1659
1663 if (!btrfs_test_opt(root, SSD) && 1660 ret = btrfs_flush_all_pending_stuffs(trans, root);
1664 (now < cur_trans->start_time || now - cur_trans->start_time < 1)) 1661 if (ret)
1665 should_grow = 1; 1662 goto cleanup_transaction;
1666
1667 do {
1668 WARN_ON(cur_trans != trans->transaction);
1669
1670 ret = btrfs_flush_all_pending_stuffs(trans, root);
1671 if (ret)
1672 goto cleanup_transaction;
1673
1674 prepare_to_wait(&cur_trans->writer_wait, &wait,
1675 TASK_UNINTERRUPTIBLE);
1676
1677 if (extwriter_counter_read(cur_trans) > 0)
1678 schedule();
1679 else if (should_grow)
1680 schedule_timeout(1);
1681 1663
1682 finish_wait(&cur_trans->writer_wait, &wait); 1664 wait_event(cur_trans->writer_wait,
1683 } while (extwriter_counter_read(cur_trans) > 0); 1665 extwriter_counter_read(cur_trans) == 0);
1684 1666
1667 /* some pending stuffs might be added after the previous flush. */
1685 ret = btrfs_flush_all_pending_stuffs(trans, root); 1668 ret = btrfs_flush_all_pending_stuffs(trans, root);
1686 if (ret) 1669 if (ret)
1687 goto cleanup_transaction; 1670 goto cleanup_transaction;