Commit cf904c8d authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: bch_err_(fn|msg) check if should print

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent e06af207
...@@ -1470,8 +1470,7 @@ int bch2_check_alloc_info(struct bch_fs *c) ...@@ -1470,8 +1470,7 @@ int bch2_check_alloc_info(struct bch_fs *c)
bch2_check_bucket_gens_key(trans, &iter, k)); bch2_check_bucket_gens_key(trans, &iter, k));
err: err:
bch2_trans_put(trans); bch2_trans_put(trans);
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
......
...@@ -393,15 +393,13 @@ int bch2_check_btree_backpointers(struct bch_fs *c) ...@@ -393,15 +393,13 @@ int bch2_check_btree_backpointers(struct bch_fs *c)
{ {
struct btree_iter iter; struct btree_iter iter;
struct bkey_s_c k; struct bkey_s_c k;
int ret;
ret = bch2_trans_run(c, int ret = bch2_trans_run(c,
for_each_btree_key_commit(trans, iter, for_each_btree_key_commit(trans, iter,
BTREE_ID_backpointers, POS_MIN, 0, k, BTREE_ID_backpointers, POS_MIN, 0, k,
NULL, NULL, BCH_TRANS_COMMIT_no_enospc, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
bch2_check_btree_backpointer(trans, &iter, k))); bch2_check_btree_backpointer(trans, &iter, k)));
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -769,8 +767,7 @@ int bch2_check_extents_to_backpointers(struct bch_fs *c) ...@@ -769,8 +767,7 @@ int bch2_check_extents_to_backpointers(struct bch_fs *c)
} }
bch2_trans_put(trans); bch2_trans_put(trans);
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -877,7 +874,6 @@ int bch2_check_backpointers_to_extents(struct bch_fs *c) ...@@ -877,7 +874,6 @@ int bch2_check_backpointers_to_extents(struct bch_fs *c)
} }
bch2_trans_put(trans); bch2_trans_put(trans);
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -315,15 +315,20 @@ do { \ ...@@ -315,15 +315,20 @@ do { \
#define bch_err_inum_offset_ratelimited(c, _inum, _offset, fmt, ...) \ #define bch_err_inum_offset_ratelimited(c, _inum, _offset, fmt, ...) \
bch2_print_ratelimited(c, KERN_ERR bch2_fmt_inum_offset(c, _inum, _offset, fmt), ##__VA_ARGS__) bch2_print_ratelimited(c, KERN_ERR bch2_fmt_inum_offset(c, _inum, _offset, fmt), ##__VA_ARGS__)
static inline bool should_print_err(int err)
{
return err && !bch2_err_matches(err, BCH_ERR_transaction_restart);
}
#define bch_err_fn(_c, _ret) \ #define bch_err_fn(_c, _ret) \
do { \ do { \
if (_ret && !bch2_err_matches(_ret, BCH_ERR_transaction_restart))\ if (should_print_err(_ret)) \
bch_err(_c, "%s(): error %s", __func__, bch2_err_str(_ret));\ bch_err(_c, "%s(): error %s", __func__, bch2_err_str(_ret));\
} while (0) } while (0)
#define bch_err_msg(_c, _ret, _msg, ...) \ #define bch_err_msg(_c, _ret, _msg, ...) \
do { \ do { \
if (_ret && !bch2_err_matches(_ret, BCH_ERR_transaction_restart))\ if (should_print_err(_ret)) \
bch_err(_c, "%s(): error " _msg " %s", __func__, \ bch_err(_c, "%s(): error " _msg " %s", __func__, \
##__VA_ARGS__, bch2_err_str(_ret)); \ ##__VA_ARGS__, bch2_err_str(_ret)); \
} while (0) } while (0)
......
...@@ -414,10 +414,9 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct ...@@ -414,10 +414,9 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct
continue; continue;
} }
if (ret) { bch_err_msg(c, ret, "getting btree node");
bch_err_msg(c, ret, "getting btree node"); if (ret)
break; break;
}
ret = btree_repair_node_boundaries(c, b, prev, cur); ret = btree_repair_node_boundaries(c, b, prev, cur);
...@@ -482,10 +481,9 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct ...@@ -482,10 +481,9 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct
false); false);
ret = PTR_ERR_OR_ZERO(cur); ret = PTR_ERR_OR_ZERO(cur);
if (ret) { bch_err_msg(c, ret, "getting btree node");
bch_err_msg(c, ret, "getting btree node"); if (ret)
goto err; goto err;
}
ret = bch2_btree_repair_topology_recurse(trans, cur); ret = bch2_btree_repair_topology_recurse(trans, cur);
six_unlock_read(&cur->c.lock); six_unlock_read(&cur->c.lock);
...@@ -707,8 +705,8 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id ...@@ -707,8 +705,8 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id
new = kmalloc(bkey_bytes(k->k), GFP_KERNEL); new = kmalloc(bkey_bytes(k->k), GFP_KERNEL);
if (!new) { if (!new) {
bch_err_msg(c, ret, "allocating new key");
ret = -BCH_ERR_ENOMEM_gc_repair_key; ret = -BCH_ERR_ENOMEM_gc_repair_key;
bch_err_msg(c, ret, "allocating new key");
goto err; goto err;
} }
...@@ -834,8 +832,7 @@ static int bch2_gc_mark_key(struct btree_trans *trans, enum btree_id btree_id, ...@@ -834,8 +832,7 @@ static int bch2_gc_mark_key(struct btree_trans *trans, enum btree_id btree_id,
bch2_mark_key(trans, btree_id, level, old, *k, flags)); bch2_mark_key(trans, btree_id, level, old, *k, flags));
fsck_err: fsck_err:
err: err:
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -1068,8 +1065,7 @@ static int bch2_gc_btree_init(struct btree_trans *trans, ...@@ -1068,8 +1065,7 @@ static int bch2_gc_btree_init(struct btree_trans *trans,
fsck_err: fsck_err:
six_unlock_read(&b->c.lock); six_unlock_read(&b->c.lock);
if (ret < 0) bch_err_fn(c, ret);
bch_err_fn(c, ret);
printbuf_exit(&buf); printbuf_exit(&buf);
return ret; return ret;
} }
...@@ -1105,10 +1101,8 @@ static int bch2_gc_btrees(struct bch_fs *c, bool initial, bool metadata_only) ...@@ -1105,10 +1101,8 @@ static int bch2_gc_btrees(struct bch_fs *c, bool initial, bool metadata_only)
: bch2_gc_btree(trans, i, initial, metadata_only); : bch2_gc_btree(trans, i, initial, metadata_only);
} }
if (ret < 0)
bch_err_fn(c, ret);
bch2_trans_put(trans); bch2_trans_put(trans);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -1304,8 +1298,7 @@ static int bch2_gc_done(struct bch_fs *c, ...@@ -1304,8 +1298,7 @@ static int bch2_gc_done(struct bch_fs *c,
fsck_err: fsck_err:
if (ca) if (ca)
percpu_ref_put(&ca->ref); percpu_ref_put(&ca->ref);
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
percpu_up_write(&c->mark_lock); percpu_up_write(&c->mark_lock);
printbuf_exit(&buf); printbuf_exit(&buf);
...@@ -1563,8 +1556,7 @@ static int bch2_gc_alloc_start(struct bch_fs *c, bool metadata_only) ...@@ -1563,8 +1556,7 @@ static int bch2_gc_alloc_start(struct bch_fs *c, bool metadata_only)
})); }));
err: err:
bch2_trans_put(trans); bch2_trans_put(trans);
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -1659,6 +1651,7 @@ static int bch2_gc_reflink_done(struct bch_fs *c, bool metadata_only) ...@@ -1659,6 +1651,7 @@ static int bch2_gc_reflink_done(struct bch_fs *c, bool metadata_only)
c->reflink_gc_nr = 0; c->reflink_gc_nr = 0;
bch2_trans_put(trans); bch2_trans_put(trans);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -1896,9 +1889,7 @@ int bch2_gc(struct bch_fs *c, bool initial, bool metadata_only) ...@@ -1896,9 +1889,7 @@ int bch2_gc(struct bch_fs *c, bool initial, bool metadata_only)
* allocator thread - issue wakeup in case they blocked on gc_lock: * allocator thread - issue wakeup in case they blocked on gc_lock:
*/ */
closure_wake_up(&c->freelist_wait); closure_wake_up(&c->freelist_wait);
bch_err_fn(c, ret);
if (ret)
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -2015,7 +2006,7 @@ int bch2_gc_gens(struct bch_fs *c) ...@@ -2015,7 +2006,7 @@ int bch2_gc_gens(struct bch_fs *c)
NULL, NULL, NULL, NULL,
BCH_TRANS_COMMIT_no_enospc, BCH_TRANS_COMMIT_no_enospc,
gc_btree_gens_key(trans, &iter, k)); gc_btree_gens_key(trans, &iter, k));
if (ret && !bch2_err_matches(ret, EROFS)) if (!bch2_err_matches(ret, EROFS))
bch_err_fn(c, ret); bch_err_fn(c, ret);
if (ret) if (ret)
goto err; goto err;
...@@ -2028,7 +2019,7 @@ int bch2_gc_gens(struct bch_fs *c) ...@@ -2028,7 +2019,7 @@ int bch2_gc_gens(struct bch_fs *c)
NULL, NULL, NULL, NULL,
BCH_TRANS_COMMIT_no_enospc, BCH_TRANS_COMMIT_no_enospc,
bch2_alloc_write_oldest_gen(trans, &iter, k)); bch2_alloc_write_oldest_gen(trans, &iter, k));
if (ret && !bch2_err_matches(ret, EROFS)) if (!bch2_err_matches(ret, EROFS))
bch_err_fn(c, ret); bch_err_fn(c, ret);
if (ret) if (ret)
goto err; goto err;
...@@ -2058,7 +2049,6 @@ static int bch2_gc_thread(void *arg) ...@@ -2058,7 +2049,6 @@ static int bch2_gc_thread(void *arg)
struct io_clock *clock = &c->io_clock[WRITE]; struct io_clock *clock = &c->io_clock[WRITE];
unsigned long last = atomic64_read(&clock->now); unsigned long last = atomic64_read(&clock->now);
unsigned last_kick = atomic_read(&c->kick_gc); unsigned last_kick = atomic_read(&c->kick_gc);
int ret;
set_freezable(); set_freezable();
...@@ -2098,11 +2088,8 @@ static int bch2_gc_thread(void *arg) ...@@ -2098,11 +2088,8 @@ static int bch2_gc_thread(void *arg)
#if 0 #if 0
ret = bch2_gc(c, false, false); ret = bch2_gc(c, false, false);
#else #else
ret = bch2_gc_gens(c); bch2_gc_gens(c);
#endif #endif
if (ret < 0)
bch_err_fn(c, ret);
debug_check_no_locks_held(); debug_check_no_locks_held();
} }
......
...@@ -2054,8 +2054,7 @@ static void async_btree_node_rewrite_work(struct work_struct *work) ...@@ -2054,8 +2054,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) bch_err_fn(c, 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);
} }
...@@ -2093,8 +2092,8 @@ void bch2_btree_node_rewrite_async(struct bch_fs *c, struct btree *b) ...@@ -2093,8 +2092,8 @@ 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);
bch_err_msg(c, ret, "going read-write");
if (ret) { if (ret) {
bch_err_msg(c, ret, "going read-write");
kfree(a); kfree(a);
return; return;
} }
......
...@@ -1760,8 +1760,7 @@ int bch2_trans_mark_dev_sb(struct bch_fs *c, struct bch_dev *ca) ...@@ -1760,8 +1760,7 @@ int bch2_trans_mark_dev_sb(struct bch_fs *c, struct bch_dev *ca)
{ {
int ret = bch2_trans_run(c, __bch2_trans_mark_dev_sb(trans, ca)); int ret = bch2_trans_run(c, __bch2_trans_mark_dev_sb(trans, ca));
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
......
...@@ -791,28 +791,22 @@ static void ec_stripe_delete_work(struct work_struct *work) ...@@ -791,28 +791,22 @@ static void ec_stripe_delete_work(struct work_struct *work)
{ {
struct bch_fs *c = struct bch_fs *c =
container_of(work, struct bch_fs, ec_stripe_delete_work); container_of(work, struct bch_fs, ec_stripe_delete_work);
struct btree_trans *trans = bch2_trans_get(c);
int ret;
u64 idx;
while (1) { while (1) {
mutex_lock(&c->ec_stripes_heap_lock); mutex_lock(&c->ec_stripes_heap_lock);
idx = stripe_idx_to_delete(c); u64 idx = stripe_idx_to_delete(c);
mutex_unlock(&c->ec_stripes_heap_lock); mutex_unlock(&c->ec_stripes_heap_lock);
if (!idx) if (!idx)
break; break;
ret = commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc, int ret = bch2_trans_do(c, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
ec_stripe_delete(trans, idx)); ec_stripe_delete(trans, idx));
if (ret) { bch_err_fn(c, ret);
bch_err_fn(c, ret); if (ret)
break; break;
}
} }
bch2_trans_put(trans);
bch2_write_ref_put(c, BCH_WRITE_REF_stripe_delete); bch2_write_ref_put(c, BCH_WRITE_REF_stripe_delete);
} }
...@@ -1126,16 +1120,15 @@ static void ec_stripe_create(struct ec_stripe_new *s) ...@@ -1126,16 +1120,15 @@ static void ec_stripe_create(struct ec_stripe_new *s)
ec_stripe_key_update(trans, ec_stripe_key_update(trans,
bkey_i_to_stripe(&s->new_stripe.key), bkey_i_to_stripe(&s->new_stripe.key),
!s->have_existing_stripe)); !s->have_existing_stripe));
bch_err_msg(c, ret, "creating stripe key");
if (ret) { if (ret) {
bch_err(c, "error creating stripe: error creating stripe key");
goto err; goto err;
} }
ret = ec_stripe_update_extents(c, &s->new_stripe); ret = ec_stripe_update_extents(c, &s->new_stripe);
if (ret) { bch_err_msg(c, ret, "error updating extents");
bch_err_msg(c, ret, "creating stripe: error updating pointers"); if (ret)
goto err; goto err;
}
err: err:
bch2_disk_reservation_put(c, &s->res); bch2_disk_reservation_put(c, &s->res);
...@@ -1865,7 +1858,6 @@ int bch2_stripes_read(struct bch_fs *c) ...@@ -1865,7 +1858,6 @@ int bch2_stripes_read(struct bch_fs *c)
bch2_stripes_heap_insert(c, m, k.k->p.offset); bch2_stripes_heap_insert(c, m, k.k->p.offset);
0; 0;
}))); })));
bch_err_fn(c, ret); bch_err_fn(c, ret);
return ret; return ret;
} }
......
...@@ -1012,15 +1012,13 @@ static int bch2_vfs_readdir(struct file *file, struct dir_context *ctx) ...@@ -1012,15 +1012,13 @@ static int bch2_vfs_readdir(struct file *file, struct dir_context *ctx)
{ {
struct bch_inode_info *inode = file_bch_inode(file); struct bch_inode_info *inode = file_bch_inode(file);
struct bch_fs *c = inode->v.i_sb->s_fs_info; struct bch_fs *c = inode->v.i_sb->s_fs_info;
int ret;
if (!dir_emit_dots(file, ctx)) if (!dir_emit_dots(file, ctx))
return 0; return 0;
ret = bch2_readdir(c, inode_inum(inode), ctx); int ret = bch2_readdir(c, inode_inum(inode), ctx);
if (ret)
bch_err_fn(c, ret);
bch_err_fn(c, ret);
return bch2_err_class(ret); return bch2_err_class(ret);
} }
...@@ -1944,10 +1942,9 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, ...@@ -1944,10 +1942,9 @@ 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) { bch_err_msg(c, ret, "mounting: error getting root inode");
bch_err_msg(c, ret, "mounting: error getting root inode"); if (ret)
goto err_put_super; goto err_put_super;
}
sb->s_root = d_make_root(vinode); sb->s_root = d_make_root(vinode);
if (!sb->s_root) { if (!sb->s_root) {
......
...@@ -209,8 +209,7 @@ static int fsck_write_inode(struct btree_trans *trans, ...@@ -209,8 +209,7 @@ static int fsck_write_inode(struct btree_trans *trans,
{ {
int ret = commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc, int ret = commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
__write_inode(trans, inode, snapshot)); __write_inode(trans, inode, snapshot));
if (ret) bch_err_fn(trans->c, ret);
bch_err_fn(trans->c, ret);
return ret; return ret;
} }
...@@ -2427,7 +2426,6 @@ static int fix_reflink_p_key(struct btree_trans *trans, struct btree_iter *iter, ...@@ -2427,7 +2426,6 @@ static int fix_reflink_p_key(struct btree_trans *trans, struct btree_iter *iter,
{ {
struct bkey_s_c_reflink_p p; struct bkey_s_c_reflink_p p;
struct bkey_i_reflink_p *u; struct bkey_i_reflink_p *u;
int ret;
if (k.k->type != KEY_TYPE_reflink_p) if (k.k->type != KEY_TYPE_reflink_p)
return 0; return 0;
...@@ -2438,7 +2436,7 @@ static int fix_reflink_p_key(struct btree_trans *trans, struct btree_iter *iter, ...@@ -2438,7 +2436,7 @@ static int fix_reflink_p_key(struct btree_trans *trans, struct btree_iter *iter,
return 0; return 0;
u = bch2_trans_kmalloc(trans, sizeof(*u)); u = bch2_trans_kmalloc(trans, sizeof(*u));
ret = PTR_ERR_OR_ZERO(u); int ret = PTR_ERR_OR_ZERO(u);
if (ret) if (ret)
return ret; return ret;
......
...@@ -1200,6 +1200,6 @@ int bch2_delete_dead_inodes(struct bch_fs *c) ...@@ -1200,6 +1200,6 @@ int bch2_delete_dead_inodes(struct bch_fs *c)
} }
err: err:
bch2_trans_put(trans); bch2_trans_put(trans);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -993,8 +993,7 @@ int bch2_set_nr_journal_buckets(struct bch_fs *c, struct bch_dev *ca, ...@@ -993,8 +993,7 @@ int bch2_set_nr_journal_buckets(struct bch_fs *c, struct bch_dev *ca,
break; break;
} }
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
unlock: unlock:
up_write(&c->state_lock); up_write(&c->state_lock);
return ret; return ret;
...@@ -1024,8 +1023,7 @@ int bch2_dev_journal_alloc(struct bch_dev *ca) ...@@ -1024,8 +1023,7 @@ int bch2_dev_journal_alloc(struct bch_dev *ca)
ret = __bch2_set_nr_journal_buckets(ca, nr, true, NULL); ret = __bch2_set_nr_journal_buckets(ca, nr, true, NULL);
err: err:
if (ret) bch_err_fn(ca, ret);
bch_err_fn(ca, ret);
return ret; return ret;
} }
......
...@@ -793,10 +793,9 @@ int bch2_journal_reclaim_start(struct journal *j) ...@@ -793,10 +793,9 @@ int bch2_journal_reclaim_start(struct journal *j)
p = kthread_create(bch2_journal_reclaim_thread, j, p = kthread_create(bch2_journal_reclaim_thread, 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) { bch_err_msg(c, ret, "creating journal reclaim thread");
bch_err_msg(c, ret, "creating journal reclaim thread"); if (ret)
return ret; return ret;
}
get_task_struct(p); get_task_struct(p);
j->reclaim_thread = p; j->reclaim_thread = p;
......
...@@ -63,8 +63,7 @@ int bch2_resume_logged_ops(struct bch_fs *c) ...@@ -63,8 +63,7 @@ int bch2_resume_logged_ops(struct bch_fs *c)
BTREE_ID_logged_ops, POS_MIN, BTREE_ID_logged_ops, POS_MIN,
BTREE_ITER_PREFETCH, k, BTREE_ITER_PREFETCH, k,
resume_logged_op(trans, &iter, k))); resume_logged_op(trans, &iter, k)));
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
......
...@@ -157,8 +157,7 @@ int bch2_check_lrus(struct bch_fs *c) ...@@ -157,8 +157,7 @@ int bch2_check_lrus(struct bch_fs *c)
BTREE_ID_lru, POS_MIN, BTREE_ITER_PREFETCH, k, BTREE_ID_lru, POS_MIN, BTREE_ITER_PREFETCH, k,
NULL, NULL, BCH_TRANS_COMMIT_no_enospc|BCH_TRANS_COMMIT_lazy_rw, NULL, NULL, BCH_TRANS_COMMIT_no_enospc|BCH_TRANS_COMMIT_lazy_rw,
bch2_check_lru_key(trans, &iter, k, &last_flushed_pos))); bch2_check_lru_key(trans, &iter, k, &last_flushed_pos)));
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -145,10 +145,9 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags) ...@@ -145,10 +145,9 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags)
continue; continue;
} }
if (ret) { bch_err_msg(c, ret, "updating btree node key");
bch_err_msg(c, ret, "updating btree node key"); if (ret)
break; break;
}
next: next:
bch2_btree_iter_next_node(&iter); bch2_btree_iter_next_node(&iter);
} }
......
...@@ -669,10 +669,9 @@ int bch2_evacuate_bucket(struct moving_context *ctxt, ...@@ -669,10 +669,9 @@ int bch2_evacuate_bucket(struct moving_context *ctxt,
bkey_err(k = bch2_btree_iter_peek_slot(&iter))); bkey_err(k = bch2_btree_iter_peek_slot(&iter)));
bch2_trans_iter_exit(trans, &iter); bch2_trans_iter_exit(trans, &iter);
if (ret) { bch_err_msg(c, ret, "looking up alloc key");
bch_err_msg(c, ret, "looking up alloc key"); if (ret)
goto err; goto err;
}
a = bch2_alloc_to_v4(k, &a_convert); a = bch2_alloc_to_v4(k, &a_convert);
dirty_sectors = bch2_bucket_sectors_dirty(*a); dirty_sectors = bch2_bucket_sectors_dirty(*a);
......
...@@ -324,9 +324,9 @@ static int bch2_copygc_thread(void *arg) ...@@ -324,9 +324,9 @@ static int bch2_copygc_thread(void *arg)
if (!buckets) if (!buckets)
return -ENOMEM; return -ENOMEM;
ret = rhashtable_init(&buckets->table, &bch_move_bucket_params); ret = rhashtable_init(&buckets->table, &bch_move_bucket_params);
bch_err_msg(c, ret, "allocating copygc buckets in flight");
if (ret) { if (ret) {
kfree(buckets); kfree(buckets);
bch_err_msg(c, ret, "allocating copygc buckets in flight");
return ret; return ret;
} }
...@@ -423,10 +423,9 @@ int bch2_copygc_start(struct bch_fs *c) ...@@ -423,10 +423,9 @@ 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) { bch_err_msg(c, ret, "creating copygc thread");
bch_err_msg(c, ret, "creating copygc thread"); if (ret)
return ret; return ret;
}
get_task_struct(t); get_task_struct(t);
......
...@@ -626,8 +626,7 @@ int bch2_fs_quota_read(struct bch_fs *c) ...@@ -626,8 +626,7 @@ int bch2_fs_quota_read(struct bch_fs *c)
bch2_trans_put(trans); bch2_trans_put(trans);
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
......
...@@ -470,10 +470,9 @@ int bch2_rebalance_start(struct bch_fs *c) ...@@ -470,10 +470,9 @@ 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) { bch_err_msg(c, ret, "creating rebalance thread");
bch_err_msg(c, ret, "creating rebalance thread"); if (ret)
return ret; return ret;
}
get_task_struct(p); get_task_struct(p);
rcu_assign_pointer(c->rebalance.thread, p); rcu_assign_pointer(c->rebalance.thread, p);
......
...@@ -463,8 +463,7 @@ static int bch2_initialize_subvolumes(struct bch_fs *c) ...@@ -463,8 +463,7 @@ static int bch2_initialize_subvolumes(struct bch_fs *c)
ret = bch2_btree_insert(c, BTREE_ID_snapshot_trees, &root_tree.k_i, NULL, 0) ?: ret = bch2_btree_insert(c, BTREE_ID_snapshot_trees, &root_tree.k_i, NULL, 0) ?:
bch2_btree_insert(c, BTREE_ID_snapshots, &root_snapshot.k_i, NULL, 0) ?: bch2_btree_insert(c, BTREE_ID_snapshots, &root_snapshot.k_i, NULL, 0) ?:
bch2_btree_insert(c, BTREE_ID_subvolumes, &root_volume.k_i, NULL, 0); bch2_btree_insert(c, BTREE_ID_subvolumes, &root_volume.k_i, NULL, 0);
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -504,8 +503,7 @@ static int bch2_fs_upgrade_for_subvolumes(struct bch_fs *c) ...@@ -504,8 +503,7 @@ static int bch2_fs_upgrade_for_subvolumes(struct bch_fs *c)
{ {
int ret = bch2_trans_do(c, NULL, NULL, BCH_TRANS_COMMIT_lazy_rw, int ret = bch2_trans_do(c, NULL, NULL, BCH_TRANS_COMMIT_lazy_rw,
__bch2_fs_upgrade_for_subvolumes(trans)); __bch2_fs_upgrade_for_subvolumes(trans));
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -1087,8 +1085,7 @@ int bch2_fs_recovery(struct bch_fs *c) ...@@ -1087,8 +1085,7 @@ int bch2_fs_recovery(struct bch_fs *c)
bch2_delete_dead_snapshots_async(c); bch2_delete_dead_snapshots_async(c);
} }
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
err: err:
fsck_err: fsck_err:
...@@ -1179,10 +1176,9 @@ int bch2_fs_initialize(struct bch_fs *c) ...@@ -1179,10 +1176,9 @@ int bch2_fs_initialize(struct bch_fs *c)
packed_inode.inode.k.p.snapshot = U32_MAX; packed_inode.inode.k.p.snapshot = U32_MAX;
ret = bch2_btree_insert(c, BTREE_ID_inodes, &packed_inode.inode.k_i, NULL, 0); ret = bch2_btree_insert(c, BTREE_ID_inodes, &packed_inode.inode.k_i, NULL, 0);
if (ret) { bch_err_msg(c, ret, "creating root directory");
bch_err_msg(c, ret, "creating root directory"); if (ret)
goto err; goto err;
}
bch2_inode_init_early(c, &lostfound_inode); bch2_inode_init_early(c, &lostfound_inode);
...@@ -1193,10 +1189,9 @@ int bch2_fs_initialize(struct bch_fs *c) ...@@ -1193,10 +1189,9 @@ int bch2_fs_initialize(struct bch_fs *c)
&lostfound, &lostfound,
0, 0, S_IFDIR|0700, 0, 0, 0, S_IFDIR|0700, 0,
NULL, NULL, (subvol_inum) { 0 }, 0)); NULL, NULL, (subvol_inum) { 0 }, 0));
if (ret) { bch_err_msg(c, ret, "creating lost+found");
bch_err_msg(c, ret, "creating lost+found"); if (ret)
goto err; goto err;
}
c->recovery_pass_done = ARRAY_SIZE(recovery_pass_fns) - 1; c->recovery_pass_done = ARRAY_SIZE(recovery_pass_fns) - 1;
...@@ -1207,10 +1202,9 @@ int bch2_fs_initialize(struct bch_fs *c) ...@@ -1207,10 +1202,9 @@ int bch2_fs_initialize(struct bch_fs *c)
} }
ret = bch2_journal_flush(&c->journal); ret = bch2_journal_flush(&c->journal);
if (ret) { bch_err_msg(c, ret, "writing first journal entry");
bch_err_msg(c, ret, "writing first journal entry"); if (ret)
goto err; goto err;
}
mutex_lock(&c->sb_lock); mutex_lock(&c->sb_lock);
SET_BCH_SB_INITIALIZED(c->disk_sb.sb, true); SET_BCH_SB_INITIALIZED(c->disk_sb.sb, true);
......
...@@ -459,7 +459,6 @@ static int bch2_snapshot_tree_master_subvol(struct btree_trans *trans, ...@@ -459,7 +459,6 @@ static int bch2_snapshot_tree_master_subvol(struct btree_trans *trans,
struct bch_fs *c = trans->c; struct bch_fs *c = trans->c;
struct btree_iter iter; struct btree_iter iter;
struct bkey_s_c k; struct bkey_s_c k;
struct bkey_s_c_subvolume s;
bool found = false; bool found = false;
int ret; int ret;
...@@ -468,7 +467,7 @@ static int bch2_snapshot_tree_master_subvol(struct btree_trans *trans, ...@@ -468,7 +467,7 @@ static int bch2_snapshot_tree_master_subvol(struct btree_trans *trans,
if (k.k->type != KEY_TYPE_subvolume) if (k.k->type != KEY_TYPE_subvolume)
continue; continue;
s = bkey_s_c_to_subvolume(k); struct bkey_s_c_subvolume s = bkey_s_c_to_subvolume(k);
if (!bch2_snapshot_is_ancestor(c, le32_to_cpu(s.v->snapshot), snapshot_root)) if (!bch2_snapshot_is_ancestor(c, le32_to_cpu(s.v->snapshot), snapshot_root))
continue; continue;
if (!BCH_SUBVOLUME_SNAP(s.v)) { if (!BCH_SUBVOLUME_SNAP(s.v)) {
...@@ -592,9 +591,7 @@ int bch2_check_snapshot_trees(struct bch_fs *c) ...@@ -592,9 +591,7 @@ int bch2_check_snapshot_trees(struct bch_fs *c)
BTREE_ITER_PREFETCH, k, BTREE_ITER_PREFETCH, k,
NULL, NULL, BCH_TRANS_COMMIT_no_enospc, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
check_snapshot_tree(trans, &iter, k))); check_snapshot_tree(trans, &iter, k)));
bch_err_fn(c, ret);
if (ret)
bch_err(c, "error %i checking snapshot trees", ret);
return ret; return ret;
} }
...@@ -866,12 +863,11 @@ int bch2_check_snapshots(struct bch_fs *c) ...@@ -866,12 +863,11 @@ int bch2_check_snapshots(struct bch_fs *c)
*/ */
ret = bch2_trans_run(c, ret = bch2_trans_run(c,
for_each_btree_key_reverse_commit(trans, iter, for_each_btree_key_reverse_commit(trans, iter,
BTREE_ID_snapshots, POS_MAX, BTREE_ID_snapshots, POS_MAX,
BTREE_ITER_PREFETCH, k, BTREE_ITER_PREFETCH, k,
NULL, NULL, BCH_TRANS_COMMIT_no_enospc, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
check_snapshot(trans, &iter, k))); check_snapshot(trans, &iter, k)));
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -1381,10 +1377,9 @@ int bch2_delete_dead_snapshots(struct bch_fs *c) ...@@ -1381,10 +1377,9 @@ 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) { bch_err_msg(c, ret, "deleting dead snapshots: error going rw");
bch_err_msg(c, ret, "deleting dead snapshots: error going rw"); if (ret)
return ret; return ret;
}
} }
trans = bch2_trans_get(c); trans = bch2_trans_get(c);
...@@ -1397,18 +1392,16 @@ int bch2_delete_dead_snapshots(struct bch_fs *c) ...@@ -1397,18 +1392,16 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
POS_MIN, 0, k, POS_MIN, 0, k,
NULL, NULL, 0, NULL, NULL, 0,
bch2_delete_redundant_snapshot(trans, k)); bch2_delete_redundant_snapshot(trans, k));
if (ret) { bch_err_msg(c, ret, "deleting redundant snapshots");
bch_err_msg(c, ret, "deleting redundant snapshots"); if (ret)
goto err; goto err;
}
ret = for_each_btree_key(trans, iter, BTREE_ID_snapshots, ret = for_each_btree_key(trans, iter, BTREE_ID_snapshots,
POS_MIN, 0, k, POS_MIN, 0, k,
bch2_snapshot_set_equiv(trans, k)); bch2_snapshot_set_equiv(trans, k));
if (ret) { bch_err_msg(c, ret, "in bch2_snapshots_set_equiv");
bch_err_msg(c, ret, "in bch2_snapshots_set_equiv"); if (ret)
goto err; goto err;
}
ret = for_each_btree_key(trans, iter, BTREE_ID_snapshots, ret = for_each_btree_key(trans, iter, BTREE_ID_snapshots,
POS_MIN, 0, k, ({ POS_MIN, 0, k, ({
...@@ -1420,11 +1413,9 @@ int bch2_delete_dead_snapshots(struct bch_fs *c) ...@@ -1420,11 +1413,9 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
? snapshot_list_add(c, &deleted, k.k->p.offset) ? snapshot_list_add(c, &deleted, k.k->p.offset)
: 0; : 0;
})); }));
bch_err_msg(c, ret, "walking snapshots");
if (ret) { if (ret)
bch_err_msg(c, ret, "walking snapshots");
goto err; goto err;
}
for (id = 0; id < BTREE_ID_NR; id++) { for (id = 0; id < BTREE_ID_NR; id++) {
struct bpos last_pos = POS_MIN; struct bpos last_pos = POS_MIN;
...@@ -1457,10 +1448,9 @@ int bch2_delete_dead_snapshots(struct bch_fs *c) ...@@ -1457,10 +1448,9 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
bch2_disk_reservation_put(c, &res); bch2_disk_reservation_put(c, &res);
darray_exit(&equiv_seen); darray_exit(&equiv_seen);
if (ret) { bch_err_msg(c, ret, "deleting keys from dying snapshots");
bch_err_msg(c, ret, "deleting keys from dying snapshots"); if (ret)
goto err; goto err;
}
} }
bch2_trans_unlock(trans); bch2_trans_unlock(trans);
...@@ -1476,10 +1466,9 @@ int bch2_delete_dead_snapshots(struct bch_fs *c) ...@@ -1476,10 +1466,9 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
: 0; : 0;
})); }));
if (ret) { bch_err_msg(c, ret, "walking snapshots");
bch_err_msg(c, ret, "walking snapshots"); if (ret)
goto err_create_lock; goto err_create_lock;
}
/* /*
* Fixing children of deleted snapshots can't be done completely * Fixing children of deleted snapshots can't be done completely
...@@ -1496,19 +1485,17 @@ int bch2_delete_dead_snapshots(struct bch_fs *c) ...@@ -1496,19 +1485,17 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
darray_for_each(deleted, i) { darray_for_each(deleted, i) {
ret = commit_do(trans, NULL, NULL, 0, ret = commit_do(trans, NULL, NULL, 0,
bch2_snapshot_node_delete(trans, *i)); bch2_snapshot_node_delete(trans, *i));
if (ret) { bch_err_msg(c, ret, "deleting snapshot %u", *i);
bch_err_msg(c, ret, "deleting snapshot %u", *i); if (ret)
goto err_create_lock; goto err_create_lock;
}
} }
darray_for_each(deleted_interior, i) { darray_for_each(deleted_interior, i) {
ret = commit_do(trans, NULL, NULL, 0, ret = commit_do(trans, NULL, NULL, 0,
bch2_snapshot_node_delete(trans, *i)); bch2_snapshot_node_delete(trans, *i));
if (ret) { bch_err_msg(c, ret, "deleting snapshot %u", *i);
bch_err_msg(c, ret, "deleting snapshot %u", *i); if (ret)
goto err_create_lock; goto err_create_lock;
}
} }
err_create_lock: err_create_lock:
up_write(&c->snapshot_create_lock); up_write(&c->snapshot_create_lock);
...@@ -1516,8 +1503,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c) ...@@ -1516,8 +1503,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
darray_exit(&deleted_interior); darray_exit(&deleted_interior);
darray_exit(&deleted); darray_exit(&deleted);
bch2_trans_put(trans); bch2_trans_put(trans);
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -1701,8 +1687,7 @@ int bch2_snapshots_read(struct bch_fs *c) ...@@ -1701,8 +1687,7 @@ int bch2_snapshots_read(struct bch_fs *c)
for_each_btree_key(trans, iter, BTREE_ID_snapshots, for_each_btree_key(trans, iter, BTREE_ID_snapshots,
POS_MIN, 0, k, POS_MIN, 0, k,
(set_is_ancestor_bitmap(c, k.k->p.offset), 0))); (set_is_ancestor_bitmap(c, k.k->p.offset), 0)));
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
......
...@@ -38,8 +38,7 @@ static int check_subvol(struct btree_trans *trans, ...@@ -38,8 +38,7 @@ static int check_subvol(struct btree_trans *trans,
if (BCH_SUBVOLUME_UNLINKED(subvol.v)) { if (BCH_SUBVOLUME_UNLINKED(subvol.v)) {
ret = bch2_subvolume_delete(trans, iter->pos.offset); ret = bch2_subvolume_delete(trans, iter->pos.offset);
if (ret) bch_err_msg(c, ret, "deleting subvolume %llu", iter->pos.offset);
bch_err_msg(c, ret, "deleting subvolume %llu", iter->pos.offset);
return ret ?: -BCH_ERR_transaction_restart_nested; return ret ?: -BCH_ERR_transaction_restart_nested;
} }
...@@ -86,11 +85,10 @@ int bch2_check_subvols(struct bch_fs *c) ...@@ -86,11 +85,10 @@ int bch2_check_subvols(struct bch_fs *c)
ret = bch2_trans_run(c, ret = bch2_trans_run(c,
for_each_btree_key_commit(trans, iter, for_each_btree_key_commit(trans, iter,
BTREE_ID_subvolumes, POS_MIN, BTREE_ITER_PREFETCH, k, BTREE_ID_subvolumes, POS_MIN, BTREE_ITER_PREFETCH, k,
NULL, NULL, BCH_TRANS_COMMIT_no_enospc, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
check_subvol(trans, &iter, k))); check_subvol(trans, &iter, k)));
if (ret) bch_err_fn(c, ret);
bch_err_fn(c, ret);
return ret; return ret;
} }
...@@ -297,10 +295,9 @@ static void bch2_subvolume_wait_for_pagecache_and_delete(struct work_struct *wor ...@@ -297,10 +295,9 @@ 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) { bch_err_msg(c, ret, "deleting subvolume %u", *id);
bch_err_msg(c, ret, "deleting subvolume %u", *id); if (ret)
break; break;
}
} }
darray_exit(&s); darray_exit(&s);
......
...@@ -1522,9 +1522,7 @@ static int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca) ...@@ -1522,9 +1522,7 @@ static int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
BTREE_TRIGGER_NORUN, NULL) ?: BTREE_TRIGGER_NORUN, NULL) ?:
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) bch_err_msg(c, ret, "removing dev alloc info");
bch_err_msg(c, ret, "removing dev alloc info");
return ret; return ret;
} }
...@@ -1551,34 +1549,29 @@ int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags) ...@@ -1551,34 +1549,29 @@ int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags)
__bch2_dev_read_only(c, ca); __bch2_dev_read_only(c, ca);
ret = bch2_dev_data_drop(c, ca->dev_idx, flags); ret = bch2_dev_data_drop(c, ca->dev_idx, flags);
if (ret) { bch_err_msg(ca, ret, "dropping data");
bch_err_msg(ca, ret, "dropping data"); if (ret)
goto err; goto err;
}
ret = bch2_dev_remove_alloc(c, ca); ret = bch2_dev_remove_alloc(c, ca);
if (ret) { bch_err_msg(ca, ret, "deleting alloc info");
bch_err_msg(ca, ret, "deleting alloc info"); if (ret)
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) { bch_err_msg(ca, ret, "flushing journal");
bch_err_msg(ca, ret, "flushing journal"); if (ret)
goto err; goto err;
}
ret = bch2_journal_flush(&c->journal); ret = bch2_journal_flush(&c->journal);
if (ret) { bch_err(ca, "journal error");
bch_err(ca, "journal error"); if (ret)
goto err; goto err;
}
ret = bch2_replicas_gc2(c); ret = bch2_replicas_gc2(c);
if (ret) { bch_err_msg(ca, ret, "in replicas_gc2()");
bch_err_msg(ca, ret, "in replicas_gc2()"); if (ret)
goto err; goto err;
}
data = bch2_dev_has_data(c, ca); data = bch2_dev_has_data(c, ca);
if (data) { if (data) {
...@@ -1650,10 +1643,9 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1650,10 +1643,9 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
int ret; int ret;
ret = bch2_read_super(path, &opts, &sb); ret = bch2_read_super(path, &opts, &sb);
if (ret) { bch_err_msg(c, ret, "reading super");
bch_err_msg(c, ret, "reading super"); if (ret)
goto err; goto err;
}
dev_mi = bch2_sb_member_get(sb.sb, sb.sb->dev_idx); dev_mi = bch2_sb_member_get(sb.sb, sb.sb->dev_idx);
...@@ -1666,10 +1658,8 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1666,10 +1658,8 @@ 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_fn(c, ret);
goto err; goto err;
}
ca = __bch2_dev_alloc(c, &dev_mi); ca = __bch2_dev_alloc(c, &dev_mi);
if (!ca) { if (!ca) {
...@@ -1684,19 +1674,17 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1684,19 +1674,17 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
goto err; goto err;
ret = bch2_dev_journal_alloc(ca); ret = bch2_dev_journal_alloc(ca);
if (ret) { bch_err_msg(c, ret, "allocating journal");
bch_err_msg(c, ret, "allocating journal"); if (ret)
goto err; goto err;
}
down_write(&c->state_lock); down_write(&c->state_lock);
mutex_lock(&c->sb_lock); mutex_lock(&c->sb_lock);
ret = bch2_sb_from_fs(c, ca); ret = bch2_sb_from_fs(c, ca);
if (ret) { bch_err_msg(c, ret, "setting up new superblock");
bch_err_msg(c, ret, "setting up new superblock"); if (ret)
goto err_unlock; goto err_unlock;
}
if (dynamic_fault("bcachefs:add:no_slot")) if (dynamic_fault("bcachefs:add:no_slot"))
goto no_slot; goto no_slot;
...@@ -1735,10 +1723,9 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1735,10 +1723,9 @@ 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) { bch_err_msg(c, ret, "creating new label");
bch_err_msg(c, ret, "creating new label"); if (ret)
goto err_unlock; goto err_unlock;
}
} }
bch2_write_super(c); bch2_write_super(c);
...@@ -1747,16 +1734,14 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1747,16 +1734,14 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
bch2_dev_usage_journal_reserve(c); bch2_dev_usage_journal_reserve(c);
ret = bch2_trans_mark_dev_sb(c, ca); ret = bch2_trans_mark_dev_sb(c, ca);
if (ret) { bch_err_msg(ca, ret, "marking new superblock");
bch_err_msg(ca, ret, "marking new superblock"); if (ret)
goto err_late; goto err_late;
}
ret = bch2_fs_freespace_init(c); ret = bch2_fs_freespace_init(c);
if (ret) { bch_err_msg(ca, ret, "initializing free space");
bch_err_msg(ca, ret, "initializing free space"); if (ret)
goto err_late; goto err_late;
}
ca->new_fs_bucket_idx = 0; ca->new_fs_bucket_idx = 0;
...@@ -1775,6 +1760,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path) ...@@ -1775,6 +1760,7 @@ int bch2_dev_add(struct bch_fs *c, const char *path)
bch2_free_super(&sb); bch2_free_super(&sb);
printbuf_exit(&label); printbuf_exit(&label);
printbuf_exit(&errbuf); printbuf_exit(&errbuf);
bch_err_fn(c, ret);
return ret; return ret;
err_late: err_late:
up_write(&c->state_lock); up_write(&c->state_lock);
...@@ -1802,10 +1788,9 @@ int bch2_dev_online(struct bch_fs *c, const char *path) ...@@ -1802,10 +1788,9 @@ int bch2_dev_online(struct bch_fs *c, const char *path)
dev_idx = sb.sb->dev_idx; dev_idx = sb.sb->dev_idx;
ret = bch2_dev_in_fs(c->disk_sb.sb, sb.sb); ret = bch2_dev_in_fs(c->disk_sb.sb, sb.sb);
if (ret) { bch_err_msg(c, ret, "bringing %s online", path);
bch_err_msg(c, ret, "bringing %s online", path); if (ret)
goto err; goto err;
}
ret = bch2_dev_attach_bdev(c, &sb); ret = bch2_dev_attach_bdev(c, &sb);
if (ret) if (ret)
...@@ -1814,10 +1799,9 @@ int bch2_dev_online(struct bch_fs *c, const char *path) ...@@ -1814,10 +1799,9 @@ int bch2_dev_online(struct bch_fs *c, const char *path)
ca = bch_dev_locked(c, dev_idx); ca = bch_dev_locked(c, dev_idx);
ret = bch2_trans_mark_dev_sb(c, ca); ret = bch2_trans_mark_dev_sb(c, ca);
if (ret) { bch_err_msg(c, ret, "bringing %s online: error from bch2_trans_mark_dev_sb", path);
bch_err_msg(c, ret, "bringing %s online: error from bch2_trans_mark_dev_sb", path); if (ret)
goto err; goto err;
}
if (ca->mi.state == BCH_MEMBER_STATE_rw) if (ca->mi.state == BCH_MEMBER_STATE_rw)
__bch2_dev_read_write(c, ca); __bch2_dev_read_write(c, ca);
...@@ -1896,10 +1880,9 @@ int bch2_dev_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets) ...@@ -1896,10 +1880,9 @@ 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) { bch_err_msg(ca, ret, "resizing buckets");
bch_err_msg(ca, ret, "resizing buckets"); if (ret)
goto err; goto err;
}
ret = bch2_trans_mark_dev_sb(c, ca); ret = bch2_trans_mark_dev_sb(c, ca);
if (ret) if (ret)
......
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