Commit ce3e9283 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Kill some -EINVALs

Repurposing standard error codes in bcachefs code is banned in new code,
and we need to get rid of the remaining ones - private error codes give
us much better error messages.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 82fdc1dc
...@@ -176,6 +176,8 @@ ...@@ -176,6 +176,8 @@
x(EINVAL, invalid) \ x(EINVAL, invalid) \
x(EINVAL, internal_fsck_err) \ x(EINVAL, internal_fsck_err) \
x(EINVAL, opt_parse_error) \ x(EINVAL, opt_parse_error) \
x(EINVAL, remove_with_metadata_missing_unimplemented)\
x(EINVAL, remove_would_lose_data) \
x(EROFS, erofs_trans_commit) \ x(EROFS, erofs_trans_commit) \
x(EROFS, erofs_no_writes) \ x(EROFS, erofs_no_writes) \
x(EROFS, erofs_journal_err) \ x(EROFS, erofs_journal_err) \
......
...@@ -31,7 +31,7 @@ static int drop_dev_ptrs(struct bch_fs *c, struct bkey_s k, ...@@ -31,7 +31,7 @@ static int drop_dev_ptrs(struct bch_fs *c, struct bkey_s k,
nr_good = bch2_bkey_durability(c, k.s_c); nr_good = bch2_bkey_durability(c, k.s_c);
if ((!nr_good && !(flags & lost)) || if ((!nr_good && !(flags & lost)) ||
(nr_good < replicas && !(flags & degraded))) (nr_good < replicas && !(flags & degraded)))
return -EINVAL; return -BCH_ERR_remove_would_lose_data;
return 0; return 0;
} }
...@@ -111,7 +111,7 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags) ...@@ -111,7 +111,7 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags)
/* don't handle this yet: */ /* don't handle this yet: */
if (flags & BCH_FORCE_IF_METADATA_LOST) if (flags & BCH_FORCE_IF_METADATA_LOST)
return -EINVAL; return -BCH_ERR_remove_with_metadata_missing_unimplemented;
trans = bch2_trans_get(c); trans = bch2_trans_get(c);
bch2_bkey_buf_init(&k); bch2_bkey_buf_init(&k);
...@@ -132,10 +132,8 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags) ...@@ -132,10 +132,8 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags)
ret = drop_dev_ptrs(c, bkey_i_to_s(k.k), ret = drop_dev_ptrs(c, bkey_i_to_s(k.k),
dev_idx, flags, true); dev_idx, flags, true);
if (ret) { if (ret)
bch_err(c, "Cannot drop device without losing data");
break; break;
}
ret = bch2_btree_node_update_key(trans, &iter, b, k.k, 0, false); ret = bch2_btree_node_update_key(trans, &iter, b, k.k, 0, false);
if (bch2_err_matches(ret, BCH_ERR_transaction_restart)) { if (bch2_err_matches(ret, BCH_ERR_transaction_restart)) {
......
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