summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2016-06-10 18:19:25 -0400
committerDavid Sterba <dsterba@suse.com>2016-07-26 07:54:26 -0400
commit66642832f06a4351e23cea6cf254967c227f8224 (patch)
tree8ae0bc5a61945bdec42d6c7a929967c548031d5d
parent64b63580728ef19137d35363a1c28794b70ad416 (diff)
btrfs: btrfs_abort_transaction, drop root parameter
__btrfs_abort_transaction doesn't use its root parameter except to obtain an fs_info pointer. We can obtain that from trans->root->fs_info for now and from trans->fs_info in a later patch. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/ctree.c12
-rw-r--r--fs/btrfs/ctree.h8
-rw-r--r--fs/btrfs/delayed-inode.c2
-rw-r--r--fs/btrfs/extent-tree.c47
-rw-r--r--fs/btrfs/file-item.c2
-rw-r--r--fs/btrfs/file.c8
-rw-r--r--fs/btrfs/free-space-cache.c2
-rw-r--r--fs/btrfs/free-space-tree.c16
-rw-r--r--fs/btrfs/inode-map.c4
-rw-r--r--fs/btrfs/inode.c77
-rw-r--r--fs/btrfs/ioctl.c33
-rw-r--r--fs/btrfs/relocation.c4
-rw-r--r--fs/btrfs/root-tree.c10
-rw-r--r--fs/btrfs/super.c12
-rw-r--r--fs/btrfs/transaction.c30
-rw-r--r--fs/btrfs/tree-log.c14
-rw-r--r--fs/btrfs/volumes.c18
17 files changed, 147 insertions, 152 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index e926b9fdb64a..d1c56c94dd5a 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1153,14 +1153,14 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
1153 1153
1154 ret = update_ref_for_cow(trans, root, buf, cow, &last_ref); 1154 ret = update_ref_for_cow(trans, root, buf, cow, &last_ref);
1155 if (ret) { 1155 if (ret) {
1156 btrfs_abort_transaction(trans, root, ret); 1156 btrfs_abort_transaction(trans, ret);
1157 return ret; 1157 return ret;
1158 } 1158 }
1159 1159
1160 if (test_bit(BTRFS_ROOT_REF_COWS, &root->state)) { 1160 if (test_bit(BTRFS_ROOT_REF_COWS, &root->state)) {
1161 ret = btrfs_reloc_cow_block(trans, root, buf, cow); 1161 ret = btrfs_reloc_cow_block(trans, root, buf, cow);
1162 if (ret) { 1162 if (ret) {
1163 btrfs_abort_transaction(trans, root, ret); 1163 btrfs_abort_transaction(trans, ret);
1164 return ret; 1164 return ret;
1165 } 1165 }
1166 } 1166 }
@@ -1198,7 +1198,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
1198 if (last_ref) { 1198 if (last_ref) {
1199 ret = tree_mod_log_free_eb(root->fs_info, buf); 1199 ret = tree_mod_log_free_eb(root->fs_info, buf);
1200 if (ret) { 1200 if (ret) {
1201 btrfs_abort_transaction(trans, root, ret); 1201 btrfs_abort_transaction(trans, ret);
1202 return ret; 1202 return ret;
1203 } 1203 }
1204 } 1204 }
@@ -3255,7 +3255,7 @@ static int push_node_left(struct btrfs_trans_handle *trans,
3255 ret = tree_mod_log_eb_copy(root->fs_info, dst, src, dst_nritems, 0, 3255 ret = tree_mod_log_eb_copy(root->fs_info, dst, src, dst_nritems, 0,
3256 push_items); 3256 push_items);
3257 if (ret) { 3257 if (ret) {
3258 btrfs_abort_transaction(trans, root, ret); 3258 btrfs_abort_transaction(trans, ret);
3259 return ret; 3259 return ret;
3260 } 3260 }
3261 copy_extent_buffer(dst, src, 3261 copy_extent_buffer(dst, src,
@@ -3330,7 +3330,7 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
3330 ret = tree_mod_log_eb_copy(root->fs_info, dst, src, 0, 3330 ret = tree_mod_log_eb_copy(root->fs_info, dst, src, 0,
3331 src_nritems - push_items, push_items); 3331 src_nritems - push_items, push_items);
3332 if (ret) { 3332 if (ret) {
3333 btrfs_abort_transaction(trans, root, ret); 3333 btrfs_abort_transaction(trans, ret);
3334 return ret; 3334 return ret;
3335 } 3335 }
3336 copy_extent_buffer(dst, src, 3336 copy_extent_buffer(dst, src,
@@ -3534,7 +3534,7 @@ static noinline int split_node(struct btrfs_trans_handle *trans,
3534 ret = tree_mod_log_eb_copy(root->fs_info, split, c, 0, 3534 ret = tree_mod_log_eb_copy(root->fs_info, split, c, 0,
3535 mid, c_nritems - mid); 3535 mid, c_nritems - mid);
3536 if (ret) { 3536 if (ret) {
3537 btrfs_abort_transaction(trans, root, ret); 3537 btrfs_abort_transaction(trans, ret);
3538 return ret; 3538 return ret;
3539 } 3539 }
3540 copy_extent_buffer(split, c, 3540 copy_extent_buffer(split, c,
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 85e0b608b7c0..f66a0ba9a2a9 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3379,23 +3379,23 @@ const char *btrfs_decode_error(int errno);
3379 3379
3380__cold 3380__cold
3381void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, 3381void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
3382 struct btrfs_root *root, const char *function, 3382 const char *function,
3383 unsigned int line, int errno); 3383 unsigned int line, int errno);
3384 3384
3385/* 3385/*
3386 * Call btrfs_abort_transaction as early as possible when an error condition is 3386 * Call btrfs_abort_transaction as early as possible when an error condition is
3387 * detected, that way the exact line number is reported. 3387 * detected, that way the exact line number is reported.
3388 */ 3388 */
3389#define btrfs_abort_transaction(trans, root, errno) \ 3389#define btrfs_abort_transaction(trans, errno) \
3390do { \ 3390do { \
3391 /* Report first abort since mount */ \ 3391 /* Report first abort since mount */ \
3392 if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED, \ 3392 if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED, \
3393 &((root)->fs_info->fs_state))) { \ 3393 &((trans)->fs_info->fs_state))) { \
3394 WARN(1, KERN_DEBUG \ 3394 WARN(1, KERN_DEBUG \
3395 "BTRFS: Transaction aborted (error %d)\n", \ 3395 "BTRFS: Transaction aborted (error %d)\n", \
3396 (errno)); \ 3396 (errno)); \
3397 } \ 3397 } \
3398 __btrfs_abort_transaction((trans), (root), __func__, \ 3398 __btrfs_abort_transaction((trans), __func__, \
3399 __LINE__, (errno)); \ 3399 __LINE__, (errno)); \
3400} while (0) 3400} while (0)
3401 3401
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 9e2a907d9ddb..3eeb9cd8cfa5 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1170,7 +1170,7 @@ static int __btrfs_run_delayed_items(struct btrfs_trans_handle *trans,
1170 if (ret) { 1170 if (ret) {
1171 btrfs_release_delayed_node(curr_node); 1171 btrfs_release_delayed_node(curr_node);
1172 curr_node = NULL; 1172 curr_node = NULL;
1173 btrfs_abort_transaction(trans, root, ret); 1173 btrfs_abort_transaction(trans, ret);
1174 break; 1174 break;
1175 } 1175 }
1176 1176
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index c6c505e2478f..c2b81b0d3fe0 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2180,7 +2180,7 @@ static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
2180 path, bytenr, parent, root_objectid, 2180 path, bytenr, parent, root_objectid,
2181 owner, offset, refs_to_add); 2181 owner, offset, refs_to_add);
2182 if (ret) 2182 if (ret)
2183 btrfs_abort_transaction(trans, root, ret); 2183 btrfs_abort_transaction(trans, ret);
2184out: 2184out:
2185 btrfs_free_path(path); 2185 btrfs_free_path(path);
2186 return ret; 2186 return ret;
@@ -2971,7 +2971,7 @@ again:
2971 trans->can_flush_pending_bgs = false; 2971 trans->can_flush_pending_bgs = false;
2972 ret = __btrfs_run_delayed_refs(trans, root, count); 2972 ret = __btrfs_run_delayed_refs(trans, root, count);
2973 if (ret < 0) { 2973 if (ret < 0) {
2974 btrfs_abort_transaction(trans, root, ret); 2974 btrfs_abort_transaction(trans, ret);
2975 return ret; 2975 return ret;
2976 } 2976 }
2977 2977
@@ -3430,7 +3430,7 @@ again:
3430 * transaction, this only happens in really bad situations 3430 * transaction, this only happens in really bad situations
3431 * anyway. 3431 * anyway.
3432 */ 3432 */
3433 btrfs_abort_transaction(trans, root, ret); 3433 btrfs_abort_transaction(trans, ret);
3434 goto out_put; 3434 goto out_put;
3435 } 3435 }
3436 WARN_ON(ret); 3436 WARN_ON(ret);
@@ -3670,7 +3670,7 @@ again:
3670 } 3670 }
3671 spin_unlock(&cur_trans->dirty_bgs_lock); 3671 spin_unlock(&cur_trans->dirty_bgs_lock);
3672 } else if (ret) { 3672 } else if (ret) {
3673 btrfs_abort_transaction(trans, root, ret); 3673 btrfs_abort_transaction(trans, ret);
3674 } 3674 }
3675 } 3675 }
3676 3676
@@ -3816,7 +3816,7 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
3816 cache); 3816 cache);
3817 } 3817 }
3818 if (ret) 3818 if (ret)
3819 btrfs_abort_transaction(trans, root, ret); 3819 btrfs_abort_transaction(trans, ret);
3820 } 3820 }
3821 3821
3822 /* if its not on the io list, we need to put the block group */ 3822 /* if its not on the io list, we need to put the block group */
@@ -6881,7 +6881,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
6881 NULL, refs_to_drop, 6881 NULL, refs_to_drop,
6882 is_data, &last_ref); 6882 is_data, &last_ref);
6883 if (ret) { 6883 if (ret) {
6884 btrfs_abort_transaction(trans, extent_root, ret); 6884 btrfs_abort_transaction(trans, ret);
6885 goto out; 6885 goto out;
6886 } 6886 }
6887 btrfs_release_path(path); 6887 btrfs_release_path(path);
@@ -6930,7 +6930,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
6930 path->nodes[0]); 6930 path->nodes[0]);
6931 } 6931 }
6932 if (ret < 0) { 6932 if (ret < 0) {
6933 btrfs_abort_transaction(trans, extent_root, ret); 6933 btrfs_abort_transaction(trans, ret);
6934 goto out; 6934 goto out;
6935 } 6935 }
6936 extent_slot = path->slots[0]; 6936 extent_slot = path->slots[0];
@@ -6941,10 +6941,10 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
6941 "unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu", 6941 "unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu",
6942 bytenr, parent, root_objectid, owner_objectid, 6942 bytenr, parent, root_objectid, owner_objectid,
6943 owner_offset); 6943 owner_offset);
6944 btrfs_abort_transaction(trans, extent_root, ret); 6944 btrfs_abort_transaction(trans, ret);
6945 goto out; 6945 goto out;
6946 } else { 6946 } else {
6947 btrfs_abort_transaction(trans, extent_root, ret); 6947 btrfs_abort_transaction(trans, ret);
6948 goto out; 6948 goto out;
6949 } 6949 }
6950 6950
@@ -6956,7 +6956,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
6956 ret = convert_extent_item_v0(trans, extent_root, path, 6956 ret = convert_extent_item_v0(trans, extent_root, path,
6957 owner_objectid, 0); 6957 owner_objectid, 0);
6958 if (ret < 0) { 6958 if (ret < 0) {
6959 btrfs_abort_transaction(trans, extent_root, ret); 6959 btrfs_abort_transaction(trans, ret);
6960 goto out; 6960 goto out;
6961 } 6961 }
6962 6962
@@ -6975,7 +6975,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
6975 btrfs_print_leaf(extent_root, path->nodes[0]); 6975 btrfs_print_leaf(extent_root, path->nodes[0]);
6976 } 6976 }
6977 if (ret < 0) { 6977 if (ret < 0) {
6978 btrfs_abort_transaction(trans, extent_root, ret); 6978 btrfs_abort_transaction(trans, ret);
6979 goto out; 6979 goto out;
6980 } 6980 }
6981 6981
@@ -7000,7 +7000,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
7000 btrfs_err(info, "trying to drop %d refs but we only have %Lu " 7000 btrfs_err(info, "trying to drop %d refs but we only have %Lu "
7001 "for bytenr %Lu", refs_to_drop, refs, bytenr); 7001 "for bytenr %Lu", refs_to_drop, refs, bytenr);
7002 ret = -EINVAL; 7002 ret = -EINVAL;
7003 btrfs_abort_transaction(trans, extent_root, ret); 7003 btrfs_abort_transaction(trans, ret);
7004 goto out; 7004 goto out;
7005 } 7005 }
7006 refs -= refs_to_drop; 7006 refs -= refs_to_drop;
@@ -7023,7 +7023,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
7023 iref, refs_to_drop, 7023 iref, refs_to_drop,
7024 is_data, &last_ref); 7024 is_data, &last_ref);
7025 if (ret) { 7025 if (ret) {
7026 btrfs_abort_transaction(trans, extent_root, ret); 7026 btrfs_abort_transaction(trans, ret);
7027 goto out; 7027 goto out;
7028 } 7028 }
7029 } 7029 }
@@ -7046,7 +7046,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
7046 ret = btrfs_del_items(trans, extent_root, path, path->slots[0], 7046 ret = btrfs_del_items(trans, extent_root, path, path->slots[0],
7047 num_to_del); 7047 num_to_del);
7048 if (ret) { 7048 if (ret) {
7049 btrfs_abort_transaction(trans, extent_root, ret); 7049 btrfs_abort_transaction(trans, ret);
7050 goto out; 7050 goto out;
7051 } 7051 }
7052 btrfs_release_path(path); 7052 btrfs_release_path(path);
@@ -7054,7 +7054,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
7054 if (is_data) { 7054 if (is_data) {
7055 ret = btrfs_del_csums(trans, root, bytenr, num_bytes); 7055 ret = btrfs_del_csums(trans, root, bytenr, num_bytes);
7056 if (ret) { 7056 if (ret) {
7057 btrfs_abort_transaction(trans, extent_root, ret); 7057 btrfs_abort_transaction(trans, ret);
7058 goto out; 7058 goto out;
7059 } 7059 }
7060 } 7060 }
@@ -7062,13 +7062,13 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
7062 ret = add_to_free_space_tree(trans, root->fs_info, bytenr, 7062 ret = add_to_free_space_tree(trans, root->fs_info, bytenr,
7063 num_bytes); 7063 num_bytes);
7064 if (ret) { 7064 if (ret) {
7065 btrfs_abort_transaction(trans, extent_root, ret); 7065 btrfs_abort_transaction(trans, ret);
7066 goto out; 7066 goto out;
7067 } 7067 }
7068 7068
7069 ret = update_block_group(trans, root, bytenr, num_bytes, 0); 7069 ret = update_block_group(trans, root, bytenr, num_bytes, 0);
7070 if (ret) { 7070 if (ret) {
7071 btrfs_abort_transaction(trans, extent_root, ret); 7071 btrfs_abort_transaction(trans, ret);
7072 goto out; 7072 goto out;
7073 } 7073 }
7074 } 7074 }
@@ -7852,8 +7852,7 @@ loop:
7852 * can do more things. 7852 * can do more things.
7853 */ 7853 */
7854 if (ret < 0 && ret != -ENOSPC) 7854 if (ret < 0 && ret != -ENOSPC)
7855 btrfs_abort_transaction(trans, 7855 btrfs_abort_transaction(trans, ret);
7856 root, ret);
7857 else 7856 else
7858 ret = 0; 7857 ret = 0;
7859 if (!exist) 7858 if (!exist)
@@ -9329,7 +9328,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
9329 &root->root_key, 9328 &root->root_key,
9330 root_item); 9329 root_item);
9331 if (ret) { 9330 if (ret) {
9332 btrfs_abort_transaction(trans, tree_root, ret); 9331 btrfs_abort_transaction(trans, ret);
9333 err = ret; 9332 err = ret;
9334 goto out_end_trans; 9333 goto out_end_trans;
9335 } 9334 }
@@ -9356,7 +9355,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
9356 9355
9357 ret = btrfs_del_root(trans, tree_root, &root->root_key); 9356 ret = btrfs_del_root(trans, tree_root, &root->root_key);
9358 if (ret) { 9357 if (ret) {
9359 btrfs_abort_transaction(trans, tree_root, ret); 9358 btrfs_abort_transaction(trans, ret);
9360 goto out_end_trans; 9359 goto out_end_trans;
9361 } 9360 }
9362 9361
@@ -9364,7 +9363,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
9364 ret = btrfs_find_root(tree_root, &root->root_key, path, 9363 ret = btrfs_find_root(tree_root, &root->root_key, path,
9365 NULL, NULL); 9364 NULL, NULL);
9366 if (ret < 0) { 9365 if (ret < 0) {
9367 btrfs_abort_transaction(trans, tree_root, ret); 9366 btrfs_abort_transaction(trans, ret);
9368 err = ret; 9367 err = ret;
9369 goto out_end_trans; 9368 goto out_end_trans;
9370 } else if (ret > 0) { 9369 } else if (ret > 0) {
@@ -10324,11 +10323,11 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans,
10324 ret = btrfs_insert_item(trans, extent_root, &key, &item, 10323 ret = btrfs_insert_item(trans, extent_root, &key, &item,
10325 sizeof(item)); 10324 sizeof(item));
10326 if (ret) 10325 if (ret)
10327 btrfs_abort_transaction(trans, extent_root, ret); 10326 btrfs_abort_transaction(trans, ret);
10328 ret = btrfs_finish_chunk_alloc(trans, extent_root, 10327 ret = btrfs_finish_chunk_alloc(trans, extent_root,
10329 key.objectid, key.offset); 10328 key.objectid, key.offset);
10330 if (ret) 10329 if (ret)
10331 btrfs_abort_transaction(trans, extent_root, ret); 10330 btrfs_abort_transaction(trans, ret);
10332 add_block_group_free_space(trans, root->fs_info, block_group); 10331 add_block_group_free_space(trans, root->fs_info, block_group);
10333 /* already aborted the transaction if it failed. */ 10332 /* already aborted the transaction if it failed. */
10334next: 10333next:
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index cdbbf85a269b..2fc803da4680 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -698,7 +698,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
698 */ 698 */
699 ret = btrfs_split_item(trans, root, path, &key, offset); 699 ret = btrfs_split_item(trans, root, path, &key, offset);
700 if (ret && ret != -EAGAIN) { 700 if (ret && ret != -EAGAIN) {
701 btrfs_abort_transaction(trans, root, ret); 701 btrfs_abort_transaction(trans, ret);
702 goto out; 702 goto out;
703 } 703 }
704 704
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 48b94904a519..9404121fd5f7 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -950,7 +950,7 @@ delete_extent_item:
950 ret = btrfs_del_items(trans, root, path, del_slot, 950 ret = btrfs_del_items(trans, root, path, del_slot,
951 del_nr); 951 del_nr);
952 if (ret) { 952 if (ret) {
953 btrfs_abort_transaction(trans, root, ret); 953 btrfs_abort_transaction(trans, ret);
954 break; 954 break;
955 } 955 }
956 956
@@ -974,7 +974,7 @@ delete_extent_item:
974 path->slots[0] = del_slot; 974 path->slots[0] = del_slot;
975 ret = btrfs_del_items(trans, root, path, del_slot, del_nr); 975 ret = btrfs_del_items(trans, root, path, del_slot, del_nr);
976 if (ret) 976 if (ret)
977 btrfs_abort_transaction(trans, root, ret); 977 btrfs_abort_transaction(trans, ret);
978 } 978 }
979 979
980 leaf = path->nodes[0]; 980 leaf = path->nodes[0];
@@ -1190,7 +1190,7 @@ again:
1190 goto again; 1190 goto again;
1191 } 1191 }
1192 if (ret < 0) { 1192 if (ret < 0) {
1193 btrfs_abort_transaction(trans, root, ret); 1193 btrfs_abort_transaction(trans, ret);
1194 goto out; 1194 goto out;
1195 } 1195 }
1196 1196
@@ -1278,7 +1278,7 @@ again:
1278 1278
1279 ret = btrfs_del_items(trans, root, path, del_slot, del_nr); 1279 ret = btrfs_del_items(trans, root, path, del_slot, del_nr);
1280 if (ret < 0) { 1280 if (ret < 0) {
1281 btrfs_abort_transaction(trans, root, ret); 1281 btrfs_abort_transaction(trans, ret);
1282 goto out; 1282 goto out;
1283 } 1283 }
1284 } 1284 }
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index cee2049ef64e..d571bd2b697b 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -280,7 +280,7 @@ fail:
280 if (locked) 280 if (locked)
281 mutex_unlock(&trans->transaction->cache_write_mutex); 281 mutex_unlock(&trans->transaction->cache_write_mutex);
282 if (ret) 282 if (ret)
283 btrfs_abort_transaction(trans, root, ret); 283 btrfs_abort_transaction(trans, ret);
284 284
285 return ret; 285 return ret;
286} 286}
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index 53dbeaf6ce94..87e7e3d3e676 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -305,7 +305,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
305out: 305out:
306 kvfree(bitmap); 306 kvfree(bitmap);
307 if (ret) 307 if (ret)
308 btrfs_abort_transaction(trans, root, ret); 308 btrfs_abort_transaction(trans, ret);
309 return ret; 309 return ret;
310} 310}
311 311
@@ -454,7 +454,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
454out: 454out:
455 kvfree(bitmap); 455 kvfree(bitmap);
456 if (ret) 456 if (ret)
457 btrfs_abort_transaction(trans, root, ret); 457 btrfs_abort_transaction(trans, ret);
458 return ret; 458 return ret;
459} 459}
460 460
@@ -851,7 +851,7 @@ int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
851out: 851out:
852 btrfs_free_path(path); 852 btrfs_free_path(path);
853 if (ret) 853 if (ret)
854 btrfs_abort_transaction(trans, fs_info->free_space_root, ret); 854 btrfs_abort_transaction(trans, ret);
855 return ret; 855 return ret;
856} 856}
857 857
@@ -1047,7 +1047,7 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans,
1047out: 1047out:
1048 btrfs_free_path(path); 1048 btrfs_free_path(path);
1049 if (ret) 1049 if (ret)
1050 btrfs_abort_transaction(trans, fs_info->free_space_root, ret); 1050 btrfs_abort_transaction(trans, ret);
1051 return ret; 1051 return ret;
1052} 1052}
1053 1053
@@ -1193,7 +1193,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info)
1193 1193
1194abort: 1194abort:
1195 fs_info->creating_free_space_tree = 0; 1195 fs_info->creating_free_space_tree = 0;
1196 btrfs_abort_transaction(trans, tree_root, ret); 1196 btrfs_abort_transaction(trans, ret);
1197 btrfs_end_transaction(trans, tree_root); 1197 btrfs_end_transaction(trans, tree_root);
1198 return ret; 1198 return ret;
1199} 1199}
@@ -1280,7 +1280,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info)
1280 return 0; 1280 return 0;
1281 1281
1282abort: 1282abort:
1283 btrfs_abort_transaction(trans, tree_root, ret); 1283 btrfs_abort_transaction(trans, ret);
1284 btrfs_end_transaction(trans, tree_root); 1284 btrfs_end_transaction(trans, tree_root);
1285 return ret; 1285 return ret;
1286} 1286}
@@ -1333,7 +1333,7 @@ out:
1333 btrfs_free_path(path); 1333 btrfs_free_path(path);
1334 mutex_unlock(&block_group->free_space_lock); 1334 mutex_unlock(&block_group->free_space_lock);
1335 if (ret) 1335 if (ret)
1336 btrfs_abort_transaction(trans, fs_info->free_space_root, ret); 1336 btrfs_abort_transaction(trans, ret);
1337 return ret; 1337 return ret;
1338} 1338}
1339 1339
@@ -1410,7 +1410,7 @@ int remove_block_group_free_space(struct btrfs_trans_handle *trans,
1410out: 1410out:
1411 btrfs_free_path(path); 1411 btrfs_free_path(path);
1412 if (ret) 1412 if (ret)
1413 btrfs_abort_transaction(trans, root, ret); 1413 btrfs_abort_transaction(trans, ret);
1414 return ret; 1414 return ret;
1415} 1415}
1416 1416
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index e3ad8c197997..aa6fabaee72e 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -458,7 +458,7 @@ again:
458 BTRFS_I(inode)->generation = 0; 458 BTRFS_I(inode)->generation = 0;
459 ret = btrfs_update_inode(trans, root, inode); 459 ret = btrfs_update_inode(trans, root, inode);
460 if (ret) { 460 if (ret) {
461 btrfs_abort_transaction(trans, root, ret); 461 btrfs_abort_transaction(trans, ret);
462 goto out_put; 462 goto out_put;
463 } 463 }
464 464
@@ -466,7 +466,7 @@ again:
466 ret = btrfs_truncate_free_space_cache(root, trans, NULL, inode); 466 ret = btrfs_truncate_free_space_cache(root, trans, NULL, inode);
467 if (ret) { 467 if (ret) {
468 if (ret != -ENOSPC) 468 if (ret != -ENOSPC)
469 btrfs_abort_transaction(trans, root, ret); 469 btrfs_abort_transaction(trans, ret);
470 goto out_put; 470 goto out_put;
471 } 471 }
472 } 472 }
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3f0311bb4d34..72cfd15b1fa8 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -296,7 +296,7 @@ static noinline int cow_file_range_inline(struct btrfs_root *root,
296 start, aligned_end, NULL, 296 start, aligned_end, NULL,
297 1, 1, extent_item_size, &extent_inserted); 297 1, 1, extent_item_size, &extent_inserted);
298 if (ret) { 298 if (ret) {
299 btrfs_abort_transaction(trans, root, ret); 299 btrfs_abort_transaction(trans, ret);
300 goto out; 300 goto out;
301 } 301 }
302 302
@@ -307,7 +307,7 @@ static noinline int cow_file_range_inline(struct btrfs_root *root,
307 inline_len, compressed_size, 307 inline_len, compressed_size,
308 compress_type, compressed_pages); 308 compress_type, compressed_pages);
309 if (ret && ret != -ENOSPC) { 309 if (ret && ret != -ENOSPC) {
310 btrfs_abort_transaction(trans, root, ret); 310 btrfs_abort_transaction(trans, ret);
311 goto out; 311 goto out;
312 } else if (ret == -ENOSPC) { 312 } else if (ret == -ENOSPC) {
313 ret = 1; 313 ret = 1;
@@ -2603,7 +2603,7 @@ again:
2603 ret = btrfs_insert_empty_item(trans, root, path, &key, 2603 ret = btrfs_insert_empty_item(trans, root, path, &key,
2604 sizeof(*extent)); 2604 sizeof(*extent));
2605 if (ret) { 2605 if (ret) {
2606 btrfs_abort_transaction(trans, root, ret); 2606 btrfs_abort_transaction(trans, ret);
2607 goto out_free_path; 2607 goto out_free_path;
2608 } 2608 }
2609 2609
@@ -2630,7 +2630,7 @@ again:
2630 backref->root_id, backref->inum, 2630 backref->root_id, backref->inum,
2631 new->file_pos); /* start - extent_offset */ 2631 new->file_pos); /* start - extent_offset */
2632 if (ret) { 2632 if (ret) {
2633 btrfs_abort_transaction(trans, root, ret); 2633 btrfs_abort_transaction(trans, ret);
2634 goto out_free_path; 2634 goto out_free_path;
2635 } 2635 }
2636 2636
@@ -2899,7 +2899,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
2899 trans->block_rsv = &root->fs_info->delalloc_block_rsv; 2899 trans->block_rsv = &root->fs_info->delalloc_block_rsv;
2900 ret = btrfs_update_inode_fallback(trans, root, inode); 2900 ret = btrfs_update_inode_fallback(trans, root, inode);
2901 if (ret) /* -ENOMEM or corruption */ 2901 if (ret) /* -ENOMEM or corruption */
2902 btrfs_abort_transaction(trans, root, ret); 2902 btrfs_abort_transaction(trans, ret);
2903 goto out; 2903 goto out;
2904 } 2904 }
2905 2905
@@ -2959,7 +2959,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
2959 ordered_extent->file_offset, ordered_extent->len, 2959 ordered_extent->file_offset, ordered_extent->len,
2960 trans->transid); 2960 trans->transid);
2961 if (ret < 0) { 2961 if (ret < 0) {
2962 btrfs_abort_transaction(trans, root, ret); 2962 btrfs_abort_transaction(trans, ret);
2963 goto out_unlock; 2963 goto out_unlock;
2964 } 2964 }
2965 2965
@@ -2969,7 +2969,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
2969 btrfs_ordered_update_i_size(inode, 0, ordered_extent); 2969 btrfs_ordered_update_i_size(inode, 0, ordered_extent);
2970 ret = btrfs_update_inode_fallback(trans, root, inode); 2970 ret = btrfs_update_inode_fallback(trans, root, inode);
2971 if (ret) { /* -ENOMEM or corruption */ 2971 if (ret) { /* -ENOMEM or corruption */
2972 btrfs_abort_transaction(trans, root, ret); 2972 btrfs_abort_transaction(trans, ret);
2973 goto out_unlock; 2973 goto out_unlock;
2974 } 2974 }
2975 ret = 0; 2975 ret = 0;
@@ -3213,7 +3213,7 @@ void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans,
3213 ret = btrfs_del_orphan_item(trans, root->fs_info->tree_root, 3213 ret = btrfs_del_orphan_item(trans, root->fs_info->tree_root,
3214 root->root_key.objectid); 3214 root->root_key.objectid);
3215 if (ret) 3215 if (ret)
3216 btrfs_abort_transaction(trans, root, ret); 3216 btrfs_abort_transaction(trans, ret);
3217 else 3217 else
3218 clear_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, 3218 clear_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED,
3219 &root->state); 3219 &root->state);
@@ -3304,7 +3304,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode)
3304 if (ret != -EEXIST) { 3304 if (ret != -EEXIST) {
3305 clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, 3305 clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
3306 &BTRFS_I(inode)->runtime_flags); 3306 &BTRFS_I(inode)->runtime_flags);
3307 btrfs_abort_transaction(trans, root, ret); 3307 btrfs_abort_transaction(trans, ret);
3308 return ret; 3308 return ret;
3309 } 3309 }
3310 } 3310 }
@@ -3316,7 +3316,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode)
3316 ret = btrfs_insert_orphan_item(trans, root->fs_info->tree_root, 3316 ret = btrfs_insert_orphan_item(trans, root->fs_info->tree_root,
3317 root->root_key.objectid); 3317 root->root_key.objectid);
3318 if (ret && ret != -EEXIST) { 3318 if (ret && ret != -EEXIST) {
3319 btrfs_abort_transaction(trans, root, ret); 3319 btrfs_abort_transaction(trans, ret);
3320 return ret; 3320 return ret;
3321 } 3321 }
3322 } 3322 }
@@ -4015,20 +4015,20 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
4015 btrfs_info(root->fs_info, 4015 btrfs_info(root->fs_info,
4016 "failed to delete reference to %.*s, inode %llu parent %llu", 4016 "failed to delete reference to %.*s, inode %llu parent %llu",
4017 name_len, name, ino, dir_ino); 4017 name_len, name, ino, dir_ino);
4018 btrfs_abort_transaction(trans, root, ret); 4018 btrfs_abort_transaction(trans, ret);
4019 goto err; 4019 goto err;
4020 } 4020 }
4021skip_backref: 4021skip_backref:
4022 ret = btrfs_delete_delayed_dir_index(trans, root, dir, index); 4022 ret = btrfs_delete_delayed_dir_index(trans, root, dir, index);
4023 if (ret) { 4023 if (ret) {
4024 btrfs_abort_transaction(trans, root, ret); 4024 btrfs_abort_transaction(trans, ret);
4025 goto err; 4025 goto err;
4026 } 4026 }
4027 4027
4028 ret = btrfs_del_inode_ref_in_log(trans, root, name, name_len, 4028 ret = btrfs_del_inode_ref_in_log(trans, root, name, name_len,
4029 inode, dir_ino); 4029 inode, dir_ino);
4030 if (ret != 0 && ret != -ENOENT) { 4030 if (ret != 0 && ret != -ENOENT) {
4031 btrfs_abort_transaction(trans, root, ret); 4031 btrfs_abort_transaction(trans, ret);
4032 goto err; 4032 goto err;
4033 } 4033 }
4034 4034
@@ -4037,7 +4037,7 @@ skip_backref:
4037 if (ret == -ENOENT) 4037 if (ret == -ENOENT)
4038 ret = 0; 4038 ret = 0;
4039 else if (ret) 4039 else if (ret)
4040 btrfs_abort_transaction(trans, root, ret); 4040 btrfs_abort_transaction(trans, ret);
4041err: 4041err:
4042 btrfs_free_path(path); 4042 btrfs_free_path(path);
4043 if (ret) 4043 if (ret)
@@ -4151,7 +4151,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
4151 WARN_ON(key.type != BTRFS_ROOT_ITEM_KEY || key.objectid != objectid); 4151 WARN_ON(key.type != BTRFS_ROOT_ITEM_KEY || key.objectid != objectid);
4152 ret = btrfs_delete_one_dir_name(trans, root, path, di); 4152 ret = btrfs_delete_one_dir_name(trans, root, path, di);
4153 if (ret) { 4153 if (ret) {
4154 btrfs_abort_transaction(trans, root, ret); 4154 btrfs_abort_transaction(trans, ret);
4155 goto out; 4155 goto out;
4156 } 4156 }
4157 btrfs_release_path(path); 4157 btrfs_release_path(path);
@@ -4161,7 +4161,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
4161 dir_ino, &index, name, name_len); 4161 dir_ino, &index, name, name_len);
4162 if (ret < 0) { 4162 if (ret < 0) {
4163 if (ret != -ENOENT) { 4163 if (ret != -ENOENT) {
4164 btrfs_abort_transaction(trans, root, ret); 4164 btrfs_abort_transaction(trans, ret);
4165 goto out; 4165 goto out;
4166 } 4166 }
4167 di = btrfs_search_dir_index_item(root, path, dir_ino, 4167 di = btrfs_search_dir_index_item(root, path, dir_ino,
@@ -4171,7 +4171,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
4171 ret = -ENOENT; 4171 ret = -ENOENT;
4172 else 4172 else
4173 ret = PTR_ERR(di); 4173 ret = PTR_ERR(di);
4174 btrfs_abort_transaction(trans, root, ret); 4174 btrfs_abort_transaction(trans, ret);
4175 goto out; 4175 goto out;
4176 } 4176 }
4177 4177
@@ -4184,7 +4184,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
4184 4184
4185 ret = btrfs_delete_delayed_dir_index(trans, root, dir, index); 4185 ret = btrfs_delete_delayed_dir_index(trans, root, dir, index);
4186 if (ret) { 4186 if (ret) {
4187 btrfs_abort_transaction(trans, root, ret); 4187 btrfs_abort_transaction(trans, ret);
4188 goto out; 4188 goto out;
4189 } 4189 }
4190 4190
@@ -4193,7 +4193,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
4193 dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb); 4193 dir->i_mtime = dir->i_ctime = current_fs_time(dir->i_sb);
4194 ret = btrfs_update_inode_fallback(trans, root, dir); 4194 ret = btrfs_update_inode_fallback(trans, root, dir);
4195 if (ret) 4195 if (ret)
4196 btrfs_abort_transaction(trans, root, ret); 4196 btrfs_abort_transaction(trans, ret);
4197out: 4197out:
4198 btrfs_free_path(path); 4198 btrfs_free_path(path);
4199 return ret; 4199 return ret;
@@ -4514,7 +4514,6 @@ search_again:
4514 pending_del_nr); 4514 pending_del_nr);
4515 if (err) { 4515 if (err) {
4516 btrfs_abort_transaction(trans, 4516 btrfs_abort_transaction(trans,
4517 root,
4518 err); 4517 err);
4519 goto error; 4518 goto error;
4520 } 4519 }
@@ -4526,8 +4525,7 @@ search_again:
4526 item_end, 4525 item_end,
4527 new_size); 4526 new_size);
4528 if (err) { 4527 if (err) {
4529 btrfs_abort_transaction(trans, 4528 btrfs_abort_transaction(trans, err);
4530 root, err);
4531 goto error; 4529 goto error;
4532 } 4530 }
4533 } else if (test_bit(BTRFS_ROOT_REF_COWS, 4531 } else if (test_bit(BTRFS_ROOT_REF_COWS,
@@ -4591,8 +4589,7 @@ delete:
4591 pending_del_slot, 4589 pending_del_slot,
4592 pending_del_nr); 4590 pending_del_nr);
4593 if (ret) { 4591 if (ret) {
4594 btrfs_abort_transaction(trans, 4592 btrfs_abort_transaction(trans, ret);
4595 root, ret);
4596 goto error; 4593 goto error;
4597 } 4594 }
4598 pending_del_nr = 0; 4595 pending_del_nr = 0;
@@ -4625,7 +4622,7 @@ out:
4625 ret = btrfs_del_items(trans, root, path, pending_del_slot, 4622 ret = btrfs_del_items(trans, root, path, pending_del_slot,
4626 pending_del_nr); 4623 pending_del_nr);
4627 if (ret) 4624 if (ret)
4628 btrfs_abort_transaction(trans, root, ret); 4625 btrfs_abort_transaction(trans, ret);
4629 } 4626 }
4630error: 4627error:
4631 if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) 4628 if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID)
@@ -4794,7 +4791,7 @@ static int maybe_insert_hole(struct btrfs_root *root, struct inode *inode,
4794 4791
4795 ret = btrfs_drop_extents(trans, root, inode, offset, offset + len, 1); 4792 ret = btrfs_drop_extents(trans, root, inode, offset, offset + len, 1);
4796 if (ret) { 4793 if (ret) {
4797 btrfs_abort_transaction(trans, root, ret); 4794 btrfs_abort_transaction(trans, ret);
4798 btrfs_end_transaction(trans, root); 4795 btrfs_end_transaction(trans, root);
4799 return ret; 4796 return ret;
4800 } 4797 }
@@ -4802,7 +4799,7 @@ static int maybe_insert_hole(struct btrfs_root *root, struct inode *inode,
4802 ret = btrfs_insert_file_extent(trans, root, btrfs_ino(inode), offset, 4799 ret = btrfs_insert_file_extent(trans, root, btrfs_ino(inode), offset,
4803 0, 0, len, 0, len, 0, 0, 0); 4800 0, 0, len, 0, len, 0, 0, 0);
4804 if (ret) 4801 if (ret)
4805 btrfs_abort_transaction(trans, root, ret); 4802 btrfs_abort_transaction(trans, ret);
4806 else 4803 else
4807 btrfs_update_inode(trans, root, inode); 4804 btrfs_update_inode(trans, root, inode);
4808 btrfs_end_transaction(trans, root); 4805 btrfs_end_transaction(trans, root);
@@ -5029,7 +5026,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
5029 i_size_write(inode, BTRFS_I(inode)->disk_i_size); 5026 i_size_write(inode, BTRFS_I(inode)->disk_i_size);
5030 err = btrfs_orphan_del(trans, inode); 5027 err = btrfs_orphan_del(trans, inode);
5031 if (err) 5028 if (err)
5032 btrfs_abort_transaction(trans, root, err); 5029 btrfs_abort_transaction(trans, err);
5033 btrfs_end_transaction(trans, root); 5030 btrfs_end_transaction(trans, root);
5034 } 5031 }
5035 } 5032 }
@@ -6335,7 +6332,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
6335 if (ret == -EEXIST || ret == -EOVERFLOW) 6332 if (ret == -EEXIST || ret == -EOVERFLOW)
6336 goto fail_dir_item; 6333 goto fail_dir_item;
6337 else if (ret) { 6334 else if (ret) {
6338 btrfs_abort_transaction(trans, root, ret); 6335 btrfs_abort_transaction(trans, ret);
6339 return ret; 6336 return ret;
6340 } 6337 }
6341 6338
@@ -6346,7 +6343,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
6346 current_fs_time(parent_inode->i_sb); 6343 current_fs_time(parent_inode->i_sb);
6347 ret = btrfs_update_inode(trans, root, parent_inode); 6344 ret = btrfs_update_inode(trans, root, parent_inode);
6348 if (ret) 6345 if (ret)
6349 btrfs_abort_transaction(trans, root, ret); 6346 btrfs_abort_transaction(trans, ret);
6350 return ret; 6347 return ret;
6351 6348
6352fail_dir_item: 6349fail_dir_item:
@@ -9568,7 +9565,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
9568 ret = btrfs_update_inode(trans, root, old_inode); 9565 ret = btrfs_update_inode(trans, root, old_inode);
9569 } 9566 }
9570 if (ret) { 9567 if (ret) {
9571 btrfs_abort_transaction(trans, root, ret); 9568 btrfs_abort_transaction(trans, ret);
9572 goto out_fail; 9569 goto out_fail;
9573 } 9570 }
9574 9571
@@ -9588,7 +9585,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
9588 ret = btrfs_update_inode(trans, dest, new_inode); 9585 ret = btrfs_update_inode(trans, dest, new_inode);
9589 } 9586 }
9590 if (ret) { 9587 if (ret) {
9591 btrfs_abort_transaction(trans, root, ret); 9588 btrfs_abort_transaction(trans, ret);
9592 goto out_fail; 9589 goto out_fail;
9593 } 9590 }
9594 9591
@@ -9596,7 +9593,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
9596 new_dentry->d_name.name, 9593 new_dentry->d_name.name,
9597 new_dentry->d_name.len, 0, old_idx); 9594 new_dentry->d_name.len, 0, old_idx);
9598 if (ret) { 9595 if (ret) {
9599 btrfs_abort_transaction(trans, root, ret); 9596 btrfs_abort_transaction(trans, ret);
9600 goto out_fail; 9597 goto out_fail;
9601 } 9598 }
9602 9599
@@ -9604,7 +9601,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
9604 old_dentry->d_name.name, 9601 old_dentry->d_name.name,
9605 old_dentry->d_name.len, 0, new_idx); 9602 old_dentry->d_name.len, 0, new_idx);
9606 if (ret) { 9603 if (ret) {
9607 btrfs_abort_transaction(trans, root, ret); 9604 btrfs_abort_transaction(trans, ret);
9608 goto out_fail; 9605 goto out_fail;
9609 } 9606 }
9610 9607
@@ -9843,7 +9840,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
9843 ret = btrfs_update_inode(trans, root, old_inode); 9840 ret = btrfs_update_inode(trans, root, old_inode);
9844 } 9841 }
9845 if (ret) { 9842 if (ret) {
9846 btrfs_abort_transaction(trans, root, ret); 9843 btrfs_abort_transaction(trans, ret);
9847 goto out_fail; 9844 goto out_fail;
9848 } 9845 }
9849 9846
@@ -9867,7 +9864,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
9867 if (!ret && new_inode->i_nlink == 0) 9864 if (!ret && new_inode->i_nlink == 0)
9868 ret = btrfs_orphan_add(trans, d_inode(new_dentry)); 9865 ret = btrfs_orphan_add(trans, d_inode(new_dentry));
9869 if (ret) { 9866 if (ret) {
9870 btrfs_abort_transaction(trans, root, ret); 9867 btrfs_abort_transaction(trans, ret);
9871 goto out_fail; 9868 goto out_fail;
9872 } 9869 }
9873 } 9870 }
@@ -9876,7 +9873,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
9876 new_dentry->d_name.name, 9873 new_dentry->d_name.name,
9877 new_dentry->d_name.len, 0, index); 9874 new_dentry->d_name.len, 0, index);
9878 if (ret) { 9875 if (ret) {
9879 btrfs_abort_transaction(trans, root, ret); 9876 btrfs_abort_transaction(trans, ret);
9880 goto out_fail; 9877 goto out_fail;
9881 } 9878 }
9882 9879
@@ -9896,7 +9893,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
9896 old_dentry); 9893 old_dentry);
9897 9894
9898 if (ret) { 9895 if (ret) {
9899 btrfs_abort_transaction(trans, root, ret); 9896 btrfs_abort_transaction(trans, ret);
9900 goto out_fail; 9897 goto out_fail;
9901 } 9898 }
9902 } 9899 }
@@ -10322,7 +10319,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
10322 if (ret) { 10319 if (ret) {
10323 btrfs_free_reserved_extent(root, ins.objectid, 10320 btrfs_free_reserved_extent(root, ins.objectid,
10324 ins.offset, 0); 10321 ins.offset, 0);
10325 btrfs_abort_transaction(trans, root, ret); 10322 btrfs_abort_transaction(trans, ret);
10326 if (own_trans) 10323 if (own_trans)
10327 btrfs_end_transaction(trans, root); 10324 btrfs_end_transaction(trans, root);
10328 break; 10325 break;
@@ -10382,7 +10379,7 @@ next:
10382 ret = btrfs_update_inode(trans, root, inode); 10379 ret = btrfs_update_inode(trans, root, inode);
10383 10380
10384 if (ret) { 10381 if (ret) {
10385 btrfs_abort_transaction(trans, root, ret); 10382 btrfs_abort_transaction(trans, ret);
10386 if (own_trans) 10383 if (own_trans)
10387 btrfs_end_transaction(trans, root); 10384 btrfs_end_transaction(trans, root);
10388 break; 10385 break;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 81413e600d9b..14ed1e9e6bc8 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -561,7 +561,7 @@ static noinline int create_subvol(struct inode *dir,
561 new_root = btrfs_read_fs_root_no_name(root->fs_info, &key); 561 new_root = btrfs_read_fs_root_no_name(root->fs_info, &key);
562 if (IS_ERR(new_root)) { 562 if (IS_ERR(new_root)) {
563 ret = PTR_ERR(new_root); 563 ret = PTR_ERR(new_root);
564 btrfs_abort_transaction(trans, root, ret); 564 btrfs_abort_transaction(trans, ret);
565 goto fail; 565 goto fail;
566 } 566 }
567 567
@@ -570,7 +570,7 @@ static noinline int create_subvol(struct inode *dir,
570 ret = btrfs_create_subvol_root(trans, new_root, root, new_dirid); 570 ret = btrfs_create_subvol_root(trans, new_root, root, new_dirid);
571 if (ret) { 571 if (ret) {
572 /* We potentially lose an unused inode item here */ 572 /* We potentially lose an unused inode item here */
573 btrfs_abort_transaction(trans, root, ret); 573 btrfs_abort_transaction(trans, ret);
574 goto fail; 574 goto fail;
575 } 575 }
576 576
@@ -583,7 +583,7 @@ static noinline int create_subvol(struct inode *dir,
583 */ 583 */
584 ret = btrfs_set_inode_index(dir, &index); 584 ret = btrfs_set_inode_index(dir, &index);
585 if (ret) { 585 if (ret) {
586 btrfs_abort_transaction(trans, root, ret); 586 btrfs_abort_transaction(trans, ret);
587 goto fail; 587 goto fail;
588 } 588 }
589 589
@@ -591,7 +591,7 @@ static noinline int create_subvol(struct inode *dir,
591 name, namelen, dir, &key, 591 name, namelen, dir, &key,
592 BTRFS_FT_DIR, index); 592 BTRFS_FT_DIR, index);
593 if (ret) { 593 if (ret) {
594 btrfs_abort_transaction(trans, root, ret); 594 btrfs_abort_transaction(trans, ret);
595 goto fail; 595 goto fail;
596 } 596 }
597 597
@@ -608,7 +608,7 @@ static noinline int create_subvol(struct inode *dir,
608 root_item->uuid, BTRFS_UUID_KEY_SUBVOL, 608 root_item->uuid, BTRFS_UUID_KEY_SUBVOL,
609 objectid); 609 objectid);
610 if (ret) 610 if (ret)
611 btrfs_abort_transaction(trans, root, ret); 611 btrfs_abort_transaction(trans, ret);
612 612
613fail: 613fail:
614 kfree(root_item); 614 kfree(root_item);
@@ -2488,7 +2488,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
2488 dentry->d_name.len); 2488 dentry->d_name.len);
2489 if (ret) { 2489 if (ret) {
2490 err = ret; 2490 err = ret;
2491 btrfs_abort_transaction(trans, root, ret); 2491 btrfs_abort_transaction(trans, ret);
2492 goto out_end_trans; 2492 goto out_end_trans;
2493 } 2493 }
2494 2494
@@ -2504,7 +2504,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
2504 root->fs_info->tree_root, 2504 root->fs_info->tree_root,
2505 dest->root_key.objectid); 2505 dest->root_key.objectid);
2506 if (ret) { 2506 if (ret) {
2507 btrfs_abort_transaction(trans, root, ret); 2507 btrfs_abort_transaction(trans, ret);
2508 err = ret; 2508 err = ret;
2509 goto out_end_trans; 2509 goto out_end_trans;
2510 } 2510 }
@@ -2514,7 +2514,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
2514 dest->root_item.uuid, BTRFS_UUID_KEY_SUBVOL, 2514 dest->root_item.uuid, BTRFS_UUID_KEY_SUBVOL,
2515 dest->root_key.objectid); 2515 dest->root_key.objectid);
2516 if (ret && ret != -ENOENT) { 2516 if (ret && ret != -ENOENT) {
2517 btrfs_abort_transaction(trans, root, ret); 2517 btrfs_abort_transaction(trans, ret);
2518 err = ret; 2518 err = ret;
2519 goto out_end_trans; 2519 goto out_end_trans;
2520 } 2520 }
@@ -2524,7 +2524,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
2524 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 2524 BTRFS_UUID_KEY_RECEIVED_SUBVOL,
2525 dest->root_key.objectid); 2525 dest->root_key.objectid);
2526 if (ret && ret != -ENOENT) { 2526 if (ret && ret != -ENOENT) {
2527 btrfs_abort_transaction(trans, root, ret); 2527 btrfs_abort_transaction(trans, ret);
2528 err = ret; 2528 err = ret;
2529 goto out_end_trans; 2529 goto out_end_trans;
2530 } 2530 }
@@ -3291,7 +3291,7 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
3291 3291
3292 ret = btrfs_update_inode(trans, root, inode); 3292 ret = btrfs_update_inode(trans, root, inode);
3293 if (ret) { 3293 if (ret) {
3294 btrfs_abort_transaction(trans, root, ret); 3294 btrfs_abort_transaction(trans, ret);
3295 btrfs_end_transaction(trans, root); 3295 btrfs_end_transaction(trans, root);
3296 goto out; 3296 goto out;
3297 } 3297 }
@@ -3693,7 +3693,7 @@ process_slot:
3693 if (ret) { 3693 if (ret) {
3694 if (ret != -EOPNOTSUPP) 3694 if (ret != -EOPNOTSUPP)
3695 btrfs_abort_transaction(trans, 3695 btrfs_abort_transaction(trans,
3696 root, ret); 3696 ret);
3697 btrfs_end_transaction(trans, root); 3697 btrfs_end_transaction(trans, root);
3698 goto out; 3698 goto out;
3699 } 3699 }
@@ -3701,8 +3701,7 @@ process_slot:
3701 ret = btrfs_insert_empty_item(trans, root, path, 3701 ret = btrfs_insert_empty_item(trans, root, path,
3702 &new_key, size); 3702 &new_key, size);
3703 if (ret) { 3703 if (ret) {
3704 btrfs_abort_transaction(trans, root, 3704 btrfs_abort_transaction(trans, ret);
3705 ret);
3706 btrfs_end_transaction(trans, root); 3705 btrfs_end_transaction(trans, root);
3707 goto out; 3706 goto out;
3708 } 3707 }
@@ -3734,7 +3733,6 @@ process_slot:
3734 new_key.offset - datao); 3733 new_key.offset - datao);
3735 if (ret) { 3734 if (ret) {
3736 btrfs_abort_transaction(trans, 3735 btrfs_abort_transaction(trans,
3737 root,
3738 ret); 3736 ret);
3739 btrfs_end_transaction(trans, 3737 btrfs_end_transaction(trans,
3740 root); 3738 root);
@@ -3771,7 +3769,6 @@ process_slot:
3771 if (ret) { 3769 if (ret) {
3772 if (ret != -EOPNOTSUPP) 3770 if (ret != -EOPNOTSUPP)
3773 btrfs_abort_transaction(trans, 3771 btrfs_abort_transaction(trans,
3774 root,
3775 ret); 3772 ret);
3776 btrfs_end_transaction(trans, root); 3773 btrfs_end_transaction(trans, root);
3777 goto out; 3774 goto out;
@@ -3827,7 +3824,7 @@ process_slot:
3827 last_dest_end, destoff + len, 1); 3824 last_dest_end, destoff + len, 1);
3828 if (ret) { 3825 if (ret) {
3829 if (ret != -EOPNOTSUPP) 3826 if (ret != -EOPNOTSUPP)
3830 btrfs_abort_transaction(trans, root, ret); 3827 btrfs_abort_transaction(trans, ret);
3831 btrfs_end_transaction(trans, root); 3828 btrfs_end_transaction(trans, root);
3832 goto out; 3829 goto out;
3833 } 3830 }
@@ -5163,13 +5160,13 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
5163 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 5160 BTRFS_UUID_KEY_RECEIVED_SUBVOL,
5164 root->root_key.objectid); 5161 root->root_key.objectid);
5165 if (ret < 0 && ret != -EEXIST) { 5162 if (ret < 0 && ret != -EEXIST) {
5166 btrfs_abort_transaction(trans, root, ret); 5163 btrfs_abort_transaction(trans, ret);
5167 goto out; 5164 goto out;
5168 } 5165 }
5169 } 5166 }
5170 ret = btrfs_commit_transaction(trans, root); 5167 ret = btrfs_commit_transaction(trans, root);
5171 if (ret < 0) { 5168 if (ret < 0) {
5172 btrfs_abort_transaction(trans, root, ret); 5169 btrfs_abort_transaction(trans, ret);
5173 goto out; 5170 goto out;
5174 } 5171 }
5175 5172
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 97cafe7291b8..b26a5aea41b4 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1723,7 +1723,7 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
1723 btrfs_header_owner(leaf), 1723 btrfs_header_owner(leaf),
1724 key.objectid, key.offset); 1724 key.objectid, key.offset);
1725 if (ret) { 1725 if (ret) {
1726 btrfs_abort_transaction(trans, root, ret); 1726 btrfs_abort_transaction(trans, ret);
1727 break; 1727 break;
1728 } 1728 }
1729 1729
@@ -1731,7 +1731,7 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
1731 parent, btrfs_header_owner(leaf), 1731 parent, btrfs_header_owner(leaf),
1732 key.objectid, key.offset); 1732 key.objectid, key.offset);
1733 if (ret) { 1733 if (ret) {
1734 btrfs_abort_transaction(trans, root, ret); 1734 btrfs_abort_transaction(trans, ret);
1735 break; 1735 break;
1736 } 1736 }
1737 } 1737 }
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index f1c30861d062..7fd7e1830cfe 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -150,7 +150,7 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
150 150
151 ret = btrfs_search_slot(trans, root, key, path, 0, 1); 151 ret = btrfs_search_slot(trans, root, key, path, 0, 1);
152 if (ret < 0) { 152 if (ret < 0) {
153 btrfs_abort_transaction(trans, root, ret); 153 btrfs_abort_transaction(trans, ret);
154 goto out; 154 goto out;
155 } 155 }
156 156
@@ -176,20 +176,20 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
176 ret = btrfs_search_slot(trans, root, key, path, 176 ret = btrfs_search_slot(trans, root, key, path,
177 -1, 1); 177 -1, 1);
178 if (ret < 0) { 178 if (ret < 0) {
179 btrfs_abort_transaction(trans, root, ret); 179 btrfs_abort_transaction(trans, ret);
180 goto out; 180 goto out;
181 } 181 }
182 182
183 ret = btrfs_del_item(trans, root, path); 183 ret = btrfs_del_item(trans, root, path);
184 if (ret < 0) { 184 if (ret < 0) {
185 btrfs_abort_transaction(trans, root, ret); 185 btrfs_abort_transaction(trans, ret);
186 goto out; 186 goto out;
187 } 187 }
188 btrfs_release_path(path); 188 btrfs_release_path(path);
189 ret = btrfs_insert_empty_item(trans, root, path, 189 ret = btrfs_insert_empty_item(trans, root, path,
190 key, sizeof(*item)); 190 key, sizeof(*item));
191 if (ret < 0) { 191 if (ret < 0) {
192 btrfs_abort_transaction(trans, root, ret); 192 btrfs_abort_transaction(trans, ret);
193 goto out; 193 goto out;
194 } 194 }
195 l = path->nodes[0]; 195 l = path->nodes[0];
@@ -448,7 +448,7 @@ again:
448 ret = btrfs_insert_empty_item(trans, tree_root, path, &key, 448 ret = btrfs_insert_empty_item(trans, tree_root, path, &key,
449 sizeof(*ref) + name_len); 449 sizeof(*ref) + name_len);
450 if (ret) { 450 if (ret) {
451 btrfs_abort_transaction(trans, tree_root, ret); 451 btrfs_abort_transaction(trans, ret);
452 btrfs_free_path(path); 452 btrfs_free_path(path);
453 return ret; 453 return ret;
454 } 454 }
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 959823a12c42..864ce334f696 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -251,9 +251,11 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
251 */ 251 */
252__cold 252__cold
253void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, 253void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
254 struct btrfs_root *root, const char *function, 254 const char *function,
255 unsigned int line, int errno) 255 unsigned int line, int errno)
256{ 256{
257 struct btrfs_fs_info *fs_info = trans->fs_info;
258
257 trans->aborted = errno; 259 trans->aborted = errno;
258 /* Nothing used. The other threads that have joined this 260 /* Nothing used. The other threads that have joined this
259 * transaction may be able to continue. */ 261 * transaction may be able to continue. */
@@ -261,16 +263,16 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
261 const char *errstr; 263 const char *errstr;
262 264
263 errstr = btrfs_decode_error(errno); 265 errstr = btrfs_decode_error(errno);
264 btrfs_warn(root->fs_info, 266 btrfs_warn(fs_info,
265 "%s:%d: Aborting unused transaction(%s).", 267 "%s:%d: Aborting unused transaction(%s).",
266 function, line, errstr); 268 function, line, errstr);
267 return; 269 return;
268 } 270 }
269 ACCESS_ONCE(trans->transaction->aborted) = errno; 271 ACCESS_ONCE(trans->transaction->aborted) = errno;
270 /* Wake up anybody who may be waiting on this transaction */ 272 /* Wake up anybody who may be waiting on this transaction */
271 wake_up(&root->fs_info->transaction_wait); 273 wake_up(&fs_info->transaction_wait);
272 wake_up(&root->fs_info->transaction_blocked_wait); 274 wake_up(&fs_info->transaction_blocked_wait);
273 __btrfs_handle_fs_error(root->fs_info, function, line, errno, NULL); 275 __btrfs_handle_fs_error(fs_info, function, line, errno, NULL);
274} 276}
275/* 277/*
276 * __btrfs_panic decodes unexpected, fatal errors from the caller, 278 * __btrfs_panic decodes unexpected, fatal errors from the caller,
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 41e14c632c3f..9cca0a721961 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1492,7 +1492,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1492 goto dir_item_existed; 1492 goto dir_item_existed;
1493 } else if (IS_ERR(dir_item)) { 1493 } else if (IS_ERR(dir_item)) {
1494 ret = PTR_ERR(dir_item); 1494 ret = PTR_ERR(dir_item);
1495 btrfs_abort_transaction(trans, root, ret); 1495 btrfs_abort_transaction(trans, ret);
1496 goto fail; 1496 goto fail;
1497 } 1497 }
1498 btrfs_release_path(path); 1498 btrfs_release_path(path);
@@ -1505,7 +1505,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1505 */ 1505 */
1506 ret = btrfs_run_delayed_items(trans, root); 1506 ret = btrfs_run_delayed_items(trans, root);
1507 if (ret) { /* Transaction aborted */ 1507 if (ret) { /* Transaction aborted */
1508 btrfs_abort_transaction(trans, root, ret); 1508 btrfs_abort_transaction(trans, ret);
1509 goto fail; 1509 goto fail;
1510 } 1510 }
1511 1511
@@ -1544,7 +1544,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1544 if (ret) { 1544 if (ret) {
1545 btrfs_tree_unlock(old); 1545 btrfs_tree_unlock(old);
1546 free_extent_buffer(old); 1546 free_extent_buffer(old);
1547 btrfs_abort_transaction(trans, root, ret); 1547 btrfs_abort_transaction(trans, ret);
1548 goto fail; 1548 goto fail;
1549 } 1549 }
1550 1550
@@ -1555,7 +1555,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1555 btrfs_tree_unlock(old); 1555 btrfs_tree_unlock(old);
1556 free_extent_buffer(old); 1556 free_extent_buffer(old);
1557 if (ret) { 1557 if (ret) {
1558 btrfs_abort_transaction(trans, root, ret); 1558 btrfs_abort_transaction(trans, ret);
1559 goto fail; 1559 goto fail;
1560 } 1560 }
1561 /* see comments in should_cow_block() */ 1561 /* see comments in should_cow_block() */
@@ -1569,7 +1569,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1569 btrfs_tree_unlock(tmp); 1569 btrfs_tree_unlock(tmp);
1570 free_extent_buffer(tmp); 1570 free_extent_buffer(tmp);
1571 if (ret) { 1571 if (ret) {
1572 btrfs_abort_transaction(trans, root, ret); 1572 btrfs_abort_transaction(trans, ret);
1573 goto fail; 1573 goto fail;
1574 } 1574 }
1575 1575
@@ -1581,7 +1581,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1581 btrfs_ino(parent_inode), index, 1581 btrfs_ino(parent_inode), index,
1582 dentry->d_name.name, dentry->d_name.len); 1582 dentry->d_name.name, dentry->d_name.len);
1583 if (ret) { 1583 if (ret) {
1584 btrfs_abort_transaction(trans, root, ret); 1584 btrfs_abort_transaction(trans, ret);
1585 goto fail; 1585 goto fail;
1586 } 1586 }
1587 1587
@@ -1589,19 +1589,19 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1589 pending->snap = btrfs_read_fs_root_no_name(root->fs_info, &key); 1589 pending->snap = btrfs_read_fs_root_no_name(root->fs_info, &key);
1590 if (IS_ERR(pending->snap)) { 1590 if (IS_ERR(pending->snap)) {
1591 ret = PTR_ERR(pending->snap); 1591 ret = PTR_ERR(pending->snap);
1592 btrfs_abort_transaction(trans, root, ret); 1592 btrfs_abort_transaction(trans, ret);
1593 goto fail; 1593 goto fail;
1594 } 1594 }
1595 1595
1596 ret = btrfs_reloc_post_snapshot(trans, pending); 1596 ret = btrfs_reloc_post_snapshot(trans, pending);
1597 if (ret) { 1597 if (ret) {
1598 btrfs_abort_transaction(trans, root, ret); 1598 btrfs_abort_transaction(trans, ret);
1599 goto fail; 1599 goto fail;
1600 } 1600 }
1601 1601
1602 ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); 1602 ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1);
1603 if (ret) { 1603 if (ret) {
1604 btrfs_abort_transaction(trans, root, ret); 1604 btrfs_abort_transaction(trans, ret);
1605 goto fail; 1605 goto fail;
1606 } 1606 }
1607 1607
@@ -1623,7 +1623,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1623 /* We have check then name at the beginning, so it is impossible. */ 1623 /* We have check then name at the beginning, so it is impossible. */
1624 BUG_ON(ret == -EEXIST || ret == -EOVERFLOW); 1624 BUG_ON(ret == -EEXIST || ret == -EOVERFLOW);
1625 if (ret) { 1625 if (ret) {
1626 btrfs_abort_transaction(trans, root, ret); 1626 btrfs_abort_transaction(trans, ret);
1627 goto fail; 1627 goto fail;
1628 } 1628 }
1629 1629
@@ -1633,13 +1633,13 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1633 current_fs_time(parent_inode->i_sb); 1633 current_fs_time(parent_inode->i_sb);
1634 ret = btrfs_update_inode_fallback(trans, parent_root, parent_inode); 1634 ret = btrfs_update_inode_fallback(trans, parent_root, parent_inode);
1635 if (ret) { 1635 if (ret) {
1636 btrfs_abort_transaction(trans, root, ret); 1636 btrfs_abort_transaction(trans, ret);
1637 goto fail; 1637 goto fail;
1638 } 1638 }
1639 ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root, new_uuid.b, 1639 ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root, new_uuid.b,
1640 BTRFS_UUID_KEY_SUBVOL, objectid); 1640 BTRFS_UUID_KEY_SUBVOL, objectid);
1641 if (ret) { 1641 if (ret) {
1642 btrfs_abort_transaction(trans, root, ret); 1642 btrfs_abort_transaction(trans, ret);
1643 goto fail; 1643 goto fail;
1644 } 1644 }
1645 if (!btrfs_is_empty_uuid(new_root_item->received_uuid)) { 1645 if (!btrfs_is_empty_uuid(new_root_item->received_uuid)) {
@@ -1648,14 +1648,14 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1648 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 1648 BTRFS_UUID_KEY_RECEIVED_SUBVOL,
1649 objectid); 1649 objectid);
1650 if (ret && ret != -EEXIST) { 1650 if (ret && ret != -EEXIST) {
1651 btrfs_abort_transaction(trans, root, ret); 1651 btrfs_abort_transaction(trans, ret);
1652 goto fail; 1652 goto fail;
1653 } 1653 }
1654 } 1654 }
1655 1655
1656 ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1); 1656 ret = btrfs_run_delayed_refs(trans, root, (unsigned long)-1);
1657 if (ret) { 1657 if (ret) {
1658 btrfs_abort_transaction(trans, root, ret); 1658 btrfs_abort_transaction(trans, ret);
1659 goto fail; 1659 goto fail;
1660 } 1660 }
1661 1661
@@ -1851,7 +1851,7 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans,
1851 1851
1852 WARN_ON(trans->use_count > 1); 1852 WARN_ON(trans->use_count > 1);
1853 1853
1854 btrfs_abort_transaction(trans, root, err); 1854 btrfs_abort_transaction(trans, err);
1855 1855
1856 spin_lock(&root->fs_info->trans_lock); 1856 spin_lock(&root->fs_info->trans_lock);
1857 1857
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 391bd3ddaed3..d31a0c4f56be 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2788,7 +2788,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2788 ret = btrfs_write_marked_extents(log, &log->dirty_log_pages, mark); 2788 ret = btrfs_write_marked_extents(log, &log->dirty_log_pages, mark);
2789 if (ret) { 2789 if (ret) {
2790 blk_finish_plug(&plug); 2790 blk_finish_plug(&plug);
2791 btrfs_abort_transaction(trans, root, ret); 2791 btrfs_abort_transaction(trans, ret);
2792 btrfs_free_logged_extents(log, log_transid); 2792 btrfs_free_logged_extents(log, log_transid);
2793 btrfs_set_log_full_commit(root->fs_info, trans); 2793 btrfs_set_log_full_commit(root->fs_info, trans);
2794 mutex_unlock(&root->log_mutex); 2794 mutex_unlock(&root->log_mutex);
@@ -2838,7 +2838,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2838 btrfs_set_log_full_commit(root->fs_info, trans); 2838 btrfs_set_log_full_commit(root->fs_info, trans);
2839 2839
2840 if (ret != -ENOSPC) { 2840 if (ret != -ENOSPC) {
2841 btrfs_abort_transaction(trans, root, ret); 2841 btrfs_abort_transaction(trans, ret);
2842 mutex_unlock(&log_root_tree->log_mutex); 2842 mutex_unlock(&log_root_tree->log_mutex);
2843 goto out; 2843 goto out;
2844 } 2844 }
@@ -2898,7 +2898,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2898 blk_finish_plug(&plug); 2898 blk_finish_plug(&plug);
2899 if (ret) { 2899 if (ret) {
2900 btrfs_set_log_full_commit(root->fs_info, trans); 2900 btrfs_set_log_full_commit(root->fs_info, trans);
2901 btrfs_abort_transaction(trans, root, ret); 2901 btrfs_abort_transaction(trans, ret);
2902 btrfs_free_logged_extents(log, log_transid); 2902 btrfs_free_logged_extents(log, log_transid);
2903 mutex_unlock(&log_root_tree->log_mutex); 2903 mutex_unlock(&log_root_tree->log_mutex);
2904 goto out_wake_log_root; 2904 goto out_wake_log_root;
@@ -2934,7 +2934,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2934 ret = write_ctree_super(trans, root->fs_info->tree_root, 1); 2934 ret = write_ctree_super(trans, root->fs_info->tree_root, 1);
2935 if (ret) { 2935 if (ret) {
2936 btrfs_set_log_full_commit(root->fs_info, trans); 2936 btrfs_set_log_full_commit(root->fs_info, trans);
2937 btrfs_abort_transaction(trans, root, ret); 2937 btrfs_abort_transaction(trans, ret);
2938 goto out_wake_log_root; 2938 goto out_wake_log_root;
2939 } 2939 }
2940 2940
@@ -2991,7 +2991,7 @@ static void free_log_tree(struct btrfs_trans_handle *trans,
2991 ret = walk_log_tree(trans, log, &wc); 2991 ret = walk_log_tree(trans, log, &wc);
2992 /* I don't think this can happen but just in case */ 2992 /* I don't think this can happen but just in case */
2993 if (ret) 2993 if (ret)
2994 btrfs_abort_transaction(trans, log, ret); 2994 btrfs_abort_transaction(trans, ret);
2995 2995
2996 while (1) { 2996 while (1) {
2997 ret = find_first_extent_bit(&log->dirty_log_pages, 2997 ret = find_first_extent_bit(&log->dirty_log_pages,
@@ -3160,7 +3160,7 @@ out_unlock:
3160 btrfs_set_log_full_commit(root->fs_info, trans); 3160 btrfs_set_log_full_commit(root->fs_info, trans);
3161 ret = 0; 3161 ret = 0;
3162 } else if (ret < 0) 3162 } else if (ret < 0)
3163 btrfs_abort_transaction(trans, root, ret); 3163 btrfs_abort_transaction(trans, ret);
3164 3164
3165 btrfs_end_log_trans(root); 3165 btrfs_end_log_trans(root);
3166 3166
@@ -3193,7 +3193,7 @@ int btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans,
3193 btrfs_set_log_full_commit(root->fs_info, trans); 3193 btrfs_set_log_full_commit(root->fs_info, trans);
3194 ret = 0; 3194 ret = 0;
3195 } else if (ret < 0 && ret != -ENOENT) 3195 } else if (ret < 0 && ret != -ENOENT)
3196 btrfs_abort_transaction(trans, root, ret); 3196 btrfs_abort_transaction(trans, ret);
3197 btrfs_end_log_trans(root); 3197 btrfs_end_log_trans(root);
3198 3198
3199 return ret; 3199 return ret;
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 359ac819a8ed..e217035d63df 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2438,14 +2438,14 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
2438 ret = init_first_rw_device(trans, root, device); 2438 ret = init_first_rw_device(trans, root, device);
2439 unlock_chunks(root); 2439 unlock_chunks(root);
2440 if (ret) { 2440 if (ret) {
2441 btrfs_abort_transaction(trans, root, ret); 2441 btrfs_abort_transaction(trans, ret);
2442 goto error_trans; 2442 goto error_trans;
2443 } 2443 }
2444 } 2444 }
2445 2445
2446 ret = btrfs_add_device(trans, root, device); 2446 ret = btrfs_add_device(trans, root, device);
2447 if (ret) { 2447 if (ret) {
2448 btrfs_abort_transaction(trans, root, ret); 2448 btrfs_abort_transaction(trans, ret);
2449 goto error_trans; 2449 goto error_trans;
2450 } 2450 }
2451 2451
@@ -2454,7 +2454,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
2454 2454
2455 ret = btrfs_finish_sprout(trans, root); 2455 ret = btrfs_finish_sprout(trans, root);
2456 if (ret) { 2456 if (ret) {
2457 btrfs_abort_transaction(trans, root, ret); 2457 btrfs_abort_transaction(trans, ret);
2458 goto error_trans; 2458 goto error_trans;
2459 } 2459 }
2460 2460
@@ -2840,7 +2840,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
2840 &dev_extent_len); 2840 &dev_extent_len);
2841 if (ret) { 2841 if (ret) {
2842 mutex_unlock(&fs_devices->device_list_mutex); 2842 mutex_unlock(&fs_devices->device_list_mutex);
2843 btrfs_abort_transaction(trans, root, ret); 2843 btrfs_abort_transaction(trans, ret);
2844 goto out; 2844 goto out;
2845 } 2845 }
2846 2846
@@ -2859,7 +2859,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
2859 ret = btrfs_update_device(trans, map->stripes[i].dev); 2859 ret = btrfs_update_device(trans, map->stripes[i].dev);
2860 if (ret) { 2860 if (ret) {
2861 mutex_unlock(&fs_devices->device_list_mutex); 2861 mutex_unlock(&fs_devices->device_list_mutex);
2862 btrfs_abort_transaction(trans, root, ret); 2862 btrfs_abort_transaction(trans, ret);
2863 goto out; 2863 goto out;
2864 } 2864 }
2865 } 2865 }
@@ -2868,7 +2868,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
2868 2868
2869 ret = btrfs_free_chunk(trans, root, chunk_objectid, chunk_offset); 2869 ret = btrfs_free_chunk(trans, root, chunk_objectid, chunk_offset);
2870 if (ret) { 2870 if (ret) {
2871 btrfs_abort_transaction(trans, root, ret); 2871 btrfs_abort_transaction(trans, ret);
2872 goto out; 2872 goto out;
2873 } 2873 }
2874 2874
@@ -2877,14 +2877,14 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
2877 if (map->type & BTRFS_BLOCK_GROUP_SYSTEM) { 2877 if (map->type & BTRFS_BLOCK_GROUP_SYSTEM) {
2878 ret = btrfs_del_sys_chunk(root, chunk_objectid, chunk_offset); 2878 ret = btrfs_del_sys_chunk(root, chunk_objectid, chunk_offset);
2879 if (ret) { 2879 if (ret) {
2880 btrfs_abort_transaction(trans, root, ret); 2880 btrfs_abort_transaction(trans, ret);
2881 goto out; 2881 goto out;
2882 } 2882 }
2883 } 2883 }
2884 2884
2885 ret = btrfs_remove_block_group(trans, extent_root, chunk_offset, em); 2885 ret = btrfs_remove_block_group(trans, extent_root, chunk_offset, em);
2886 if (ret) { 2886 if (ret) {
2887 btrfs_abort_transaction(trans, extent_root, ret); 2887 btrfs_abort_transaction(trans, ret);
2888 goto out; 2888 goto out;
2889 } 2889 }
2890 2890
@@ -4299,7 +4299,7 @@ int btrfs_create_uuid_tree(struct btrfs_fs_info *fs_info)
4299 BTRFS_UUID_TREE_OBJECTID); 4299 BTRFS_UUID_TREE_OBJECTID);
4300 if (IS_ERR(uuid_root)) { 4300 if (IS_ERR(uuid_root)) {
4301 ret = PTR_ERR(uuid_root); 4301 ret = PTR_ERR(uuid_root);
4302 btrfs_abort_transaction(trans, tree_root, ret); 4302 btrfs_abort_transaction(trans, ret);
4303 btrfs_end_transaction(trans, tree_root); 4303 btrfs_end_transaction(trans, tree_root);
4304 return ret; 4304 return ret;
4305 } 4305 }