Commit a4553fef authored by Anand Jain's avatar Anand Jain Committed by David Sterba

Btrfs: consolidate btrfs_error() to btrfs_std_error()

btrfs_error() and btrfs_std_error() does the same thing
and calls _btrfs_std_error(), so consolidate them together.
And the main motivation is that btrfs_error() is closely
named with btrfs_err(), one handles error action the other
is to log the error, so don't closely name them.
Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
Suggested-by: default avatarDavid Sterba <dsterba@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 57d816a1
...@@ -1011,7 +1011,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans, ...@@ -1011,7 +1011,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
return ret; return ret;
if (refs == 0) { if (refs == 0) {
ret = -EROFS; ret = -EROFS;
btrfs_std_error(root->fs_info, ret); btrfs_std_error(root->fs_info, ret, NULL);
return ret; return ret;
} }
} else { } else {
...@@ -1927,7 +1927,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, ...@@ -1927,7 +1927,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
child = read_node_slot(root, mid, 0); child = read_node_slot(root, mid, 0);
if (!child) { if (!child) {
ret = -EROFS; ret = -EROFS;
btrfs_std_error(root->fs_info, ret); btrfs_std_error(root->fs_info, ret, NULL);
goto enospc; goto enospc;
} }
...@@ -2030,7 +2030,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, ...@@ -2030,7 +2030,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
*/ */
if (!left) { if (!left) {
ret = -EROFS; ret = -EROFS;
btrfs_std_error(root->fs_info, ret); btrfs_std_error(root->fs_info, ret, NULL);
goto enospc; goto enospc;
} }
wret = balance_node_right(trans, root, mid, left); wret = balance_node_right(trans, root, mid, left);
......
...@@ -4127,14 +4127,7 @@ do { \ ...@@ -4127,14 +4127,7 @@ do { \
__LINE__, (errno)); \ __LINE__, (errno)); \
} while (0) } while (0)
#define btrfs_std_error(fs_info, errno) \ #define btrfs_std_error(fs_info, errno, fmt, args...) \
do { \
if ((errno)) \
__btrfs_std_error((fs_info), __func__, \
__LINE__, (errno), NULL); \
} while (0)
#define btrfs_error(fs_info, errno, fmt, args...) \
do { \ do { \
__btrfs_std_error((fs_info), __func__, __LINE__, \ __btrfs_std_error((fs_info), __func__, __LINE__, \
(errno), fmt, ##args); \ (errno), fmt, ##args); \
......
...@@ -2377,7 +2377,7 @@ static int btrfs_replay_log(struct btrfs_fs_info *fs_info, ...@@ -2377,7 +2377,7 @@ static int btrfs_replay_log(struct btrfs_fs_info *fs_info,
/* returns with log_tree_root freed on success */ /* returns with log_tree_root freed on success */
ret = btrfs_recover_log_trees(log_tree_root); ret = btrfs_recover_log_trees(log_tree_root);
if (ret) { if (ret) {
btrfs_error(tree_root->fs_info, ret, btrfs_std_error(tree_root->fs_info, ret,
"Failed to recover log tree"); "Failed to recover log tree");
free_extent_buffer(log_tree_root->node); free_extent_buffer(log_tree_root->node);
kfree(log_tree_root); kfree(log_tree_root);
...@@ -3556,7 +3556,7 @@ static int write_all_supers(struct btrfs_root *root, int max_mirrors) ...@@ -3556,7 +3556,7 @@ static int write_all_supers(struct btrfs_root *root, int max_mirrors)
if (ret) { if (ret) {
mutex_unlock( mutex_unlock(
&root->fs_info->fs_devices->device_list_mutex); &root->fs_info->fs_devices->device_list_mutex);
btrfs_error(root->fs_info, ret, btrfs_std_error(root->fs_info, ret,
"errors while submitting device barriers."); "errors while submitting device barriers.");
return ret; return ret;
} }
...@@ -3596,7 +3596,7 @@ static int write_all_supers(struct btrfs_root *root, int max_mirrors) ...@@ -3596,7 +3596,7 @@ static int write_all_supers(struct btrfs_root *root, int max_mirrors)
mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); mutex_unlock(&root->fs_info->fs_devices->device_list_mutex);
/* FUA is masked off if unsupported and can't be the reason */ /* FUA is masked off if unsupported and can't be the reason */
btrfs_error(root->fs_info, -EIO, btrfs_std_error(root->fs_info, -EIO,
"%d errors while writing supers", total_errors); "%d errors while writing supers", total_errors);
return -EIO; return -EIO;
} }
...@@ -3614,7 +3614,7 @@ static int write_all_supers(struct btrfs_root *root, int max_mirrors) ...@@ -3614,7 +3614,7 @@ static int write_all_supers(struct btrfs_root *root, int max_mirrors)
} }
mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); mutex_unlock(&root->fs_info->fs_devices->device_list_mutex);
if (total_errors > max_errors) { if (total_errors > max_errors) {
btrfs_error(root->fs_info, -EIO, btrfs_std_error(root->fs_info, -EIO,
"%d errors while writing supers", total_errors); "%d errors while writing supers", total_errors);
return -EIO; return -EIO;
} }
......
...@@ -8688,7 +8688,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, ...@@ -8688,7 +8688,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
if (!for_reloc && root_dropped == false) if (!for_reloc && root_dropped == false)
btrfs_add_dead_root(root); btrfs_add_dead_root(root);
if (err && err != -EAGAIN) if (err && err != -EAGAIN)
btrfs_std_error(root->fs_info, err); btrfs_std_error(root->fs_info, err, NULL);
return err; return err;
} }
......
...@@ -157,7 +157,7 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans, ...@@ -157,7 +157,7 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans,
*/ */
if (!btrfs_find_name_in_ext_backref(path, ref_objectid, if (!btrfs_find_name_in_ext_backref(path, ref_objectid,
name, name_len, &extref)) { name, name_len, &extref)) {
btrfs_std_error(root->fs_info, -ENOENT); btrfs_std_error(root->fs_info, -ENOENT, NULL);
ret = -EROFS; ret = -EROFS;
goto out; goto out;
} }
......
...@@ -4806,7 +4806,7 @@ static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg) ...@@ -4806,7 +4806,7 @@ static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg)
/* update qgroup status and info */ /* update qgroup status and info */
err = btrfs_run_qgroups(trans, root->fs_info); err = btrfs_run_qgroups(trans, root->fs_info);
if (err < 0) if (err < 0)
btrfs_error(root->fs_info, ret, btrfs_std_error(root->fs_info, ret,
"failed to update qgroup status and info\n"); "failed to update qgroup status and info\n");
err = btrfs_end_transaction(trans, root); err = btrfs_end_transaction(trans, root);
if (err && !ret) if (err && !ret)
......
...@@ -2418,7 +2418,7 @@ void merge_reloc_roots(struct reloc_control *rc) ...@@ -2418,7 +2418,7 @@ void merge_reloc_roots(struct reloc_control *rc)
} }
out: out:
if (ret) { if (ret) {
btrfs_std_error(root->fs_info, ret); btrfs_std_error(root->fs_info, ret, NULL);
if (!list_empty(&reloc_roots)) if (!list_empty(&reloc_roots))
free_reloc_roots(&reloc_roots); free_reloc_roots(&reloc_roots);
......
...@@ -283,7 +283,7 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root) ...@@ -283,7 +283,7 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root)
trans = btrfs_join_transaction(tree_root); trans = btrfs_join_transaction(tree_root);
if (IS_ERR(trans)) { if (IS_ERR(trans)) {
err = PTR_ERR(trans); err = PTR_ERR(trans);
btrfs_error(tree_root->fs_info, err, btrfs_std_error(tree_root->fs_info, err,
"Failed to start trans to delete " "Failed to start trans to delete "
"orphan item"); "orphan item");
break; break;
...@@ -292,7 +292,7 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root) ...@@ -292,7 +292,7 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root)
root_key.objectid); root_key.objectid);
btrfs_end_transaction(trans, tree_root); btrfs_end_transaction(trans, tree_root);
if (err) { if (err) {
btrfs_error(tree_root->fs_info, err, btrfs_std_error(tree_root->fs_info, err,
"Failed to delete root orphan " "Failed to delete root orphan "
"item"); "item");
break; break;
......
...@@ -2135,7 +2135,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -2135,7 +2135,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
ret = btrfs_write_and_wait_transaction(trans, root); ret = btrfs_write_and_wait_transaction(trans, root);
if (ret) { if (ret) {
btrfs_error(root->fs_info, ret, btrfs_std_error(root->fs_info, ret,
"Error while writing out transaction"); "Error while writing out transaction");
mutex_unlock(&root->fs_info->tree_log_mutex); mutex_unlock(&root->fs_info->tree_log_mutex);
goto scrub_continue; goto scrub_continue;
......
...@@ -5314,7 +5314,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) ...@@ -5314,7 +5314,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
ret = walk_log_tree(trans, log_root_tree, &wc); ret = walk_log_tree(trans, log_root_tree, &wc);
if (ret) { if (ret) {
btrfs_error(fs_info, ret, "Failed to pin buffers while " btrfs_std_error(fs_info, ret, "Failed to pin buffers while "
"recovering log root tree."); "recovering log root tree.");
goto error; goto error;
} }
...@@ -5328,7 +5328,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) ...@@ -5328,7 +5328,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
ret = btrfs_search_slot(NULL, log_root_tree, &key, path, 0, 0); ret = btrfs_search_slot(NULL, log_root_tree, &key, path, 0, 0);
if (ret < 0) { if (ret < 0) {
btrfs_error(fs_info, ret, btrfs_std_error(fs_info, ret,
"Couldn't find tree log root."); "Couldn't find tree log root.");
goto error; goto error;
} }
...@@ -5346,7 +5346,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) ...@@ -5346,7 +5346,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
log = btrfs_read_fs_root(log_root_tree, &found_key); log = btrfs_read_fs_root(log_root_tree, &found_key);
if (IS_ERR(log)) { if (IS_ERR(log)) {
ret = PTR_ERR(log); ret = PTR_ERR(log);
btrfs_error(fs_info, ret, btrfs_std_error(fs_info, ret,
"Couldn't read tree log root."); "Couldn't read tree log root.");
goto error; goto error;
} }
...@@ -5361,7 +5361,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) ...@@ -5361,7 +5361,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
free_extent_buffer(log->node); free_extent_buffer(log->node);
free_extent_buffer(log->commit_root); free_extent_buffer(log->commit_root);
kfree(log); kfree(log);
btrfs_error(fs_info, ret, "Couldn't read target root " btrfs_std_error(fs_info, ret, "Couldn't read target root "
"for tree log recovery."); "for tree log recovery.");
goto error; goto error;
} }
......
...@@ -1402,7 +1402,7 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans, ...@@ -1402,7 +1402,7 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,
extent = btrfs_item_ptr(leaf, path->slots[0], extent = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_dev_extent); struct btrfs_dev_extent);
} else { } else {
btrfs_error(root->fs_info, ret, "Slot search failed"); btrfs_std_error(root->fs_info, ret, "Slot search failed");
goto out; goto out;
} }
...@@ -1410,7 +1410,7 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans, ...@@ -1410,7 +1410,7 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,
ret = btrfs_del_item(trans, root, path); ret = btrfs_del_item(trans, root, path);
if (ret) { if (ret) {
btrfs_error(root->fs_info, ret, btrfs_std_error(root->fs_info, ret,
"Failed to remove dev extent item"); "Failed to remove dev extent item");
} else { } else {
trans->transaction->have_free_bgs = 1; trans->transaction->have_free_bgs = 1;
...@@ -2368,7 +2368,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) ...@@ -2368,7 +2368,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
ret = btrfs_relocate_sys_chunks(root); ret = btrfs_relocate_sys_chunks(root);
if (ret < 0) if (ret < 0)
btrfs_error(root->fs_info, ret, btrfs_std_error(root->fs_info, ret,
"Failed to relocate sys chunks after " "Failed to relocate sys chunks after "
"device initialization. This can be fixed " "device initialization. This can be fixed "
"using the \"btrfs balance\" command."); "using the \"btrfs balance\" command.");
...@@ -2613,7 +2613,7 @@ static int btrfs_free_chunk(struct btrfs_trans_handle *trans, ...@@ -2613,7 +2613,7 @@ static int btrfs_free_chunk(struct btrfs_trans_handle *trans,
if (ret < 0) if (ret < 0)
goto out; goto out;
else if (ret > 0) { /* Logic error or corruption */ else if (ret > 0) { /* Logic error or corruption */
btrfs_error(root->fs_info, -ENOENT, btrfs_std_error(root->fs_info, -ENOENT,
"Failed lookup while freeing chunk."); "Failed lookup while freeing chunk.");
ret = -ENOENT; ret = -ENOENT;
goto out; goto out;
...@@ -2621,7 +2621,7 @@ static int btrfs_free_chunk(struct btrfs_trans_handle *trans, ...@@ -2621,7 +2621,7 @@ static int btrfs_free_chunk(struct btrfs_trans_handle *trans,
ret = btrfs_del_item(trans, root, path); ret = btrfs_del_item(trans, root, path);
if (ret < 0) if (ret < 0)
btrfs_error(root->fs_info, ret, btrfs_std_error(root->fs_info, ret,
"Failed to delete chunk item."); "Failed to delete chunk item.");
out: out:
btrfs_free_path(path); btrfs_free_path(path);
...@@ -2806,7 +2806,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root, u64 chunk_offset) ...@@ -2806,7 +2806,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root, u64 chunk_offset)
trans = btrfs_start_transaction(root, 0); trans = btrfs_start_transaction(root, 0);
if (IS_ERR(trans)) { if (IS_ERR(trans)) {
ret = PTR_ERR(trans); ret = PTR_ERR(trans);
btrfs_std_error(root->fs_info, ret); btrfs_std_error(root->fs_info, ret, NULL);
return ret; return ret;
} }
...@@ -3461,7 +3461,7 @@ static void __cancel_balance(struct btrfs_fs_info *fs_info) ...@@ -3461,7 +3461,7 @@ static void __cancel_balance(struct btrfs_fs_info *fs_info)
unset_balance_control(fs_info); unset_balance_control(fs_info);
ret = del_balance_item(fs_info->tree_root); ret = del_balance_item(fs_info->tree_root);
if (ret) if (ret)
btrfs_std_error(fs_info, ret); btrfs_std_error(fs_info, ret, NULL);
atomic_set(&fs_info->mutually_exclusive_operation_running, 0); atomic_set(&fs_info->mutually_exclusive_operation_running, 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment