From fefd6fa29426e8f9c86cef09c5bbf3b9782aa1d2 Mon Sep 17 00:00:00 2001 From: Miao Xie Date: Mon, 28 Jan 2013 12:36:22 +0000 Subject: [PATCH] --- yaml --- r: 349603 b: refs/heads/master c: 843fcf35733164076a77ad833c72c32da8228ad0 h: refs/heads/master i: 349601: b3139566a2d85e96a198ab8313b20f2b3e5f8efd 349599: 37ba11399c6a415cb94800bb807a3603fa2519e7 v: v3 --- [refs] | 2 +- trunk/fs/btrfs/transaction.c | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index e3ff9e471a75..897f8ea1762e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0a3404dcff29a7589e8d6ce8c36f97c5411f85b4 +refs/heads/master: 843fcf35733164076a77ad833c72c32da8228ad0 diff --git a/trunk/fs/btrfs/transaction.c b/trunk/fs/btrfs/transaction.c index f15494699f3b..fc03aa60b684 100644 --- a/trunk/fs/btrfs/transaction.c +++ b/trunk/fs/btrfs/transaction.c @@ -333,12 +333,14 @@ start_transaction(struct btrfs_root *root, u64 num_items, int type, &root->fs_info->trans_block_rsv, num_bytes, flush); if (ret) - return ERR_PTR(ret); + goto reserve_fail; } again: h = kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS); - if (!h) - return ERR_PTR(-ENOMEM); + if (!h) { + ret = -ENOMEM; + goto alloc_fail; + } /* * If we are JOIN_NOLOCK we're already committing a transaction and @@ -365,11 +367,7 @@ start_transaction(struct btrfs_root *root, u64 num_items, int type, if (ret < 0) { /* We must get the transaction if we are JOIN_NOLOCK. */ BUG_ON(type == TRANS_JOIN_NOLOCK); - - if (type < TRANS_JOIN_NOLOCK) - sb_end_intwrite(root->fs_info->sb); - kmem_cache_free(btrfs_trans_handle_cachep, h); - return ERR_PTR(ret); + goto join_fail; } cur_trans = root->fs_info->running_transaction; @@ -410,6 +408,19 @@ start_transaction(struct btrfs_root *root, u64 num_items, int type, if (!current->journal_info && type != TRANS_USERSPACE) current->journal_info = h; return h; + +join_fail: + if (type < TRANS_JOIN_NOLOCK) + sb_end_intwrite(root->fs_info->sb); + kmem_cache_free(btrfs_trans_handle_cachep, h); +alloc_fail: + if (num_bytes) + btrfs_block_rsv_release(root, &root->fs_info->trans_block_rsv, + num_bytes); +reserve_fail: + if (qgroup_reserved) + btrfs_qgroup_free(root, qgroup_reserved); + return ERR_PTR(ret); } struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,