Commit dab9ef0d authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Add error message for some allocation failures

Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 8042b5b7
...@@ -1387,8 +1387,11 @@ int bch2_dev_allocator_start(struct bch_dev *ca) ...@@ -1387,8 +1387,11 @@ int bch2_dev_allocator_start(struct bch_dev *ca)
p = kthread_create(bch2_allocator_thread, ca, p = kthread_create(bch2_allocator_thread, ca,
"bch-alloc/%s", ca->name); "bch-alloc/%s", ca->name);
if (IS_ERR(p)) if (IS_ERR(p)) {
bch_err(ca->fs, "error creating allocator thread: %li",
PTR_ERR(p));
return PTR_ERR(p); return PTR_ERR(p);
}
get_task_struct(p); get_task_struct(p);
rcu_assign_pointer(ca->alloc_thread, p); rcu_assign_pointer(ca->alloc_thread, p);
......
...@@ -115,8 +115,10 @@ static int bch2_gc_check_topology(struct bch_fs *c, ...@@ -115,8 +115,10 @@ static int bch2_gc_check_topology(struct bch_fs *c,
} }
new = kmalloc(bkey_bytes(&cur.k->k), GFP_KERNEL); new = kmalloc(bkey_bytes(&cur.k->k), GFP_KERNEL);
if (!new) if (!new) {
bch_err(c, "%s: error allocating new key", __func__);
return -ENOMEM; return -ENOMEM;
}
bkey_copy(new, cur.k); bkey_copy(new, cur.k);
...@@ -235,8 +237,10 @@ static int bch2_check_fix_ptrs(struct bch_fs *c, enum btree_id btree_id, ...@@ -235,8 +237,10 @@ static int bch2_check_fix_ptrs(struct bch_fs *c, 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(c, "%s: error allocating new key", __func__);
return -ENOMEM; return -ENOMEM;
}
bkey_reassemble(new, *k); bkey_reassemble(new, *k);
...@@ -302,8 +306,10 @@ static int bch2_gc_mark_key(struct bch_fs *c, enum btree_id btree_id, ...@@ -302,8 +306,10 @@ static int bch2_gc_mark_key(struct bch_fs *c, enum btree_id btree_id,
"superblock not marked as containing replicas (type %u)", "superblock not marked as containing replicas (type %u)",
k.k->type)) { k.k->type)) {
ret = bch2_mark_bkey_replicas(c, k); ret = bch2_mark_bkey_replicas(c, k);
if (ret) if (ret) {
return ret; bch_err(c, "error marking bkey replicas: %i", ret);
goto err;
}
} }
ret = bch2_check_fix_ptrs(c, btree_id, level, is_root, &k); ret = bch2_check_fix_ptrs(c, btree_id, level, is_root, &k);
...@@ -321,6 +327,9 @@ static int bch2_gc_mark_key(struct bch_fs *c, enum btree_id btree_id, ...@@ -321,6 +327,9 @@ static int bch2_gc_mark_key(struct bch_fs *c, enum btree_id btree_id,
bch2_mark_key(c, k, 0, k.k->size, NULL, 0, flags); bch2_mark_key(c, k, 0, k.k->size, NULL, 0, flags);
fsck_err: fsck_err:
err:
if (ret)
bch_err(c, "%s: ret %i", __func__, ret);
return ret; return ret;
} }
...@@ -448,8 +457,10 @@ static int bch2_gc_btree_init_recurse(struct bch_fs *c, struct btree *b, ...@@ -448,8 +457,10 @@ static int bch2_gc_btree_init_recurse(struct bch_fs *c, struct btree *b,
ret = bch2_gc_mark_key(c, b->c.btree_id, b->c.level, false, ret = bch2_gc_mark_key(c, b->c.btree_id, b->c.level, false,
k, &max_stale, true); k, &max_stale, true);
if (ret) if (ret) {
bch_err(c, "%s: error %i from bch2_gc_mark_key", __func__, ret);
break; break;
}
if (b->c.level) { if (b->c.level) {
bch2_bkey_buf_reassemble(&cur, c, k); bch2_bkey_buf_reassemble(&cur, c, k);
...@@ -493,8 +504,11 @@ static int bch2_gc_btree_init_recurse(struct bch_fs *c, struct btree *b, ...@@ -493,8 +504,11 @@ static int bch2_gc_btree_init_recurse(struct bch_fs *c, struct btree *b,
continue; continue;
} }
if (ret) if (ret) {
bch_err(c, "%s: error %i getting btree node",
__func__, ret);
break; break;
}
ret = bch2_gc_btree_init_recurse(c, child, ret = bch2_gc_btree_init_recurse(c, child,
target_depth); target_depth);
...@@ -551,6 +565,8 @@ static int bch2_gc_btree_init(struct bch_fs *c, ...@@ -551,6 +565,8 @@ static int bch2_gc_btree_init(struct bch_fs *c,
fsck_err: fsck_err:
six_unlock_read(&b->c.lock); six_unlock_read(&b->c.lock);
if (ret)
bch_err(c, "%s: ret %i", __func__, ret);
return ret; return ret;
} }
...@@ -574,8 +590,10 @@ static int bch2_gc_btrees(struct bch_fs *c, bool initial) ...@@ -574,8 +590,10 @@ static int bch2_gc_btrees(struct bch_fs *c, bool initial)
int ret = initial int ret = initial
? bch2_gc_btree_init(c, id) ? bch2_gc_btree_init(c, id)
: bch2_gc_btree(c, id, initial); : bch2_gc_btree(c, id, initial);
if (ret) if (ret) {
bch_err(c, "%s: ret %i", __func__, ret);
return ret; return ret;
}
} }
return 0; return 0;
...@@ -881,6 +899,8 @@ static int bch2_gc_done(struct bch_fs *c, ...@@ -881,6 +899,8 @@ static int bch2_gc_done(struct bch_fs *c,
#undef copy_stripe_field #undef copy_stripe_field
#undef copy_field #undef copy_field
fsck_err: fsck_err:
if (ret)
bch_err(c, "%s: ret %i", __func__, ret);
return ret; return ret;
} }
...@@ -1601,8 +1621,10 @@ int bch2_gc_thread_start(struct bch_fs *c) ...@@ -1601,8 +1621,10 @@ int bch2_gc_thread_start(struct bch_fs *c)
BUG_ON(c->gc_thread); BUG_ON(c->gc_thread);
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: %li", PTR_ERR(p));
return PTR_ERR(p); return PTR_ERR(p);
}
get_task_struct(p); get_task_struct(p);
c->gc_thread = p; c->gc_thread = p;
......
...@@ -691,8 +691,10 @@ int bch2_journal_reclaim_start(struct journal *j) ...@@ -691,8 +691,10 @@ 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);
if (IS_ERR(p)) if (IS_ERR(p)) {
bch_err(c, "error creating journal reclaim thread: %li", PTR_ERR(p));
return PTR_ERR(p); return PTR_ERR(p);
}
get_task_struct(p); get_task_struct(p);
j->reclaim_thread = p; j->reclaim_thread = p;
......
...@@ -348,8 +348,10 @@ int bch2_copygc_start(struct bch_fs *c) ...@@ -348,8 +348,10 @@ int bch2_copygc_start(struct bch_fs *c)
return -ENOMEM; return -ENOMEM;
t = kthread_create(bch2_copygc_thread, c, "bch-copygc/%s", c->name); t = kthread_create(bch2_copygc_thread, c, "bch-copygc/%s", c->name);
if (IS_ERR(t)) if (IS_ERR(t)) {
bch_err(c, "error creating copygc thread: %li", PTR_ERR(t));
return PTR_ERR(t); return PTR_ERR(t);
}
get_task_struct(t); get_task_struct(t);
......
...@@ -315,8 +315,10 @@ int bch2_rebalance_start(struct bch_fs *c) ...@@ -315,8 +315,10 @@ int bch2_rebalance_start(struct bch_fs *c)
return 0; return 0;
p = kthread_create(bch2_rebalance_thread, c, "bch-rebalance/%s", c->name); p = kthread_create(bch2_rebalance_thread, c, "bch-rebalance/%s", c->name);
if (IS_ERR(p)) if (IS_ERR(p)) {
bch_err(c, "error creating rebalance thread: %li", PTR_ERR(p));
return PTR_ERR(p); return PTR_ERR(p);
}
get_task_struct(p); get_task_struct(p);
rcu_assign_pointer(c->rebalance.thread, p); rcu_assign_pointer(c->rebalance.thread, p);
......
...@@ -122,8 +122,11 @@ int bch2_journal_key_insert(struct bch_fs *c, enum btree_id id, ...@@ -122,8 +122,11 @@ int bch2_journal_key_insert(struct bch_fs *c, enum btree_id id,
}; };
new_keys.d = kvmalloc(sizeof(new_keys.d[0]) * new_keys.size, GFP_KERNEL); new_keys.d = kvmalloc(sizeof(new_keys.d[0]) * new_keys.size, GFP_KERNEL);
if (!new_keys.d) if (!new_keys.d) {
bch_err(c, "%s: error allocating new key array (size %zu)",
__func__, new_keys.size);
return -ENOMEM; return -ENOMEM;
}
memcpy(new_keys.d, keys->d, sizeof(keys->d[0]) * keys->nr); memcpy(new_keys.d, keys->d, sizeof(keys->d[0]) * keys->nr);
kvfree(keys->d); kvfree(keys->d);
...@@ -145,8 +148,10 @@ int bch2_journal_key_delete(struct bch_fs *c, enum btree_id id, ...@@ -145,8 +148,10 @@ int bch2_journal_key_delete(struct bch_fs *c, enum btree_id id,
kmalloc(sizeof(struct bkey), GFP_KERNEL); kmalloc(sizeof(struct bkey), GFP_KERNEL);
int ret; int ret;
if (!whiteout) if (!whiteout) {
bch_err(c, "%s: error allocating new key", __func__);
return -ENOMEM; return -ENOMEM;
}
bkey_init(&whiteout->k); bkey_init(&whiteout->k);
whiteout->k.p = pos; whiteout->k.p = pos;
...@@ -1330,8 +1335,10 @@ int bch2_fs_initialize(struct bch_fs *c) ...@@ -1330,8 +1335,10 @@ int bch2_fs_initialize(struct bch_fs *c)
&lostfound, &lostfound,
0, 0, S_IFDIR|0700, 0, 0, 0, S_IFDIR|0700, 0,
NULL, NULL)); NULL, NULL));
if (ret) if (ret) {
bch_err(c, "error creating lost+found");
goto err; goto err;
}
if (enabled_qtypes(c)) { if (enabled_qtypes(c)) {
ret = bch2_fs_quota_read(c); ret = bch2_fs_quota_read(c);
......
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