Commit 54a12984 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: EIO errcode cleanup

We want to be using private errcodes whenever possible, for better error
messages.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 7a51608d
...@@ -486,7 +486,7 @@ int bch2_bucket_ref_update(struct btree_trans *trans, struct bch_dev *ca, ...@@ -486,7 +486,7 @@ int bch2_bucket_ref_update(struct btree_trans *trans, struct bch_dev *ca,
return ret; return ret;
err: err:
bch2_dump_trans_updates(trans); bch2_dump_trans_updates(trans);
ret = -EIO; ret = -BCH_ERR_bucket_ref_update;
goto out; goto out;
} }
...@@ -573,7 +573,7 @@ static int bch2_trigger_pointer(struct btree_trans *trans, ...@@ -573,7 +573,7 @@ static int bch2_trigger_pointer(struct btree_trans *trans,
struct bch_dev *ca = bch2_dev_tryget(c, p.ptr.dev); struct bch_dev *ca = bch2_dev_tryget(c, p.ptr.dev);
if (unlikely(!ca)) { if (unlikely(!ca)) {
if (insert && p.ptr.dev != BCH_SB_MEMBER_INVALID) if (insert && p.ptr.dev != BCH_SB_MEMBER_INVALID)
ret = -EIO; ret = -BCH_ERR_trigger_pointer;
goto err; goto err;
} }
...@@ -602,7 +602,7 @@ static int bch2_trigger_pointer(struct btree_trans *trans, ...@@ -602,7 +602,7 @@ static int bch2_trigger_pointer(struct btree_trans *trans,
if (bch2_fs_inconsistent_on(!g, c, "reference to invalid bucket on device %u\n %s", if (bch2_fs_inconsistent_on(!g, c, "reference to invalid bucket on device %u\n %s",
p.ptr.dev, p.ptr.dev,
(bch2_bkey_val_to_text(&buf, c, k), buf.buf))) { (bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {
ret = -EIO; ret = -BCH_ERR_trigger_pointer;
goto err_unlock; goto err_unlock;
} }
...@@ -647,7 +647,7 @@ static int bch2_trigger_stripe_ptr(struct btree_trans *trans, ...@@ -647,7 +647,7 @@ static int bch2_trigger_stripe_ptr(struct btree_trans *trans,
bch2_trans_inconsistent(trans, bch2_trans_inconsistent(trans,
"stripe pointer doesn't match stripe %llu", "stripe pointer doesn't match stripe %llu",
(u64) p.ec.idx); (u64) p.ec.idx);
ret = -EIO; ret = -BCH_ERR_trigger_stripe_pointer;
goto err; goto err;
} }
...@@ -686,7 +686,7 @@ static int bch2_trigger_stripe_ptr(struct btree_trans *trans, ...@@ -686,7 +686,7 @@ static int bch2_trigger_stripe_ptr(struct btree_trans *trans,
(u64) p.ec.idx, buf.buf); (u64) p.ec.idx, buf.buf);
printbuf_exit(&buf); printbuf_exit(&buf);
bch2_inconsistent_error(c); bch2_inconsistent_error(c);
return -EIO; return -BCH_ERR_trigger_stripe_pointer;
} }
m->block_sectors[p.ec.block] += sectors; m->block_sectors[p.ec.block] += sectors;
...@@ -966,7 +966,7 @@ static int __bch2_trans_mark_metadata_bucket(struct btree_trans *trans, ...@@ -966,7 +966,7 @@ static int __bch2_trans_mark_metadata_bucket(struct btree_trans *trans,
bch2_data_type_str(a->v.data_type), bch2_data_type_str(a->v.data_type),
bch2_data_type_str(type), bch2_data_type_str(type),
bch2_data_type_str(type)); bch2_data_type_str(type));
ret = -EIO; ret = -BCH_ERR_metadata_bucket_inconsistency;
goto err; goto err;
} }
...@@ -1022,7 +1022,7 @@ static int bch2_mark_metadata_bucket(struct btree_trans *trans, struct bch_dev * ...@@ -1022,7 +1022,7 @@ static int bch2_mark_metadata_bucket(struct btree_trans *trans, struct bch_dev *
bucket_unlock(g); bucket_unlock(g);
err_unlock: err_unlock:
percpu_up_read(&c->mark_lock); percpu_up_read(&c->mark_lock);
return -EIO; return -BCH_ERR_metadata_bucket_inconsistency;
} }
int bch2_trans_mark_metadata_bucket(struct btree_trans *trans, int bch2_trans_mark_metadata_bucket(struct btree_trans *trans,
......
...@@ -193,7 +193,7 @@ static int __mark_stripe_bucket(struct btree_trans *trans, ...@@ -193,7 +193,7 @@ static int __mark_stripe_bucket(struct btree_trans *trans,
a->dirty_sectors, a->dirty_sectors,
a->stripe, s.k->p.offset, a->stripe, s.k->p.offset,
(bch2_bkey_val_to_text(&buf, c, s.s_c), buf.buf))) { (bch2_bkey_val_to_text(&buf, c, s.s_c), buf.buf))) {
ret = -EIO; ret = -BCH_ERR_mark_stripe;
goto err; goto err;
} }
...@@ -204,7 +204,7 @@ static int __mark_stripe_bucket(struct btree_trans *trans, ...@@ -204,7 +204,7 @@ static int __mark_stripe_bucket(struct btree_trans *trans,
a->dirty_sectors, a->dirty_sectors,
a->cached_sectors, a->cached_sectors,
(bch2_bkey_val_to_text(&buf, c, s.s_c), buf.buf))) { (bch2_bkey_val_to_text(&buf, c, s.s_c), buf.buf))) {
ret = -EIO; ret = -BCH_ERR_mark_stripe;
goto err; goto err;
} }
} else { } else {
...@@ -214,7 +214,7 @@ static int __mark_stripe_bucket(struct btree_trans *trans, ...@@ -214,7 +214,7 @@ static int __mark_stripe_bucket(struct btree_trans *trans,
bucket.inode, bucket.offset, a->gen, bucket.inode, bucket.offset, a->gen,
a->stripe, a->stripe,
(bch2_bkey_val_to_text(&buf, c, s.s_c), buf.buf))) { (bch2_bkey_val_to_text(&buf, c, s.s_c), buf.buf))) {
ret = -EIO; ret = -BCH_ERR_mark_stripe;
goto err; goto err;
} }
...@@ -224,7 +224,7 @@ static int __mark_stripe_bucket(struct btree_trans *trans, ...@@ -224,7 +224,7 @@ static int __mark_stripe_bucket(struct btree_trans *trans,
bch2_data_type_str(a->data_type), bch2_data_type_str(a->data_type),
bch2_data_type_str(data_type), bch2_data_type_str(data_type),
(bch2_bkey_val_to_text(&buf, c, s.s_c), buf.buf))) { (bch2_bkey_val_to_text(&buf, c, s.s_c), buf.buf))) {
ret = -EIO; ret = -BCH_ERR_mark_stripe;
goto err; goto err;
} }
...@@ -236,7 +236,7 @@ static int __mark_stripe_bucket(struct btree_trans *trans, ...@@ -236,7 +236,7 @@ static int __mark_stripe_bucket(struct btree_trans *trans,
a->dirty_sectors, a->dirty_sectors,
a->cached_sectors, a->cached_sectors,
(bch2_bkey_val_to_text(&buf, c, s.s_c), buf.buf))) { (bch2_bkey_val_to_text(&buf, c, s.s_c), buf.buf))) {
ret = -EIO; ret = -BCH_ERR_mark_stripe;
goto err; goto err;
} }
} }
...@@ -274,8 +274,8 @@ static int mark_stripe_bucket(struct btree_trans *trans, ...@@ -274,8 +274,8 @@ static int mark_stripe_bucket(struct btree_trans *trans,
struct bch_dev *ca = bch2_dev_tryget(c, ptr->dev); struct bch_dev *ca = bch2_dev_tryget(c, ptr->dev);
if (unlikely(!ca)) { if (unlikely(!ca)) {
if (!(flags & BTREE_TRIGGER_overwrite)) if (ptr->dev != BCH_SB_MEMBER_INVALID && !(flags & BTREE_TRIGGER_overwrite))
ret = -EIO; ret = -BCH_ERR_mark_stripe;
goto err; goto err;
} }
...@@ -294,7 +294,7 @@ static int mark_stripe_bucket(struct btree_trans *trans, ...@@ -294,7 +294,7 @@ static int mark_stripe_bucket(struct btree_trans *trans,
if (bch2_fs_inconsistent_on(!g, c, "reference to invalid bucket on device %u\n %s", if (bch2_fs_inconsistent_on(!g, c, "reference to invalid bucket on device %u\n %s",
ptr->dev, ptr->dev,
(bch2_bkey_val_to_text(&buf, c, s.s_c), buf.buf))) { (bch2_bkey_val_to_text(&buf, c, s.s_c), buf.buf))) {
ret = -EIO; ret = -BCH_ERR_mark_stripe;
goto err_unlock; goto err_unlock;
} }
...@@ -839,7 +839,7 @@ int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio) ...@@ -839,7 +839,7 @@ int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio)
bch_err_ratelimited(c, bch_err_ratelimited(c,
"error doing reconstruct read: error %i looking up stripe", ret); "error doing reconstruct read: error %i looking up stripe", ret);
kfree(buf); kfree(buf);
return -EIO; return -BCH_ERR_stripe_reconstruct;
} }
v = &bkey_i_to_stripe(&buf->key)->v; v = &bkey_i_to_stripe(&buf->key)->v;
...@@ -847,7 +847,7 @@ int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio) ...@@ -847,7 +847,7 @@ int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio)
if (!bch2_ptr_matches_stripe(v, rbio->pick)) { if (!bch2_ptr_matches_stripe(v, rbio->pick)) {
bch_err_ratelimited(c, bch_err_ratelimited(c,
"error doing reconstruct read: pointer doesn't match stripe"); "error doing reconstruct read: pointer doesn't match stripe");
ret = -EIO; ret = -BCH_ERR_stripe_reconstruct;
goto err; goto err;
} }
...@@ -855,7 +855,7 @@ int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio) ...@@ -855,7 +855,7 @@ int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio)
if (offset + bio_sectors(&rbio->bio) > le16_to_cpu(v->sectors)) { if (offset + bio_sectors(&rbio->bio) > le16_to_cpu(v->sectors)) {
bch_err_ratelimited(c, bch_err_ratelimited(c,
"error doing reconstruct read: read is bigger than stripe"); "error doing reconstruct read: read is bigger than stripe");
ret = -EIO; ret = -BCH_ERR_stripe_reconstruct;
goto err; goto err;
} }
...@@ -871,7 +871,7 @@ int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio) ...@@ -871,7 +871,7 @@ int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio)
if (ec_nr_failed(buf) > v->nr_redundant) { if (ec_nr_failed(buf) > v->nr_redundant) {
bch_err_ratelimited(c, bch_err_ratelimited(c,
"error doing reconstruct read: unable to read enough blocks"); "error doing reconstruct read: unable to read enough blocks");
ret = -EIO; ret = -BCH_ERR_stripe_reconstruct;
goto err; goto err;
} }
......
...@@ -244,6 +244,15 @@ ...@@ -244,6 +244,15 @@
x(EIO, btree_node_read_error) \ x(EIO, btree_node_read_error) \
x(EIO, btree_node_read_validate_error) \ x(EIO, btree_node_read_validate_error) \
x(EIO, btree_need_topology_repair) \ x(EIO, btree_need_topology_repair) \
x(EIO, bucket_ref_update) \
x(EIO, trigger_pointer) \
x(EIO, trigger_stripe_pointer) \
x(EIO, metadata_bucket_inconsistency) \
x(EIO, mark_stripe) \
x(EIO, stripe_reconstruct) \
x(EIO, key_type_error) \
x(EIO, no_device_to_read_from) \
x(EIO, missing_indirect_extent) \
x(BCH_ERR_btree_node_read_err, btree_node_read_err_fixable) \ x(BCH_ERR_btree_node_read_err, btree_node_read_err_fixable) \
x(BCH_ERR_btree_node_read_err, btree_node_read_err_want_retry) \ x(BCH_ERR_btree_node_read_err, btree_node_read_err_want_retry) \
x(BCH_ERR_btree_node_read_err, btree_node_read_err_must_retry) \ x(BCH_ERR_btree_node_read_err, btree_node_read_err_must_retry) \
......
...@@ -115,7 +115,7 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k, ...@@ -115,7 +115,7 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k,
int ret = 0; int ret = 0;
if (k.k->type == KEY_TYPE_error) if (k.k->type == KEY_TYPE_error)
return -EIO; return -BCH_ERR_key_type_error;
rcu_read_lock(); rcu_read_lock();
bkey_for_each_ptr_decode(k.k, ptrs, p, entry) { bkey_for_each_ptr_decode(k.k, ptrs, p, entry) {
...@@ -133,7 +133,7 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k, ...@@ -133,7 +133,7 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k,
* read: * read:
*/ */
if (!ret && !p.ptr.cached) if (!ret && !p.ptr.cached)
ret = -EIO; ret = -BCH_ERR_no_device_to_read_from;
struct bch_dev *ca = bch2_dev_rcu(c, p.ptr.dev); struct bch_dev *ca = bch2_dev_rcu(c, p.ptr.dev);
...@@ -146,16 +146,13 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k, ...@@ -146,16 +146,13 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k,
? f->idx ? f->idx
: f->idx + 1; : f->idx + 1;
if (!p.idx && !ca) if (!p.idx && (!ca || !bch2_dev_is_readable(ca)))
p.idx++; p.idx++;
if (!p.idx && p.has_ec && bch2_force_reconstruct_read) if (!p.idx && p.has_ec && bch2_force_reconstruct_read)
p.idx++; p.idx++;
if (!p.idx && !bch2_dev_is_readable(ca)) if (p.idx > (unsigned) p.has_ec)
p.idx++;
if (p.idx >= (unsigned) p.has_ec + 1)
continue; continue;
if (ret > 0 && !ptr_better(c, p, *pick)) if (ret > 0 && !ptr_better(c, p, *pick))
......
...@@ -777,7 +777,7 @@ int __bch2_read_indirect_extent(struct btree_trans *trans, ...@@ -777,7 +777,7 @@ int __bch2_read_indirect_extent(struct btree_trans *trans,
orig_k->k->k.size, orig_k->k->k.size,
reflink_offset); reflink_offset);
bch2_inconsistent_error(trans->c); bch2_inconsistent_error(trans->c);
ret = -EIO; ret = -BCH_ERR_missing_indirect_extent;
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