diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/transaction.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 01c9620bb001..9c8f158dd2db 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -972,6 +972,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
972 | struct extent_io_tree *pinned_copy; | 972 | struct extent_io_tree *pinned_copy; |
973 | DEFINE_WAIT(wait); | 973 | DEFINE_WAIT(wait); |
974 | int ret; | 974 | int ret; |
975 | int should_grow = 0; | ||
976 | unsigned long now = get_seconds(); | ||
975 | 977 | ||
976 | /* make a pass through all the delayed refs we have so far | 978 | /* make a pass through all the delayed refs we have so far |
977 | * any runnings procs may add more while we are here | 979 | * any runnings procs may add more while we are here |
@@ -1029,6 +1031,9 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
1029 | } | 1031 | } |
1030 | } | 1032 | } |
1031 | 1033 | ||
1034 | if (now < cur_trans->start_time || now - cur_trans->start_time < 1) | ||
1035 | should_grow = 1; | ||
1036 | |||
1032 | do { | 1037 | do { |
1033 | int snap_pending = 0; | 1038 | int snap_pending = 0; |
1034 | joined = cur_trans->num_joined; | 1039 | joined = cur_trans->num_joined; |
@@ -1041,7 +1046,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
1041 | 1046 | ||
1042 | if (cur_trans->num_writers > 1) | 1047 | if (cur_trans->num_writers > 1) |
1043 | timeout = MAX_SCHEDULE_TIMEOUT; | 1048 | timeout = MAX_SCHEDULE_TIMEOUT; |
1044 | else | 1049 | else if (should_grow) |
1045 | timeout = 1; | 1050 | timeout = 1; |
1046 | 1051 | ||
1047 | mutex_unlock(&root->fs_info->trans_mutex); | 1052 | mutex_unlock(&root->fs_info->trans_mutex); |
@@ -1051,12 +1056,14 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
1051 | BUG_ON(ret); | 1056 | BUG_ON(ret); |
1052 | } | 1057 | } |
1053 | 1058 | ||
1054 | schedule_timeout(timeout); | 1059 | smp_mb(); |
1060 | if (cur_trans->num_writers > 1 || should_grow) | ||
1061 | schedule_timeout(timeout); | ||
1055 | 1062 | ||
1056 | mutex_lock(&root->fs_info->trans_mutex); | 1063 | mutex_lock(&root->fs_info->trans_mutex); |
1057 | finish_wait(&cur_trans->writer_wait, &wait); | 1064 | finish_wait(&cur_trans->writer_wait, &wait); |
1058 | } while (cur_trans->num_writers > 1 || | 1065 | } while (cur_trans->num_writers > 1 || |
1059 | (cur_trans->num_joined != joined)); | 1066 | (should_grow && cur_trans->num_joined != joined)); |
1060 | 1067 | ||
1061 | ret = create_pending_snapshots(trans, root->fs_info); | 1068 | ret = create_pending_snapshots(trans, root->fs_info); |
1062 | BUG_ON(ret); | 1069 | BUG_ON(ret); |