mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2026-01-27 12:47:24 +01:00
bcachefs: Use bch2_err_matches() for BCH_ERR_fsck_(fix|ignore)
We'll be adding subtypes of these errors, and new error code tracing. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
dc43f6a70b
commit
642c1aabb0
|
|
@ -709,8 +709,8 @@ static int __need_discard_or_freespace_err(struct btree_trans *trans,
|
|||
set ? "" : "un",
|
||||
bch2_btree_id_str(btree),
|
||||
buf.buf);
|
||||
if (ret == -BCH_ERR_fsck_ignore ||
|
||||
ret == -BCH_ERR_fsck_errors_not_fixed)
|
||||
if (bch2_err_matches(ret, BCH_ERR_fsck_ignore) ||
|
||||
bch2_err_matches(ret, BCH_ERR_fsck_errors_not_fixed))
|
||||
ret = 0;
|
||||
|
||||
printbuf_exit(&buf);
|
||||
|
|
|
|||
|
|
@ -602,8 +602,8 @@ static int __btree_err(int ret,
|
|||
switch (ret) {
|
||||
case -BCH_ERR_btree_node_read_err_fixable:
|
||||
ret2 = bch2_fsck_err_opt(c, FSCK_CAN_FIX, err_type);
|
||||
if (ret2 != -BCH_ERR_fsck_fix &&
|
||||
ret2 != -BCH_ERR_fsck_ignore) {
|
||||
if (!bch2_err_matches(ret2, BCH_ERR_fsck_fix) &&
|
||||
!bch2_err_matches(ret2, BCH_ERR_fsck_ignore)) {
|
||||
ret = ret2;
|
||||
goto fsck_err;
|
||||
}
|
||||
|
|
@ -631,8 +631,8 @@ static int __btree_err(int ret,
|
|||
switch (ret) {
|
||||
case -BCH_ERR_btree_node_read_err_fixable:
|
||||
ret2 = __bch2_fsck_err(c, NULL, FSCK_CAN_FIX, err_type, "%s", out.buf);
|
||||
if (ret2 != -BCH_ERR_fsck_fix &&
|
||||
ret2 != -BCH_ERR_fsck_ignore) {
|
||||
if (!bch2_err_matches(ret2, BCH_ERR_fsck_fix) &&
|
||||
!bch2_err_matches(ret2, BCH_ERR_fsck_ignore)) {
|
||||
ret = ret2;
|
||||
goto fsck_err;
|
||||
}
|
||||
|
|
@ -660,7 +660,7 @@ fsck_err:
|
|||
failed, err_msg, \
|
||||
msg, ##__VA_ARGS__); \
|
||||
\
|
||||
if (_ret != -BCH_ERR_fsck_fix) { \
|
||||
if (!bch2_err_matches(_ret, BCH_ERR_fsck_fix)) { \
|
||||
ret = _ret; \
|
||||
goto fsck_err; \
|
||||
} \
|
||||
|
|
|
|||
|
|
@ -444,7 +444,7 @@ int __bch2_fsck_err(struct bch_fs *c,
|
|||
{
|
||||
va_list args;
|
||||
struct printbuf buf = PRINTBUF, *out = &buf;
|
||||
int ret = -BCH_ERR_fsck_ignore;
|
||||
int ret = 0;
|
||||
const char *action_orig = "fix?", *action = action_orig;
|
||||
|
||||
might_sleep();
|
||||
|
|
@ -573,19 +573,26 @@ int __bch2_fsck_err(struct bch_fs *c,
|
|||
} else {
|
||||
prt_str(out, ", not ");
|
||||
prt_actioning(out, action);
|
||||
ret = -BCH_ERR_fsck_ignore;
|
||||
}
|
||||
} else {
|
||||
if (flags & FSCK_CAN_IGNORE) {
|
||||
prt_str(out, ", continuing");
|
||||
ret = -BCH_ERR_fsck_ignore;
|
||||
} else {
|
||||
prt_str(out, " (repair unimplemented)");
|
||||
ret = -BCH_ERR_fsck_repair_unimplemented;
|
||||
}
|
||||
} else if (!(flags & FSCK_CAN_IGNORE)) {
|
||||
prt_str(out, " (repair unimplemented)");
|
||||
}
|
||||
|
||||
if (ret == -BCH_ERR_fsck_ignore &&
|
||||
if (bch2_err_matches(ret, BCH_ERR_fsck_ignore) &&
|
||||
(c->opts.fix_errors == FSCK_FIX_exit ||
|
||||
!(flags & FSCK_CAN_IGNORE)))
|
||||
ret = -BCH_ERR_fsck_errors_not_fixed;
|
||||
|
||||
if (test_bit(BCH_FS_in_fsck, &c->flags) &&
|
||||
(ret != -BCH_ERR_fsck_fix &&
|
||||
ret != -BCH_ERR_fsck_ignore)) {
|
||||
(!bch2_err_matches(ret, BCH_ERR_fsck_fix) &&
|
||||
!bch2_err_matches(ret, BCH_ERR_fsck_ignore))) {
|
||||
exiting = true;
|
||||
print = true;
|
||||
}
|
||||
|
|
@ -613,26 +620,26 @@ print:
|
|||
|
||||
if (s)
|
||||
s->ret = ret;
|
||||
|
||||
err_unlock:
|
||||
mutex_unlock(&c->fsck_error_msgs_lock);
|
||||
err:
|
||||
/*
|
||||
* We don't yet track whether the filesystem currently has errors, for
|
||||
* log_fsck_err()s: that would require us to track for every error type
|
||||
* which recovery pass corrects it, to get the fsck exit status correct:
|
||||
*/
|
||||
if (flags & FSCK_CAN_FIX) {
|
||||
if (ret == -BCH_ERR_fsck_fix) {
|
||||
set_bit(BCH_FS_errors_fixed, &c->flags);
|
||||
} else {
|
||||
set_bit(BCH_FS_errors_not_fixed, &c->flags);
|
||||
set_bit(BCH_FS_error, &c->flags);
|
||||
}
|
||||
if (bch2_err_matches(ret, BCH_ERR_fsck_fix)) {
|
||||
set_bit(BCH_FS_errors_fixed, &c->flags);
|
||||
} else {
|
||||
set_bit(BCH_FS_errors_not_fixed, &c->flags);
|
||||
set_bit(BCH_FS_error, &c->flags);
|
||||
}
|
||||
err_unlock:
|
||||
mutex_unlock(&c->fsck_error_msgs_lock);
|
||||
err:
|
||||
|
||||
if (action != action_orig)
|
||||
kfree(action);
|
||||
printbuf_exit(&buf);
|
||||
|
||||
BUG_ON(!ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,13 +105,13 @@ void bch2_free_fsck_errs(struct bch_fs *);
|
|||
#define fsck_err_wrap(_do) \
|
||||
({ \
|
||||
int _ret = _do; \
|
||||
if (_ret != -BCH_ERR_fsck_fix && \
|
||||
_ret != -BCH_ERR_fsck_ignore) { \
|
||||
if (!bch2_err_matches(_ret, BCH_ERR_fsck_fix) && \
|
||||
!bch2_err_matches(_ret, BCH_ERR_fsck_ignore)) { \
|
||||
ret = _ret; \
|
||||
goto fsck_err; \
|
||||
} \
|
||||
\
|
||||
_ret == -BCH_ERR_fsck_fix; \
|
||||
bch2_err_matches(_ret, BCH_ERR_fsck_fix); \
|
||||
})
|
||||
|
||||
#define __fsck_err(...) fsck_err_wrap(bch2_fsck_err(__VA_ARGS__))
|
||||
|
|
@ -170,8 +170,8 @@ do { \
|
|||
int _ret = __bch2_bkey_fsck_err(c, k, from, \
|
||||
BCH_FSCK_ERR_##_err_type, \
|
||||
_err_msg, ##__VA_ARGS__); \
|
||||
if (_ret != -BCH_ERR_fsck_fix && \
|
||||
_ret != -BCH_ERR_fsck_ignore) \
|
||||
if (!bch2_err_matches(_ret, BCH_ERR_fsck_fix) && \
|
||||
!bch2_err_matches(_ret, BCH_ERR_fsck_ignore)) \
|
||||
ret = _ret; \
|
||||
ret = -BCH_ERR_fsck_delete_bkey; \
|
||||
goto fsck_err; \
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user