Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66642832 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by David Sterba
Browse files

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: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 64b63580
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -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;
		}
	}
@@ -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;
			}
		}
@@ -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,
@@ -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,
@@ -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,
+4 −4
Original line number Diff line number Diff line
@@ -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)

+1 −1
Original line number Diff line number Diff line
@@ -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;
		}

+23 −24
Original line number Diff line number Diff line
@@ -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;
@@ -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;
	}

@@ -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);
@@ -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);
			}
		}

@@ -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 */
@@ -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);
@@ -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];
@@ -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;
	}

@@ -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;
		}

@@ -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;
		}

@@ -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;
@@ -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;
			}
		}
@@ -7046,7 +7046,7 @@ 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);
@@ -7054,7 +7054,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
		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;
			}
		}
@@ -7062,13 +7062,13 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
		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;
		}
	}
@@ -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)
@@ -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;
			}
@@ -9356,7 +9355,7 @@ 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;
	}

@@ -9364,7 +9363,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
		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) {
@@ -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:
+1 −1
Original line number Diff line number Diff line
@@ -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;
			}

Loading