提交 581227d0 编写于 作者: M Miao Xie 提交者: Josef Bacik

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: NMiao Xie <miaox@cn.fujitsu.com>
Signed-off-by: NJosef Bacik <jbacik@fusionio.com>
上级 3f1e3fa6
...@@ -1566,10 +1566,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -1566,10 +1566,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
{ {
struct btrfs_transaction *cur_trans = trans->transaction; struct btrfs_transaction *cur_trans = trans->transaction;
struct btrfs_transaction *prev_trans = NULL; struct btrfs_transaction *prev_trans = NULL;
DEFINE_WAIT(wait);
int ret; int ret;
int should_grow = 0;
unsigned long now = get_seconds();
ret = btrfs_run_ordered_operations(trans, root, 0); ret = btrfs_run_ordered_operations(trans, root, 0);
if (ret) { if (ret) {
...@@ -1660,28 +1657,14 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -1660,28 +1657,14 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
if (ret) if (ret)
goto cleanup_transaction; goto cleanup_transaction;
if (!btrfs_test_opt(root, SSD) && ret = btrfs_flush_all_pending_stuffs(trans, root);
(now < cur_trans->start_time || now - cur_trans->start_time < 1)) if (ret)
should_grow = 1; goto cleanup_transaction;
do {
WARN_ON(cur_trans != trans->transaction);
ret = btrfs_flush_all_pending_stuffs(trans, root);
if (ret)
goto cleanup_transaction;
prepare_to_wait(&cur_trans->writer_wait, &wait,
TASK_UNINTERRUPTIBLE);
if (extwriter_counter_read(cur_trans) > 0)
schedule();
else if (should_grow)
schedule_timeout(1);
finish_wait(&cur_trans->writer_wait, &wait); wait_event(cur_trans->writer_wait,
} while (extwriter_counter_read(cur_trans) > 0); extwriter_counter_read(cur_trans) == 0);
/* some pending stuffs might be added after the previous flush. */
ret = btrfs_flush_all_pending_stuffs(trans, root); ret = btrfs_flush_all_pending_stuffs(trans, root);
if (ret) if (ret)
goto cleanup_transaction; goto cleanup_transaction;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册