Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Kent Overstreet <kent.overstreet@linux.dev>

+5 -5
+2
fs/bcachefs/errcode.h
··· 176 176 x(EINVAL, invalid) \ 177 177 x(EINVAL, internal_fsck_err) \ 178 178 x(EINVAL, opt_parse_error) \ 179 + x(EINVAL, remove_with_metadata_missing_unimplemented)\ 180 + x(EINVAL, remove_would_lose_data) \ 179 181 x(EROFS, erofs_trans_commit) \ 180 182 x(EROFS, erofs_no_writes) \ 181 183 x(EROFS, erofs_journal_err) \
+3 -5
fs/bcachefs/migrate.c
··· 31 31 nr_good = bch2_bkey_durability(c, k.s_c); 32 32 if ((!nr_good && !(flags & lost)) || 33 33 (nr_good < replicas && !(flags & degraded))) 34 - return -EINVAL; 34 + return -BCH_ERR_remove_would_lose_data; 35 35 36 36 return 0; 37 37 } ··· 111 111 112 112 /* don't handle this yet: */ 113 113 if (flags & BCH_FORCE_IF_METADATA_LOST) 114 - return -EINVAL; 114 + return -BCH_ERR_remove_with_metadata_missing_unimplemented; 115 115 116 116 trans = bch2_trans_get(c); 117 117 bch2_bkey_buf_init(&k); ··· 132 132 133 133 ret = drop_dev_ptrs(c, bkey_i_to_s(k.k), 134 134 dev_idx, flags, true); 135 - if (ret) { 136 - bch_err(c, "Cannot drop device without losing data"); 135 + if (ret) 137 136 break; 138 - } 139 137 140 138 ret = bch2_btree_node_update_key(trans, &iter, b, k.k, 0, false); 141 139 if (bch2_err_matches(ret, BCH_ERR_transaction_restart)) {