Skip to content

Commit

Permalink
btrfs: btrfs_abort_transaction, drop root parameter
Browse files Browse the repository at this point in the history
__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 <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
jeffmahoney authored and kdave committed Jul 26, 2016
1 parent 64b6358 commit 6664283
Show file tree
Hide file tree
Showing 17 changed files with 147 additions and 152 deletions.
12 changes: 6 additions & 6 deletions fs/btrfs/ctree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,14 +1153,14 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,

ret = update_ref_for_cow(trans, root, buf, cow, &last_ref);
if (ret) {
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
return ret;
}

if (test_bit(BTRFS_ROOT_REF_COWS, &root->state)) {
ret = btrfs_reloc_cow_block(trans, root, buf, cow);
if (ret) {
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
return ret;
}
}
Expand Down Expand Up @@ -1198,7 +1198,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
if (last_ref) {
ret = tree_mod_log_free_eb(root->fs_info, buf);
if (ret) {
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
return ret;
}
}
Expand Down Expand Up @@ -3255,7 +3255,7 @@ static int push_node_left(struct btrfs_trans_handle *trans,
ret = tree_mod_log_eb_copy(root->fs_info, dst, src, dst_nritems, 0,
push_items);
if (ret) {
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
return ret;
}
copy_extent_buffer(dst, src,
Expand Down Expand Up @@ -3330,7 +3330,7 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
ret = tree_mod_log_eb_copy(root->fs_info, dst, src, 0,
src_nritems - push_items, push_items);
if (ret) {
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
return ret;
}
copy_extent_buffer(dst, src,
Expand Down Expand Up @@ -3534,7 +3534,7 @@ static noinline int split_node(struct btrfs_trans_handle *trans,
ret = tree_mod_log_eb_copy(root->fs_info, split, c, 0,
mid, c_nritems - mid);
if (ret) {
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
return ret;
}
copy_extent_buffer(split, c,
Expand Down
8 changes: 4 additions & 4 deletions fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -3379,23 +3379,23 @@ const char *btrfs_decode_error(int errno);

__cold
void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
struct btrfs_root *root, const char *function,
const char *function,
unsigned int line, int errno);

/*
* Call btrfs_abort_transaction as early as possible when an error condition is
* detected, that way the exact line number is reported.
*/
#define btrfs_abort_transaction(trans, root, errno) \
#define btrfs_abort_transaction(trans, errno) \
do { \
/* Report first abort since mount */ \
if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED, \
&((root)->fs_info->fs_state))) { \
&((trans)->fs_info->fs_state))) { \
WARN(1, KERN_DEBUG \
"BTRFS: Transaction aborted (error %d)\n", \
(errno)); \
} \
__btrfs_abort_transaction((trans), (root), __func__, \
__btrfs_abort_transaction((trans), __func__, \
__LINE__, (errno)); \
} while (0)

Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/delayed-inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ static int __btrfs_run_delayed_items(struct btrfs_trans_handle *trans,
if (ret) {
btrfs_release_delayed_node(curr_node);
curr_node = NULL;
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
break;
}

Expand Down
47 changes: 23 additions & 24 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,7 @@ static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
path, bytenr, parent, root_objectid,
owner, offset, refs_to_add);
if (ret)
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
out:
btrfs_free_path(path);
return ret;
Expand Down Expand Up @@ -2971,7 +2971,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
trans->can_flush_pending_bgs = false;
ret = __btrfs_run_delayed_refs(trans, root, count);
if (ret < 0) {
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
return ret;
}

Expand Down Expand Up @@ -3430,7 +3430,7 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
* transaction, this only happens in really bad situations
* anyway.
*/
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
goto out_put;
}
WARN_ON(ret);
Expand Down Expand Up @@ -3670,7 +3670,7 @@ int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans,
}
spin_unlock(&cur_trans->dirty_bgs_lock);
} else if (ret) {
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
}
}

Expand Down Expand Up @@ -3816,7 +3816,7 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
cache);
}
if (ret)
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
}

/* if its not on the io list, we need to put the block group */
Expand Down Expand Up @@ -6881,7 +6881,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
NULL, refs_to_drop,
is_data, &last_ref);
if (ret) {
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}
btrfs_release_path(path);
Expand Down Expand Up @@ -6930,7 +6930,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
path->nodes[0]);
}
if (ret < 0) {
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}
extent_slot = path->slots[0];
Expand All @@ -6941,10 +6941,10 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
"unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu",
bytenr, parent, root_objectid, owner_objectid,
owner_offset);
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
} else {
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}

Expand All @@ -6956,7 +6956,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
ret = convert_extent_item_v0(trans, extent_root, path,
owner_objectid, 0);
if (ret < 0) {
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}

Expand All @@ -6975,7 +6975,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
btrfs_print_leaf(extent_root, path->nodes[0]);
}
if (ret < 0) {
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}

Expand All @@ -7000,7 +7000,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
btrfs_err(info, "trying to drop %d refs but we only have %Lu "
"for bytenr %Lu", refs_to_drop, refs, bytenr);
ret = -EINVAL;
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}
refs -= refs_to_drop;
Expand All @@ -7023,7 +7023,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
iref, refs_to_drop,
is_data, &last_ref);
if (ret) {
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}
}
Expand All @@ -7046,29 +7046,29 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
ret = btrfs_del_items(trans, extent_root, path, path->slots[0],
num_to_del);
if (ret) {
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}
btrfs_release_path(path);

if (is_data) {
ret = btrfs_del_csums(trans, root, bytenr, num_bytes);
if (ret) {
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}
}

ret = add_to_free_space_tree(trans, root->fs_info, bytenr,
num_bytes);
if (ret) {
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}

ret = update_block_group(trans, root, bytenr, num_bytes, 0);
if (ret) {
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}
}
Expand Down Expand Up @@ -7852,8 +7852,7 @@ static noinline int find_free_extent(struct btrfs_root *orig_root,
* can do more things.
*/
if (ret < 0 && ret != -ENOSPC)
btrfs_abort_transaction(trans,
root, ret);
btrfs_abort_transaction(trans, ret);
else
ret = 0;
if (!exist)
Expand Down Expand Up @@ -9329,7 +9328,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
&root->root_key,
root_item);
if (ret) {
btrfs_abort_transaction(trans, tree_root, ret);
btrfs_abort_transaction(trans, ret);
err = ret;
goto out_end_trans;
}
Expand All @@ -9356,15 +9355,15 @@ int btrfs_drop_snapshot(struct btrfs_root *root,

ret = btrfs_del_root(trans, tree_root, &root->root_key);
if (ret) {
btrfs_abort_transaction(trans, tree_root, ret);
btrfs_abort_transaction(trans, ret);
goto out_end_trans;
}

if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID) {
ret = btrfs_find_root(tree_root, &root->root_key, path,
NULL, NULL);
if (ret < 0) {
btrfs_abort_transaction(trans, tree_root, ret);
btrfs_abort_transaction(trans, ret);
err = ret;
goto out_end_trans;
} else if (ret > 0) {
Expand Down Expand Up @@ -10324,11 +10323,11 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans,
ret = btrfs_insert_item(trans, extent_root, &key, &item,
sizeof(item));
if (ret)
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
ret = btrfs_finish_chunk_alloc(trans, extent_root,
key.objectid, key.offset);
if (ret)
btrfs_abort_transaction(trans, extent_root, ret);
btrfs_abort_transaction(trans, ret);
add_block_group_free_space(trans, root->fs_info, block_group);
/* already aborted the transaction if it failed. */
next:
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/file-item.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
*/
ret = btrfs_split_item(trans, root, path, &key, offset);
if (ret && ret != -EAGAIN) {
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}

Expand Down
8 changes: 4 additions & 4 deletions fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
ret = btrfs_del_items(trans, root, path, del_slot,
del_nr);
if (ret) {
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
break;
}

Expand All @@ -974,7 +974,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
path->slots[0] = del_slot;
ret = btrfs_del_items(trans, root, path, del_slot, del_nr);
if (ret)
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
}

leaf = path->nodes[0];
Expand Down Expand Up @@ -1190,7 +1190,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
goto again;
}
if (ret < 0) {
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}

Expand Down Expand Up @@ -1278,7 +1278,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,

ret = btrfs_del_items(trans, root, path, del_slot, del_nr);
if (ret < 0) {
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);
goto out;
}
}
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/free-space-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root,
if (locked)
mutex_unlock(&trans->transaction->cache_write_mutex);
if (ret)
btrfs_abort_transaction(trans, root, ret);
btrfs_abort_transaction(trans, ret);

return ret;
}
Expand Down
Loading

0 comments on commit 6664283

Please sign in to comment.