aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 6217bb6d516a..cfe7f588ef05 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -676,6 +676,7 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans,
676 676
677 btrfs_free_log(trans, root); 677 btrfs_free_log(trans, root);
678 btrfs_update_reloc_root(trans, root); 678 btrfs_update_reloc_root(trans, root);
679 btrfs_orphan_commit_root(trans, root);
679 680
680 if (root->commit_root != root->node) { 681 if (root->commit_root != root->node) {
681 switch_commit_root(root); 682 switch_commit_root(root);
@@ -835,6 +836,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
835 struct extent_buffer *tmp; 836 struct extent_buffer *tmp;
836 struct extent_buffer *old; 837 struct extent_buffer *old;
837 int ret; 838 int ret;
839 int retries = 0;
840 u64 to_reserve = 0;
838 u64 index = 0; 841 u64 index = 0;
839 u64 objectid; 842 u64 objectid;
840 843
@@ -850,6 +853,17 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
850 goto fail; 853 goto fail;
851 } 854 }
852 855
856 btrfs_orphan_pre_snapshot(trans, pending, &to_reserve);
857
858 if (to_reserve > 0) {
859 ret = btrfs_block_rsv_add(trans, root, &pending->block_rsv,
860 to_reserve, &retries);
861 if (ret) {
862 pending->error = ret;
863 goto fail;
864 }
865 }
866
853 key.objectid = objectid; 867 key.objectid = objectid;
854 key.offset = (u64)-1; 868 key.offset = (u64)-1;
855 key.type = BTRFS_ROOT_ITEM_KEY; 869 key.type = BTRFS_ROOT_ITEM_KEY;
@@ -909,6 +923,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
909 key.offset = (u64)-1; 923 key.offset = (u64)-1;
910 pending->snap = btrfs_read_fs_root_no_name(root->fs_info, &key); 924 pending->snap = btrfs_read_fs_root_no_name(root->fs_info, &key);
911 BUG_ON(IS_ERR(pending->snap)); 925 BUG_ON(IS_ERR(pending->snap));
926
927 btrfs_orphan_post_snapshot(trans, pending);
912fail: 928fail:
913 kfree(new_root_item); 929 kfree(new_root_item);
914 btrfs_block_rsv_release(root, &pending->block_rsv, (u64)-1); 930 btrfs_block_rsv_release(root, &pending->block_rsv, (u64)-1);