Commit e46c181a authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Convert more code to bch_err_msg()

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent da187cac
...@@ -1931,7 +1931,7 @@ static int bch2_dev_freespace_init(struct bch_fs *c, struct bch_dev *ca, ...@@ -1931,7 +1931,7 @@ static int bch2_dev_freespace_init(struct bch_fs *c, struct bch_dev *ca,
bch2_trans_exit(&trans); bch2_trans_exit(&trans);
if (ret < 0) { if (ret < 0) {
bch_err(ca, "error initializing free space: %s", bch2_err_str(ret)); bch_err_msg(ca, ret, "initializing free space");
return ret; return ret;
} }
......
...@@ -1483,7 +1483,7 @@ static int bch2_gc_alloc_done(struct bch_fs *c, bool metadata_only) ...@@ -1483,7 +1483,7 @@ static int bch2_gc_alloc_done(struct bch_fs *c, bool metadata_only)
bch2_alloc_write_key(&trans, &iter, k, metadata_only)); bch2_alloc_write_key(&trans, &iter, k, metadata_only));
if (ret < 0) { if (ret < 0) {
bch_err(c, "error writing alloc info: %s", bch2_err_str(ret)); bch_err_fn(c, ret);
percpu_ref_put(&ca->ref); percpu_ref_put(&ca->ref);
break; break;
} }
...@@ -1548,7 +1548,7 @@ static int bch2_gc_alloc_start(struct bch_fs *c, bool metadata_only) ...@@ -1548,7 +1548,7 @@ static int bch2_gc_alloc_start(struct bch_fs *c, bool metadata_only)
bch2_trans_exit(&trans); bch2_trans_exit(&trans);
if (ret) if (ret)
bch_err(c, "error reading alloc info at gc start: %s", bch2_err_str(ret)); bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -1998,7 +1998,7 @@ int bch2_gc_gens(struct bch_fs *c) ...@@ -1998,7 +1998,7 @@ int bch2_gc_gens(struct bch_fs *c)
BTREE_INSERT_NOFAIL, BTREE_INSERT_NOFAIL,
gc_btree_gens_key(&trans, &iter, k)); gc_btree_gens_key(&trans, &iter, k));
if (ret && !bch2_err_matches(ret, EROFS)) if (ret && !bch2_err_matches(ret, EROFS))
bch_err(c, "error recalculating oldest_gen: %s", bch2_err_str(ret)); bch_err_fn(c, ret);
if (ret) if (ret)
goto err; goto err;
} }
...@@ -2011,7 +2011,7 @@ int bch2_gc_gens(struct bch_fs *c) ...@@ -2011,7 +2011,7 @@ int bch2_gc_gens(struct bch_fs *c)
BTREE_INSERT_NOFAIL, BTREE_INSERT_NOFAIL,
bch2_alloc_write_oldest_gen(&trans, &iter, k)); bch2_alloc_write_oldest_gen(&trans, &iter, k));
if (ret && !bch2_err_matches(ret, EROFS)) if (ret && !bch2_err_matches(ret, EROFS))
bch_err(c, "error writing oldest_gen: %s", bch2_err_str(ret)); bch_err_fn(c, ret);
if (ret) if (ret)
goto err; goto err;
...@@ -2083,7 +2083,7 @@ static int bch2_gc_thread(void *arg) ...@@ -2083,7 +2083,7 @@ static int bch2_gc_thread(void *arg)
ret = bch2_gc_gens(c); ret = bch2_gc_gens(c);
#endif #endif
if (ret < 0) if (ret < 0)
bch_err(c, "btree gc failed: %s", bch2_err_str(ret)); bch_err_fn(c, ret);
debug_check_no_locks_held(); debug_check_no_locks_held();
} }
...@@ -2113,7 +2113,7 @@ int bch2_gc_thread_start(struct bch_fs *c) ...@@ -2113,7 +2113,7 @@ int bch2_gc_thread_start(struct bch_fs *c)
p = kthread_create(bch2_gc_thread, c, "bch-gc/%s", c->name); p = kthread_create(bch2_gc_thread, c, "bch-gc/%s", c->name);
if (IS_ERR(p)) { if (IS_ERR(p)) {
bch_err(c, "error creating gc thread: %s", bch2_err_str(PTR_ERR(p))); bch_err_fn(c, PTR_ERR(p));
return PTR_ERR(p); return PTR_ERR(p);
} }
......
...@@ -2057,7 +2057,7 @@ static void async_btree_node_rewrite_work(struct work_struct *work) ...@@ -2057,7 +2057,7 @@ static void async_btree_node_rewrite_work(struct work_struct *work)
ret = bch2_trans_do(c, NULL, NULL, 0, ret = bch2_trans_do(c, NULL, NULL, 0,
async_btree_node_rewrite_trans(&trans, a)); async_btree_node_rewrite_trans(&trans, a));
if (ret) if (ret)
bch_err(c, "%s: error %s", __func__, bch2_err_str(ret)); bch_err_fn(c, ret);
bch2_write_ref_put(c, BCH_WRITE_REF_node_rewrite); bch2_write_ref_put(c, BCH_WRITE_REF_node_rewrite);
kfree(a); kfree(a);
} }
...@@ -2096,8 +2096,7 @@ void bch2_btree_node_rewrite_async(struct bch_fs *c, struct btree *b) ...@@ -2096,8 +2096,7 @@ void bch2_btree_node_rewrite_async(struct bch_fs *c, struct btree *b)
ret = bch2_fs_read_write_early(c); ret = bch2_fs_read_write_early(c);
if (ret) { if (ret) {
bch_err(c, "%s: error going read-write: %s", bch_err_msg(c, ret, "going read-write");
__func__, bch2_err_str(ret));
kfree(a); kfree(a);
return; return;
} }
......
...@@ -1133,8 +1133,7 @@ static void ec_stripe_create(struct ec_stripe_new *s) ...@@ -1133,8 +1133,7 @@ static void ec_stripe_create(struct ec_stripe_new *s)
ret = ec_stripe_update_extents(c, &s->new_stripe); ret = ec_stripe_update_extents(c, &s->new_stripe);
if (ret) { if (ret) {
bch_err(c, "error creating stripe: error updating pointers: %s", bch_err_msg(c, ret, "creating stripe: error updating pointers");
bch2_err_str(ret));
goto err; goto err;
} }
err: err:
......
...@@ -1890,7 +1890,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, ...@@ -1890,7 +1890,7 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type,
vinode = bch2_vfs_inode_get(c, BCACHEFS_ROOT_SUBVOL_INUM); vinode = bch2_vfs_inode_get(c, BCACHEFS_ROOT_SUBVOL_INUM);
ret = PTR_ERR_OR_ZERO(vinode); ret = PTR_ERR_OR_ZERO(vinode);
if (ret) { if (ret) {
bch_err(c, "error mounting: error getting root inode: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "mounting: error getting root inode");
goto err_put_super; goto err_put_super;
} }
......
...@@ -80,7 +80,7 @@ static int __snapshot_lookup_subvol(struct btree_trans *trans, u32 snapshot, ...@@ -80,7 +80,7 @@ static int __snapshot_lookup_subvol(struct btree_trans *trans, u32 snapshot,
if (!ret) if (!ret)
*subvol = le32_to_cpu(s.subvol); *subvol = le32_to_cpu(s.subvol);
else if (bch2_err_matches(ret, ENOENT)) else if (bch2_err_matches(ret, ENOENT))
bch_err(trans->c, "snapshot %u not fonud", snapshot); bch_err(trans->c, "snapshot %u not found", snapshot);
return ret; return ret;
} }
...@@ -127,8 +127,7 @@ static int lookup_first_inode(struct btree_trans *trans, u64 inode_nr, ...@@ -127,8 +127,7 @@ static int lookup_first_inode(struct btree_trans *trans, u64 inode_nr,
ret = bch2_inode_unpack(k, inode); ret = bch2_inode_unpack(k, inode);
err: err:
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart)) if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
bch_err(trans->c, "error fetching inode %llu: %s", bch_err_msg(trans->c, ret, "fetching inode %llu", inode_nr);
inode_nr, bch2_err_str(ret));
bch2_trans_iter_exit(trans, &iter); bch2_trans_iter_exit(trans, &iter);
return ret; return ret;
} }
...@@ -154,8 +153,7 @@ static int __lookup_inode(struct btree_trans *trans, u64 inode_nr, ...@@ -154,8 +153,7 @@ static int __lookup_inode(struct btree_trans *trans, u64 inode_nr,
*snapshot = iter.pos.snapshot; *snapshot = iter.pos.snapshot;
err: err:
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart)) if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
bch_err(trans->c, "error fetching inode %llu:%u: %s", bch_err_msg(trans->c, ret, "fetching inode %llu:%u", inode_nr, *snapshot);
inode_nr, *snapshot, bch2_err_str(ret));
bch2_trans_iter_exit(trans, &iter); bch2_trans_iter_exit(trans, &iter);
return ret; return ret;
} }
...@@ -206,17 +204,16 @@ static int __write_inode(struct btree_trans *trans, ...@@ -206,17 +204,16 @@ static int __write_inode(struct btree_trans *trans,
BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE); BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE);
} }
static int write_inode(struct btree_trans *trans, static int fsck_write_inode(struct btree_trans *trans,
struct bch_inode_unpacked *inode, struct bch_inode_unpacked *inode,
u32 snapshot) u32 snapshot)
{ {
int ret = commit_do(trans, NULL, NULL, int ret = commit_do(trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW, BTREE_INSERT_LAZY_RW,
__write_inode(trans, inode, snapshot)); __write_inode(trans, inode, snapshot));
if (ret) if (ret)
bch_err(trans->c, "error in fsck: error updating inode: %s", bch_err_fn(trans->c, ret);
bch2_err_str(ret));
return ret; return ret;
} }
...@@ -278,7 +275,7 @@ static int lookup_lostfound(struct btree_trans *trans, u32 subvol, ...@@ -278,7 +275,7 @@ static int lookup_lostfound(struct btree_trans *trans, u32 subvol,
} }
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart)) if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
bch_err(c, "error looking up lost+found: %s", bch2_err_str(ret)); bch_err_fn(c, ret);
if (ret) if (ret)
return ret; return ret;
...@@ -301,7 +298,7 @@ static int lookup_lostfound(struct btree_trans *trans, u32 subvol, ...@@ -301,7 +298,7 @@ static int lookup_lostfound(struct btree_trans *trans, u32 subvol,
0, 0, S_IFDIR|0700, 0, NULL, NULL, 0, 0, S_IFDIR|0700, 0, NULL, NULL,
(subvol_inum) { }, 0); (subvol_inum) { }, 0);
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart)) if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
bch_err(c, "error creating lost+found: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "creating lost+found");
return ret; return ret;
} }
...@@ -365,8 +362,7 @@ static int reattach_inode(struct btree_trans *trans, ...@@ -365,8 +362,7 @@ static int reattach_inode(struct btree_trans *trans,
BTREE_INSERT_NOFAIL, BTREE_INSERT_NOFAIL,
__reattach_inode(trans, inode, inode_snapshot)); __reattach_inode(trans, inode, inode_snapshot));
if (ret) { if (ret) {
bch_err(trans->c, "error reattaching inode %llu: %s", bch_err_msg(trans->c, ret, "reattaching inode %llu", inode->bi_inum);
inode->bi_inum, bch2_err_str(ret));
return ret; return ret;
} }
...@@ -819,7 +815,7 @@ static int hash_check_key(struct btree_trans *trans, ...@@ -819,7 +815,7 @@ static int hash_check_key(struct btree_trans *trans,
bch2_bkey_val_to_text(&buf, c, hash_k), buf.buf))) { bch2_bkey_val_to_text(&buf, c, hash_k), buf.buf))) {
ret = hash_redo_key(trans, desc, hash_info, k_iter, hash_k); ret = hash_redo_key(trans, desc, hash_info, k_iter, hash_k);
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart)) if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
bch_err(c, "hash_redo_key err %s", bch2_err_str(ret)); bch_err_fn(c, ret);
if (ret) if (ret)
return ret; return ret;
ret = -BCH_ERR_transaction_restart_nested; ret = -BCH_ERR_transaction_restart_nested;
...@@ -883,7 +879,8 @@ static int check_inode(struct btree_trans *trans, ...@@ -883,7 +879,8 @@ static int check_inode(struct btree_trans *trans,
ret = __write_inode(trans, &u, iter->pos.snapshot); ret = __write_inode(trans, &u, iter->pos.snapshot);
if (ret) { if (ret) {
bch_err_msg(c, ret, "in fsck: error updating inode"); if (!bch2_err_matches(ret, BCH_ERR_transaction_restart))
bch_err_msg(c, ret, "in fsck updating inode");
return ret; return ret;
} }
...@@ -901,8 +898,7 @@ static int check_inode(struct btree_trans *trans, ...@@ -901,8 +898,7 @@ static int check_inode(struct btree_trans *trans,
ret = bch2_inode_rm_snapshot(trans, u.bi_inum, iter->pos.snapshot); ret = bch2_inode_rm_snapshot(trans, u.bi_inum, iter->pos.snapshot);
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart)) if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
bch_err(c, "error in fsck: error while deleting inode: %s", bch_err_msg(c, ret, "in fsck deleting inode");
bch2_err_str(ret));
return ret; return ret;
} }
...@@ -925,8 +921,7 @@ static int check_inode(struct btree_trans *trans, ...@@ -925,8 +921,7 @@ static int check_inode(struct btree_trans *trans,
POS(u.bi_inum, U64_MAX), POS(u.bi_inum, U64_MAX),
0, NULL); 0, NULL);
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart)) if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
bch_err(c, "error in fsck: error truncating inode: %s", bch_err_msg(c, ret, "in fsck truncating inode");
bch2_err_str(ret));
if (ret) if (ret)
return ret; return ret;
...@@ -951,8 +946,7 @@ static int check_inode(struct btree_trans *trans, ...@@ -951,8 +946,7 @@ static int check_inode(struct btree_trans *trans,
sectors = bch2_count_inode_sectors(trans, u.bi_inum, iter->pos.snapshot); sectors = bch2_count_inode_sectors(trans, u.bi_inum, iter->pos.snapshot);
if (sectors < 0) { if (sectors < 0) {
bch_err(c, "error in fsck: error recounting inode sectors: %s", bch_err_msg(c, sectors, "fsck recounting inode sectors");
bch2_err_str(sectors));
return sectors; return sectors;
} }
...@@ -971,13 +965,13 @@ static int check_inode(struct btree_trans *trans, ...@@ -971,13 +965,13 @@ static int check_inode(struct btree_trans *trans,
if (do_update) { if (do_update) {
ret = __write_inode(trans, &u, iter->pos.snapshot); ret = __write_inode(trans, &u, iter->pos.snapshot);
if (ret) { if (ret) {
bch_err_msg(c, ret, "in fsck: error updating inode"); bch_err_msg(c, ret, "in fsck updating inode");
return ret; return ret;
} }
} }
err: err:
fsck_err: fsck_err:
if (ret) if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
bch_err_fn(c, ret); bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -1078,7 +1072,7 @@ static int check_i_sectors(struct btree_trans *trans, struct inode_walker *w) ...@@ -1078,7 +1072,7 @@ static int check_i_sectors(struct btree_trans *trans, struct inode_walker *w)
w->last_pos.inode, i->snapshot, w->last_pos.inode, i->snapshot,
i->inode.bi_sectors, i->count)) { i->inode.bi_sectors, i->count)) {
i->inode.bi_sectors = i->count; i->inode.bi_sectors = i->count;
ret = write_inode(trans, &i->inode, i->snapshot); ret = fsck_write_inode(trans, &i->inode, i->snapshot);
if (ret) if (ret)
break; break;
} }
...@@ -1496,7 +1490,7 @@ static int check_subdir_count(struct btree_trans *trans, struct inode_walker *w) ...@@ -1496,7 +1490,7 @@ static int check_subdir_count(struct btree_trans *trans, struct inode_walker *w)
"directory %llu:%u with wrong i_nlink: got %u, should be %llu", "directory %llu:%u with wrong i_nlink: got %u, should be %llu",
w->last_pos.inode, i->snapshot, i->inode.bi_nlink, i->count)) { w->last_pos.inode, i->snapshot, i->inode.bi_nlink, i->count)) {
i->inode.bi_nlink = i->count; i->inode.bi_nlink = i->count;
ret = write_inode(trans, &i->inode, i->snapshot); ret = fsck_write_inode(trans, &i->inode, i->snapshot);
if (ret) if (ret)
break; break;
} }
...@@ -1923,7 +1917,7 @@ static int check_root_trans(struct btree_trans *trans) ...@@ -1923,7 +1917,7 @@ static int check_root_trans(struct btree_trans *trans)
__bch2_btree_insert(trans, BTREE_ID_subvolumes, __bch2_btree_insert(trans, BTREE_ID_subvolumes,
&root_subvol.k_i, 0)); &root_subvol.k_i, 0));
if (ret) { if (ret) {
bch_err(c, "error writing root subvol: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "writing root subvol");
goto err; goto err;
} }
...@@ -1942,7 +1936,7 @@ static int check_root_trans(struct btree_trans *trans) ...@@ -1942,7 +1936,7 @@ static int check_root_trans(struct btree_trans *trans)
ret = __write_inode(trans, &root_inode, snapshot); ret = __write_inode(trans, &root_inode, snapshot);
if (ret) if (ret)
bch_err(c, "error writing root inode: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "writing root inode");
} }
err: err:
fsck_err: fsck_err:
......
...@@ -834,7 +834,7 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr, ...@@ -834,7 +834,7 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr,
ca->mi.bucket_size)); ca->mi.bucket_size));
if (ret) { if (ret) {
bch2_open_bucket_put(c, ob[nr_got]); bch2_open_bucket_put(c, ob[nr_got]);
bch_err(c, "error marking new journal buckets: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "marking new journal buckets");
break; break;
} }
......
...@@ -758,7 +758,7 @@ int bch2_journal_reclaim_start(struct journal *j) ...@@ -758,7 +758,7 @@ int bch2_journal_reclaim_start(struct journal *j)
"bch-reclaim/%s", c->name); "bch-reclaim/%s", c->name);
ret = PTR_ERR_OR_ZERO(p); ret = PTR_ERR_OR_ZERO(p);
if (ret) { if (ret) {
bch_err(c, "error creating journal reclaim thread: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "creating journal reclaim thread");
return ret; return ret;
} }
......
...@@ -148,8 +148,7 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags) ...@@ -148,8 +148,7 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags)
} }
if (ret) { if (ret) {
bch_err(c, "Error updating btree node key: %s", bch_err_msg(c, ret, "updating btree node key");
bch2_err_str(ret));
break; break;
} }
next: next:
......
...@@ -242,7 +242,7 @@ static int bch2_copygc(struct btree_trans *trans, ...@@ -242,7 +242,7 @@ static int bch2_copygc(struct btree_trans *trans,
ret = 0; ret = 0;
if (ret < 0 && !bch2_err_matches(ret, EROFS)) if (ret < 0 && !bch2_err_matches(ret, EROFS))
bch_err(c, "error from bch2_move_data() in copygc: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "from bch2_move_data()");
moved = atomic64_read(&ctxt->stats->sectors_moved) - moved; moved = atomic64_read(&ctxt->stats->sectors_moved) - moved;
trace_and_count(c, copygc, c, moved, 0, 0, 0); trace_and_count(c, copygc, c, moved, 0, 0, 0);
...@@ -320,8 +320,7 @@ static int bch2_copygc_thread(void *arg) ...@@ -320,8 +320,7 @@ static int bch2_copygc_thread(void *arg)
ret = rhashtable_init(&move_buckets.table, &bch_move_bucket_params); ret = rhashtable_init(&move_buckets.table, &bch_move_bucket_params);
if (ret) { if (ret) {
bch_err(c, "error allocating copygc buckets in flight: %s", bch_err_msg(c, ret, "allocating copygc buckets in flight");
bch2_err_str(ret));
return ret; return ret;
} }
...@@ -404,7 +403,7 @@ int bch2_copygc_start(struct bch_fs *c) ...@@ -404,7 +403,7 @@ int bch2_copygc_start(struct bch_fs *c)
t = kthread_create(bch2_copygc_thread, c, "bch-copygc/%s", c->name); t = kthread_create(bch2_copygc_thread, c, "bch-copygc/%s", c->name);
ret = PTR_ERR_OR_ZERO(t); ret = PTR_ERR_OR_ZERO(t);
if (ret) { if (ret) {
bch_err(c, "error creating copygc thread: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "creating copygc thread");
return ret; return ret;
} }
......
...@@ -350,7 +350,7 @@ int bch2_rebalance_start(struct bch_fs *c) ...@@ -350,7 +350,7 @@ int bch2_rebalance_start(struct bch_fs *c)
p = kthread_create(bch2_rebalance_thread, c, "bch-rebalance/%s", c->name); p = kthread_create(bch2_rebalance_thread, c, "bch-rebalance/%s", c->name);
ret = PTR_ERR_OR_ZERO(p); ret = PTR_ERR_OR_ZERO(p);
if (ret) { if (ret) {
bch_err(c, "error creating rebalance thread: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "creating rebalance thread");
return ret; return ret;
} }
......
...@@ -429,7 +429,7 @@ static int bch2_mark_replicas_slowpath(struct bch_fs *c, ...@@ -429,7 +429,7 @@ static int bch2_mark_replicas_slowpath(struct bch_fs *c,
return ret; return ret;
err: err:
bch_err(c, "error adding replicas entry: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "adding replicas entry");
goto out; goto out;
} }
......
...@@ -1385,7 +1385,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c) ...@@ -1385,7 +1385,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
if (!test_bit(BCH_FS_STARTED, &c->flags)) { if (!test_bit(BCH_FS_STARTED, &c->flags)) {
ret = bch2_fs_read_write_early(c); ret = bch2_fs_read_write_early(c);
if (ret) { if (ret) {
bch_err(c, "error deleleting dead snapshots: error going rw: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "error deleleting dead snapshots: error going rw");
return ret; return ret;
} }
} }
...@@ -1401,7 +1401,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c) ...@@ -1401,7 +1401,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
NULL, NULL, 0, NULL, NULL, 0,
bch2_delete_redundant_snapshot(&trans, &iter, k)); bch2_delete_redundant_snapshot(&trans, &iter, k));
if (ret) { if (ret) {
bch_err(c, "error deleting redundant snapshots: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "deleting redundant snapshots");
goto err; goto err;
} }
...@@ -1409,7 +1409,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c) ...@@ -1409,7 +1409,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
POS_MIN, 0, k, POS_MIN, 0, k,
bch2_snapshot_set_equiv(&trans, k)); bch2_snapshot_set_equiv(&trans, k));
if (ret) { if (ret) {
bch_err(c, "error in bch2_snapshots_set_equiv: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "in bch2_snapshots_set_equiv");
goto err; goto err;
} }
......
...@@ -41,8 +41,7 @@ static int check_subvol(struct btree_trans *trans, ...@@ -41,8 +41,7 @@ static int check_subvol(struct btree_trans *trans,
ret = bch2_subvolume_delete(trans, iter->pos.offset); ret = bch2_subvolume_delete(trans, iter->pos.offset);
if (ret) if (ret)
bch_err(c, "error deleting subvolume %llu: %s", bch_err_msg(c, ret, "deleting subvolume %llu", iter->pos.offset);
iter->pos.offset, bch2_err_str(ret));
return ret ?: -BCH_ERR_transaction_restart_nested; return ret ?: -BCH_ERR_transaction_restart_nested;
} }
...@@ -296,7 +295,7 @@ static void bch2_subvolume_wait_for_pagecache_and_delete(struct work_struct *wor ...@@ -296,7 +295,7 @@ static void bch2_subvolume_wait_for_pagecache_and_delete(struct work_struct *wor
for (id = s.data; id < s.data + s.nr; id++) { for (id = s.data; id < s.data + s.nr; id++) {
ret = bch2_trans_run(c, bch2_subvolume_delete(&trans, *id)); ret = bch2_trans_run(c, bch2_subvolume_delete(&trans, *id));
if (ret) { if (ret) {
bch_err(c, "error deleting subvolume %u: %s", *id, bch2_err_str(ret)); bch_err_msg(c, ret, "deleting subvolume %u", *id);
break; break;
} }
} }
......
...@@ -994,7 +994,7 @@ int bch2_fs_start(struct bch_fs *c) ...@@ -994,7 +994,7 @@ int bch2_fs_start(struct bch_fs *c)
up_write(&c->state_lock); up_write(&c->state_lock);
return ret; return ret;
err: err:
bch_err(c, "error starting filesystem: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "starting filesystem");
goto out; goto out;
} }
...@@ -1459,7 +1459,7 @@ static int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca) ...@@ -1459,7 +1459,7 @@ static int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
bch2_btree_delete_range(c, BTREE_ID_bucket_gens, start, end, bch2_btree_delete_range(c, BTREE_ID_bucket_gens, start, end,
BTREE_TRIGGER_NORUN, NULL); BTREE_TRIGGER_NORUN, NULL);
if (ret) if (ret)
bch_err(c, "error removing dev alloc info: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "removing dev alloc info");
return ret; return ret;
} }
...@@ -1488,31 +1488,31 @@ int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags) ...@@ -1488,31 +1488,31 @@ int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags)
ret = bch2_dev_data_drop(c, ca->dev_idx, flags); ret = bch2_dev_data_drop(c, ca->dev_idx, flags);
if (ret) { if (ret) {
bch_err(ca, "Remove failed: error dropping data: %s", bch2_err_str(ret)); bch_err_msg(ca, ret, "dropping data");
goto err; goto err;
} }
ret = bch2_dev_remove_alloc(c, ca); ret = bch2_dev_remove_alloc(c, ca);
if (ret) { if (ret) {
bch_err(ca, "Remove failed, error deleting alloc info"); bch_err_msg(ca, ret, "deleting alloc info");
goto err; goto err;
} }
ret = bch2_journal_flush_device_pins(&c->journal, ca->dev_idx); ret = bch2_journal_flush_device_pins(&c->journal, ca->dev_idx);
if (ret) { if (ret) {
bch_err(ca, "Remove failed: error flushing journal: %s", bch2_err_str(ret)); bch_err_msg(ca, ret, "flushing journal");
goto err; goto err;
} }
ret = bch2_journal_flush(&c->journal); ret = bch2_journal_flush(&c->journal);
if (ret) { if (ret) {
bch_err(ca, "Remove failed, journal error"); bch_err(ca, "journal error");
goto err; goto err;
} }
ret = bch2_replicas_gc2(c); ret = bch2_replicas_gc2(c);
if (ret) { if (ret) {
bch_err(ca, "Remove failed: error from replicas gc: %s", bch2_err_str(ret)); bch_err_msg(ca, ret, "in replicas_gc2()");
goto err; goto err;
} }
...@@ -1587,7 +1587,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1587,7 +1587,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
ret = bch2_read_super(path, &opts, &sb); ret = bch2_read_super(path, &opts, &sb);
if (ret) { if (ret) {
bch_err(c, "device add error: error reading super: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "reading super");
goto err; goto err;
} }
...@@ -1603,7 +1603,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1603,7 +1603,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
ret = bch2_dev_may_add(sb.sb, c); ret = bch2_dev_may_add(sb.sb, c);
if (ret) { if (ret) {
bch_err(c, "device add error: %s", bch2_err_str(ret)); bch_err_fn(c, ret);
goto err; goto err;
} }
...@@ -1624,7 +1624,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1624,7 +1624,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
ret = bch2_dev_journal_alloc(ca); ret = bch2_dev_journal_alloc(ca);
if (ret) { if (ret) {
bch_err(c, "device add error: journal alloc failed"); bch_err_msg(c, ret, "allocating journal");
goto err; goto err;
} }
...@@ -1633,7 +1633,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1633,7 +1633,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
ret = bch2_sb_from_fs(c, ca); ret = bch2_sb_from_fs(c, ca);
if (ret) { if (ret) {
bch_err(c, "device add error: new device superblock too small"); bch_err_msg(c, ret, "setting up new superblock");
goto err_unlock; goto err_unlock;
} }
...@@ -1642,8 +1642,8 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1642,8 +1642,8 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
if (!bch2_sb_resize_members(&ca->disk_sb, if (!bch2_sb_resize_members(&ca->disk_sb,
le32_to_cpu(mi->field.u64s) + le32_to_cpu(mi->field.u64s) +
sizeof(dev_mi) / sizeof(u64))) { sizeof(dev_mi) / sizeof(u64))) {
bch_err(c, "device add error: new device superblock too small");
ret = -BCH_ERR_ENOSPC_sb_members; ret = -BCH_ERR_ENOSPC_sb_members;
bch_err_msg(c, ret, "setting up new superblock");
goto err_unlock; goto err_unlock;
} }
...@@ -1655,8 +1655,8 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1655,8 +1655,8 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
if (!bch2_dev_exists(c->disk_sb.sb, mi, dev_idx)) if (!bch2_dev_exists(c->disk_sb.sb, mi, dev_idx))
goto have_slot; goto have_slot;
no_slot: no_slot:
bch_err(c, "device add error: already have maximum number of devices");
ret = -BCH_ERR_ENOSPC_sb_members; ret = -BCH_ERR_ENOSPC_sb_members;
bch_err_msg(c, ret, "setting up new superblock");
goto err_unlock; goto err_unlock;
have_slot: have_slot:
...@@ -1666,8 +1666,8 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1666,8 +1666,8 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
mi = bch2_sb_resize_members(&c->disk_sb, u64s); mi = bch2_sb_resize_members(&c->disk_sb, u64s);
if (!mi) { if (!mi) {
bch_err(c, "device add error: no room in superblock for member info");
ret = -BCH_ERR_ENOSPC_sb_members; ret = -BCH_ERR_ENOSPC_sb_members;
bch_err_msg(c, ret, "setting up new superblock");
goto err_unlock; goto err_unlock;
} }
...@@ -1683,7 +1683,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1683,7 +1683,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
if (BCH_MEMBER_GROUP(&dev_mi)) { if (BCH_MEMBER_GROUP(&dev_mi)) {
ret = __bch2_dev_group_set(c, ca, label.buf); ret = __bch2_dev_group_set(c, ca, label.buf);
if (ret) { if (ret) {
bch_err(c, "device add error: error setting label"); bch_err_msg(c, ret, "creating new label");
goto err_unlock; goto err_unlock;
} }
} }
...@@ -1695,13 +1695,13 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1695,13 +1695,13 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
ret = bch2_trans_mark_dev_sb(c, ca); ret = bch2_trans_mark_dev_sb(c, ca);
if (ret) { if (ret) {
bch_err(c, "device add error: error marking new superblock: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "marking new superblock");
goto err_late; goto err_late;
} }
ret = bch2_fs_freespace_init(c); ret = bch2_fs_freespace_init(c);
if (ret) { if (ret) {
bch_err(c, "device add error: error initializing free space: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "initializing free space");
goto err_late; goto err_late;
} }
...@@ -1751,7 +1751,7 @@ int bch2_dev_online(struct bch_fs *c, const char *path) ...@@ -1751,7 +1751,7 @@ int bch2_dev_online(struct bch_fs *c, const char *path)
ret = bch2_dev_in_fs(c->disk_sb.sb, sb.sb); ret = bch2_dev_in_fs(c->disk_sb.sb, sb.sb);
if (ret) { if (ret) {
bch_err(c, "error bringing %s online: %s", path, bch2_err_str(ret)); bch_err_msg(c, ret, "bringing %s online", path);
goto err; goto err;
} }
...@@ -1763,8 +1763,7 @@ int bch2_dev_online(struct bch_fs *c, const char *path) ...@@ -1763,8 +1763,7 @@ int bch2_dev_online(struct bch_fs *c, const char *path)
ret = bch2_trans_mark_dev_sb(c, ca); ret = bch2_trans_mark_dev_sb(c, ca);
if (ret) { if (ret) {
bch_err(c, "error bringing %s online: error from bch2_trans_mark_dev_sb: %s", bch_err_msg(c, ret, "bringing %s online: error from bch2_trans_mark_dev_sb", path);
path, bch2_err_str(ret));
goto err; goto err;
} }
...@@ -1782,7 +1781,7 @@ int bch2_dev_online(struct bch_fs *c, const char *path) ...@@ -1782,7 +1781,7 @@ int bch2_dev_online(struct bch_fs *c, const char *path)
ret = bch2_fs_freespace_init(c); ret = bch2_fs_freespace_init(c);
if (ret) if (ret)
bch_err(c, "device add error: error initializing free space: %s", bch2_err_str(ret)); bch_err_msg(c, ret, "initializing free space");
up_write(&c->state_lock); up_write(&c->state_lock);
return 0; return 0;
...@@ -1837,7 +1836,7 @@ int bch2_dev_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets) ...@@ -1837,7 +1836,7 @@ int bch2_dev_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets)
ret = bch2_dev_buckets_resize(c, ca, nbuckets); ret = bch2_dev_buckets_resize(c, ca, nbuckets);
if (ret) { if (ret) {
bch_err(ca, "Resize error: %s", bch2_err_str(ret)); bch_err_msg(ca, ret, "resizing buckets");
goto err; goto err;
} }
......
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