diff options
-rw-r--r-- | fs/btrfs/inode.c | 19 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 29 | ||||
-rw-r--r-- | fs/btrfs/transaction.h | 2 |
3 files changed, 32 insertions, 18 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index aae55625aa59..9e9754adf7a4 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -3834,15 +3834,10 @@ void btrfs_evict_inode(struct inode *inode) | |||
3834 | btrfs_i_size_write(inode, 0); | 3834 | btrfs_i_size_write(inode, 0); |
3835 | 3835 | ||
3836 | /* | 3836 | /* |
3837 | * This is a bit simpler than btrfs_truncate since | 3837 | * This is a bit simpler than btrfs_truncate since we've already |
3838 | * | 3838 | * reserved our space for our orphan item in the unlink, so we just |
3839 | * 1) We've already reserved our space for our orphan item in the | 3839 | * need to reserve some slack space in case we add bytes and update |
3840 | * unlink. | 3840 | * inode item when doing the truncate. |
3841 | * 2) We're going to delete the inode item, so we don't need to update | ||
3842 | * it at all. | ||
3843 | * | ||
3844 | * So we just need to reserve some slack space in case we add bytes when | ||
3845 | * doing the truncate. | ||
3846 | */ | 3841 | */ |
3847 | while (1) { | 3842 | while (1) { |
3848 | ret = btrfs_block_rsv_refill_noflush(root, rsv, min_size); | 3843 | ret = btrfs_block_rsv_refill_noflush(root, rsv, min_size); |
@@ -3863,7 +3858,7 @@ void btrfs_evict_inode(struct inode *inode) | |||
3863 | goto no_delete; | 3858 | goto no_delete; |
3864 | } | 3859 | } |
3865 | 3860 | ||
3866 | trans = btrfs_start_transaction(root, 0); | 3861 | trans = btrfs_start_transaction_noflush(root, 1); |
3867 | if (IS_ERR(trans)) { | 3862 | if (IS_ERR(trans)) { |
3868 | btrfs_orphan_del(NULL, inode); | 3863 | btrfs_orphan_del(NULL, inode); |
3869 | btrfs_free_block_rsv(root, rsv); | 3864 | btrfs_free_block_rsv(root, rsv); |
@@ -3876,6 +3871,10 @@ void btrfs_evict_inode(struct inode *inode) | |||
3876 | if (ret != -ENOSPC) | 3871 | if (ret != -ENOSPC) |
3877 | break; | 3872 | break; |
3878 | 3873 | ||
3874 | trans->block_rsv = &root->fs_info->trans_block_rsv; | ||
3875 | ret = btrfs_update_inode(trans, root, inode); | ||
3876 | BUG_ON(ret); | ||
3877 | |||
3879 | nr = trans->blocks_used; | 3878 | nr = trans->blocks_used; |
3880 | btrfs_end_transaction(trans, root); | 3879 | btrfs_end_transaction(trans, root); |
3881 | trans = NULL; | 3880 | trans = NULL; |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index a86fc723aad9..f8ae448ebec4 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -290,7 +290,8 @@ static int may_wait_transaction(struct btrfs_root *root, int type) | |||
290 | } | 290 | } |
291 | 291 | ||
292 | static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root, | 292 | static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root, |
293 | u64 num_items, int type) | 293 | u64 num_items, int type, |
294 | int noflush) | ||
294 | { | 295 | { |
295 | struct btrfs_trans_handle *h; | 296 | struct btrfs_trans_handle *h; |
296 | struct btrfs_transaction *cur_trans; | 297 | struct btrfs_transaction *cur_trans; |
@@ -324,9 +325,14 @@ static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root, | |||
324 | } | 325 | } |
325 | 326 | ||
326 | num_bytes = btrfs_calc_trans_metadata_size(root, num_items); | 327 | num_bytes = btrfs_calc_trans_metadata_size(root, num_items); |
327 | ret = btrfs_block_rsv_add(root, | 328 | if (noflush) |
328 | &root->fs_info->trans_block_rsv, | 329 | ret = btrfs_block_rsv_add_noflush(root, |
329 | num_bytes); | 330 | &root->fs_info->trans_block_rsv, |
331 | num_bytes); | ||
332 | else | ||
333 | ret = btrfs_block_rsv_add(root, | ||
334 | &root->fs_info->trans_block_rsv, | ||
335 | num_bytes); | ||
330 | if (ret) | 336 | if (ret) |
331 | return ERR_PTR(ret); | 337 | return ERR_PTR(ret); |
332 | } | 338 | } |
@@ -393,21 +399,28 @@ got_it: | |||
393 | struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, | 399 | struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, |
394 | int num_items) | 400 | int num_items) |
395 | { | 401 | { |
396 | return start_transaction(root, num_items, TRANS_START); | 402 | return start_transaction(root, num_items, TRANS_START, 0); |
397 | } | 403 | } |
404 | |||
405 | struct btrfs_trans_handle *btrfs_start_transaction_noflush( | ||
406 | struct btrfs_root *root, int num_items) | ||
407 | { | ||
408 | return start_transaction(root, num_items, TRANS_START, 1); | ||
409 | } | ||
410 | |||
398 | struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) | 411 | struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root) |
399 | { | 412 | { |
400 | return start_transaction(root, 0, TRANS_JOIN); | 413 | return start_transaction(root, 0, TRANS_JOIN, 0); |
401 | } | 414 | } |
402 | 415 | ||
403 | struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root) | 416 | struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root) |
404 | { | 417 | { |
405 | return start_transaction(root, 0, TRANS_JOIN_NOLOCK); | 418 | return start_transaction(root, 0, TRANS_JOIN_NOLOCK, 0); |
406 | } | 419 | } |
407 | 420 | ||
408 | struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root) | 421 | struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root) |
409 | { | 422 | { |
410 | return start_transaction(root, 0, TRANS_USERSPACE); | 423 | return start_transaction(root, 0, TRANS_USERSPACE, 0); |
411 | } | 424 | } |
412 | 425 | ||
413 | /* wait for a transaction commit to be fully complete */ | 426 | /* wait for a transaction commit to be fully complete */ |
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index 1a138bfb8f13..1b054800eca3 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h | |||
@@ -97,6 +97,8 @@ int btrfs_end_transaction_nolock(struct btrfs_trans_handle *trans, | |||
97 | struct btrfs_root *root); | 97 | struct btrfs_root *root); |
98 | struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, | 98 | struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, |
99 | int num_items); | 99 | int num_items); |
100 | struct btrfs_trans_handle *btrfs_start_transaction_noflush( | ||
101 | struct btrfs_root *root, int num_items); | ||
100 | struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root); | 102 | struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root); |
101 | struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root); | 103 | struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root); |
102 | struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root); | 104 | struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root); |