Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 139465
b: refs/heads/master
c: 89573b9
h: refs/heads/master
i:
  139463: 3b1c193
v: v3
  • Loading branch information
Chris Mason committed Mar 24, 2009
1 parent 2c6b6d0 commit 68ff7d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 66d7e85ea7c3628189d19b265495358f756cb463
refs/heads/master: 89573b9c516b24af8a3b9958dd5afca8fa874e3d
13 changes: 10 additions & 3 deletions trunk/fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
struct extent_io_tree *pinned_copy;
DEFINE_WAIT(wait);
int ret;
int should_grow = 0;
unsigned long now = get_seconds();

/* make a pass through all the delayed refs we have so far
* any runnings procs may add more while we are here
Expand Down Expand Up @@ -1029,6 +1031,9 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
}
}

if (now < cur_trans->start_time || now - cur_trans->start_time < 1)
should_grow = 1;

do {
int snap_pending = 0;
joined = cur_trans->num_joined;
Expand All @@ -1041,7 +1046,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,

if (cur_trans->num_writers > 1)
timeout = MAX_SCHEDULE_TIMEOUT;
else
else if (should_grow)
timeout = 1;

mutex_unlock(&root->fs_info->trans_mutex);
Expand All @@ -1051,12 +1056,14 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
BUG_ON(ret);
}

schedule_timeout(timeout);
smp_mb();
if (cur_trans->num_writers > 1 || should_grow)
schedule_timeout(timeout);

mutex_lock(&root->fs_info->trans_mutex);
finish_wait(&cur_trans->writer_wait, &wait);
} while (cur_trans->num_writers > 1 ||
(cur_trans->num_joined != joined));
(should_grow && cur_trans->num_joined != joined));

ret = create_pending_snapshots(trans, root->fs_info);
BUG_ON(ret);
Expand Down

0 comments on commit 68ff7d1

Please sign in to comment.