diff options
| -rw-r--r-- | fs/btrfs/transaction.c | 4 | ||||
| -rw-r--r-- | fs/btrfs/transaction.h | 5 | ||||
| -rw-r--r-- | fs/btrfs/volumes.c | 2 |
3 files changed, 11 insertions, 0 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index e0faf803513a..038fcf6051e0 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
| @@ -220,6 +220,7 @@ loop: | |||
| 220 | * commit the transaction. | 220 | * commit the transaction. |
| 221 | */ | 221 | */ |
| 222 | atomic_set(&cur_trans->use_count, 2); | 222 | atomic_set(&cur_trans->use_count, 2); |
| 223 | cur_trans->have_free_bgs = 0; | ||
| 223 | cur_trans->start_time = get_seconds(); | 224 | cur_trans->start_time = get_seconds(); |
| 224 | 225 | ||
| 225 | cur_trans->delayed_refs.href_root = RB_ROOT; | 226 | cur_trans->delayed_refs.href_root = RB_ROOT; |
| @@ -2037,6 +2038,9 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
| 2037 | 2038 | ||
| 2038 | btrfs_finish_extent_commit(trans, root); | 2039 | btrfs_finish_extent_commit(trans, root); |
| 2039 | 2040 | ||
| 2041 | if (cur_trans->have_free_bgs) | ||
| 2042 | btrfs_clear_space_info_full(root->fs_info); | ||
| 2043 | |||
| 2040 | root->fs_info->last_trans_committed = cur_trans->transid; | 2044 | root->fs_info->last_trans_committed = cur_trans->transid; |
| 2041 | /* | 2045 | /* |
| 2042 | * We needn't acquire the lock here because there is no other task | 2046 | * We needn't acquire the lock here because there is no other task |
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index 3305451451ca..937050a2b68e 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h | |||
| @@ -47,6 +47,11 @@ struct btrfs_transaction { | |||
| 47 | atomic_t num_writers; | 47 | atomic_t num_writers; |
| 48 | atomic_t use_count; | 48 | atomic_t use_count; |
| 49 | 49 | ||
| 50 | /* | ||
| 51 | * true if there is free bgs operations in this transaction | ||
| 52 | */ | ||
| 53 | int have_free_bgs; | ||
| 54 | |||
| 50 | /* Be protected by fs_info->trans_lock when we want to change it. */ | 55 | /* Be protected by fs_info->trans_lock when we want to change it. */ |
| 51 | enum btrfs_trans_state state; | 56 | enum btrfs_trans_state state; |
| 52 | struct list_head list; | 57 | struct list_head list; |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 2c4cab2dbd1a..cd4d1315aaa9 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
| @@ -1310,6 +1310,8 @@ again: | |||
| 1310 | if (ret) { | 1310 | if (ret) { |
| 1311 | btrfs_error(root->fs_info, ret, | 1311 | btrfs_error(root->fs_info, ret, |
| 1312 | "Failed to remove dev extent item"); | 1312 | "Failed to remove dev extent item"); |
| 1313 | } else { | ||
| 1314 | trans->transaction->have_free_bgs = 1; | ||
| 1313 | } | 1315 | } |
| 1314 | out: | 1316 | out: |
| 1315 | btrfs_free_path(path); | 1317 | btrfs_free_path(path); |
