mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-12-09 00:00:17 +03:00
Update bcachefs sources to 656fe6ab62bd bcachefs: kill silly gcc warning
Some checks failed
build / bcachefs-tools-msrv (push) Has been cancelled
.deb build orchestrator / source-only (push) Has been cancelled
.deb build orchestrator / obs (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:forky], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:forky], map[build-arch:amd64 host-arch:ppc64el machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:forky], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:trixie], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:trixie], map[build-arch:amd64 host-arch:ppc64el machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:trixie], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:unstable], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:unstable], map[build-arch:amd64 host-arch:ppc64el machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:unstable], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:ubuntu version:plucky], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:ubuntu version:plucky], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:ubuntu version:questing], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:ubuntu version:questing], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / reprotest (push) Has been cancelled
.deb build orchestrator / publish (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
Some checks failed
build / bcachefs-tools-msrv (push) Has been cancelled
.deb build orchestrator / source-only (push) Has been cancelled
.deb build orchestrator / obs (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:forky], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:forky], map[build-arch:amd64 host-arch:ppc64el machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:forky], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:trixie], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:trixie], map[build-arch:amd64 host-arch:ppc64el machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:trixie], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:unstable], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:unstable], map[build-arch:amd64 host-arch:ppc64el machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:unstable], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:ubuntu version:plucky], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:ubuntu version:plucky], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:ubuntu version:questing], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:ubuntu version:questing], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / reprotest (push) Has been cancelled
.deb build orchestrator / publish (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
This commit is contained in:
parent
9694ddaba1
commit
b33db73147
@ -1 +1 @@
|
||||
92092a7729703f2285902b56aacaae199a3517eb
|
||||
656fe6ab62bd41321e90e1567e6bf9c3ea058633
|
||||
|
||||
@ -95,21 +95,10 @@ void bch2_btree_node_wait_on_write(struct btree *b)
|
||||
TASK_UNINTERRUPTIBLE);
|
||||
}
|
||||
|
||||
static void btree_err_msg(struct printbuf *out, struct bch_fs *c,
|
||||
struct bch_dev *ca,
|
||||
bool print_pos,
|
||||
static void btree_err_msg(struct printbuf *out, struct bch_fs *c, struct bch_dev *ca,
|
||||
struct btree *b, struct bset *i, struct bkey_packed *k,
|
||||
unsigned offset, int rw)
|
||||
const char *fmt, va_list args)
|
||||
{
|
||||
if (print_pos) {
|
||||
prt_str(out, rw == READ
|
||||
? "error validating btree node "
|
||||
: "corrupt btree node before write ");
|
||||
prt_printf(out, "at btree ");
|
||||
bch2_btree_pos_to_text(out, c, b);
|
||||
prt_newline(out);
|
||||
}
|
||||
|
||||
if (ca)
|
||||
prt_printf(out, "%s ", ca->name);
|
||||
|
||||
@ -122,10 +111,13 @@ static void btree_err_msg(struct printbuf *out, struct bch_fs *c,
|
||||
(unsigned long)(void *)k -
|
||||
((unsigned long)(void *)i & ~511UL));
|
||||
prt_str(out, ": ");
|
||||
|
||||
prt_vprintf(out, fmt, args);
|
||||
prt_newline(out);
|
||||
}
|
||||
|
||||
__printf(11, 12)
|
||||
static int __btree_err(int ret,
|
||||
static int __btree_err(enum bch_fsck_flags flags,
|
||||
struct bch_fs *c,
|
||||
struct bch_dev *ca,
|
||||
struct btree *b,
|
||||
@ -138,99 +130,47 @@ static int __btree_err(int ret,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
if (c->recovery.curr_pass == BCH_RECOVERY_PASS_scan_for_btree_nodes)
|
||||
return ret == -BCH_ERR_btree_node_read_err_fixable
|
||||
return flags & FSCK_CAN_FIX
|
||||
? bch_err_throw(c, fsck_fix)
|
||||
: ret;
|
||||
: bch_err_throw(c, btree_node_validate_err);
|
||||
|
||||
bool have_retry = false;
|
||||
int ret2;
|
||||
bch2_sb_error_count(c, err_type);
|
||||
|
||||
if (rw == READ) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
btree_err_msg(err_msg, c, ca, b, i, k, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if (ca) {
|
||||
bch2_dev_io_failures_mut(failed, ca->dev_idx)->errcode =
|
||||
bch_err_throw(c, btree_node_validate_err);
|
||||
|
||||
struct extent_ptr_decoded pick;
|
||||
have_retry = bch2_bkey_pick_read_device(c,
|
||||
bool have_retry = bch2_bkey_pick_read_device(c,
|
||||
bkey_i_to_s_c(&b->key),
|
||||
failed, &pick, -1) == 1;
|
||||
|
||||
return !have_retry &&
|
||||
(flags & FSCK_CAN_FIX) &&
|
||||
bch2_fsck_err_opt(c, FSCK_CAN_FIX, err_type) == -BCH_ERR_fsck_fix
|
||||
? bch_err_throw(c, fsck_fix)
|
||||
: bch_err_throw(c, btree_node_validate_err);
|
||||
} else {
|
||||
CLASS(bch_log_msg, msg)(c);
|
||||
|
||||
prt_str(&msg.m, "corrupt btree node before write at btree ");
|
||||
bch2_btree_pos_to_text(&msg.m, c, b);
|
||||
prt_newline(&msg.m);
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
btree_err_msg(&msg.m, c, NULL, b, i, k, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
bch2_fs_emergency_read_only2(c, &msg.m);
|
||||
|
||||
return bch_err_throw(c, fsck_errors_not_fixed);
|
||||
}
|
||||
|
||||
if (!have_retry && ret == -BCH_ERR_btree_node_read_err_want_retry)
|
||||
ret = bch_err_throw(c, btree_node_read_err_fixable);
|
||||
if (!have_retry && ret == -BCH_ERR_btree_node_read_err_must_retry)
|
||||
ret = bch_err_throw(c, btree_node_read_err_bad_node);
|
||||
|
||||
bch2_sb_error_count(c, err_type);
|
||||
|
||||
bool print_deferred = err_msg &&
|
||||
rw == READ &&
|
||||
!(test_bit(BCH_FS_in_fsck, &c->flags) &&
|
||||
c->opts.fix_errors == FSCK_FIX_ask);
|
||||
|
||||
CLASS(printbuf, out)();
|
||||
bch2_log_msg_start(c, &out);
|
||||
|
||||
if (!print_deferred)
|
||||
err_msg = &out;
|
||||
|
||||
btree_err_msg(err_msg, c, ca, !print_deferred, b, i, k, b->written, rw);
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
prt_vprintf(err_msg, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if (print_deferred) {
|
||||
prt_newline(err_msg);
|
||||
|
||||
switch (ret) {
|
||||
case -BCH_ERR_btree_node_read_err_fixable:
|
||||
ret2 = bch2_fsck_err_opt(c, FSCK_CAN_FIX, err_type);
|
||||
if (!bch2_err_matches(ret2, BCH_ERR_fsck_fix) &&
|
||||
!bch2_err_matches(ret2, BCH_ERR_fsck_ignore)) {
|
||||
ret = ret2;
|
||||
goto fsck_err;
|
||||
}
|
||||
|
||||
if (!have_retry)
|
||||
ret = bch_err_throw(c, fsck_fix);
|
||||
return ret;
|
||||
case -BCH_ERR_btree_node_read_err_bad_node:
|
||||
prt_str(&out, ", ");
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (rw == WRITE) {
|
||||
prt_str(&out, ", ");
|
||||
ret = __bch2_inconsistent_error(c, &out)
|
||||
? -BCH_ERR_fsck_errors_not_fixed
|
||||
: 0;
|
||||
goto print;
|
||||
}
|
||||
|
||||
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 (!bch2_err_matches(ret2, BCH_ERR_fsck_fix) &&
|
||||
!bch2_err_matches(ret2, BCH_ERR_fsck_ignore)) {
|
||||
ret = ret2;
|
||||
goto fsck_err;
|
||||
}
|
||||
|
||||
if (!have_retry)
|
||||
ret = bch_err_throw(c, fsck_fix);
|
||||
return ret;
|
||||
case -BCH_ERR_btree_node_read_err_bad_node:
|
||||
prt_str(&out, ", ");
|
||||
break;
|
||||
}
|
||||
print:
|
||||
bch2_print_str(c, KERN_ERR, out.buf);
|
||||
fsck_err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define btree_err(type, c, ca, b, i, k, _err_type, msg, ...) \
|
||||
@ -313,7 +253,7 @@ int bch2_validate_bset(struct bch_fs *c, struct bch_dev *ca,
|
||||
int ret = 0;
|
||||
|
||||
btree_err_on(!bch2_version_compatible(version),
|
||||
-BCH_ERR_btree_node_read_err_incompatible,
|
||||
0,
|
||||
c, ca, b, i, NULL,
|
||||
btree_node_unsupported_version,
|
||||
"unsupported bset version %u.%u",
|
||||
@ -322,8 +262,8 @@ int bch2_validate_bset(struct bch_fs *c, struct bch_dev *ca,
|
||||
|
||||
if (c->recovery.curr_pass != BCH_RECOVERY_PASS_scan_for_btree_nodes &&
|
||||
btree_err_on(version < c->sb.version_min,
|
||||
-BCH_ERR_btree_node_read_err_fixable,
|
||||
c, NULL, b, i, NULL,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, i, NULL,
|
||||
btree_node_bset_older_than_sb_min,
|
||||
"bset version %u older than superblock version_min %u",
|
||||
version, c->sb.version_min)) {
|
||||
@ -339,8 +279,8 @@ int bch2_validate_bset(struct bch_fs *c, struct bch_dev *ca,
|
||||
|
||||
if (btree_err_on(BCH_VERSION_MAJOR(version) >
|
||||
BCH_VERSION_MAJOR(c->sb.version),
|
||||
-BCH_ERR_btree_node_read_err_fixable,
|
||||
c, NULL, b, i, NULL,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, i, NULL,
|
||||
btree_node_bset_newer_than_sb,
|
||||
"bset version %u newer than superblock version %u",
|
||||
version, c->sb.version)) {
|
||||
@ -350,19 +290,19 @@ int bch2_validate_bset(struct bch_fs *c, struct bch_dev *ca,
|
||||
}
|
||||
|
||||
btree_err_on(BSET_SEPARATE_WHITEOUTS(i),
|
||||
-BCH_ERR_btree_node_read_err_incompatible,
|
||||
0,
|
||||
c, ca, b, i, NULL,
|
||||
btree_node_unsupported_version,
|
||||
"BSET_SEPARATE_WHITEOUTS no longer supported");
|
||||
|
||||
btree_err_on(offset && !i->u64s,
|
||||
-BCH_ERR_btree_node_read_err_fixable,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, i, NULL,
|
||||
bset_empty,
|
||||
"empty bset");
|
||||
|
||||
btree_err_on(BSET_OFFSET(i) && BSET_OFFSET(i) != offset,
|
||||
-BCH_ERR_btree_node_read_err_want_retry,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, i, NULL,
|
||||
bset_wrong_sector_offset,
|
||||
"bset at wrong sector offset");
|
||||
@ -378,20 +318,20 @@ int bch2_validate_bset(struct bch_fs *c, struct bch_dev *ca,
|
||||
|
||||
/* XXX endianness */
|
||||
btree_err_on(bp->seq != bn->keys.seq,
|
||||
-BCH_ERR_btree_node_read_err_must_retry,
|
||||
0,
|
||||
c, ca, b, NULL, NULL,
|
||||
bset_bad_seq,
|
||||
"incorrect sequence number (wrong btree node)");
|
||||
}
|
||||
|
||||
btree_err_on(BTREE_NODE_ID(bn) != b->c.btree_id,
|
||||
-BCH_ERR_btree_node_read_err_must_retry,
|
||||
0,
|
||||
c, ca, b, i, NULL,
|
||||
btree_node_bad_btree,
|
||||
"incorrect btree id");
|
||||
|
||||
btree_err_on(BTREE_NODE_LEVEL(bn) != b->c.level,
|
||||
-BCH_ERR_btree_node_read_err_must_retry,
|
||||
0,
|
||||
c, ca, b, i, NULL,
|
||||
btree_node_bad_level,
|
||||
"incorrect level");
|
||||
@ -410,7 +350,7 @@ int bch2_validate_bset(struct bch_fs *c, struct bch_dev *ca,
|
||||
}
|
||||
|
||||
btree_err_on(!bpos_eq(b->data->min_key, bp->min_key),
|
||||
-BCH_ERR_btree_node_read_err_must_retry,
|
||||
0,
|
||||
c, ca, b, NULL, NULL,
|
||||
btree_node_bad_min_key,
|
||||
"incorrect min_key: got %s should be %s",
|
||||
@ -421,7 +361,7 @@ int bch2_validate_bset(struct bch_fs *c, struct bch_dev *ca,
|
||||
}
|
||||
|
||||
btree_err_on(!bpos_eq(bn->max_key, b->key.k.p),
|
||||
-BCH_ERR_btree_node_read_err_must_retry,
|
||||
0,
|
||||
c, ca, b, i, NULL,
|
||||
btree_node_bad_max_key,
|
||||
"incorrect max key %s",
|
||||
@ -433,7 +373,7 @@ int bch2_validate_bset(struct bch_fs *c, struct bch_dev *ca,
|
||||
BSET_BIG_ENDIAN(i), write, bn);
|
||||
|
||||
btree_err_on(bch2_bkey_format_invalid(c, &bn->format, write, &buf1),
|
||||
-BCH_ERR_btree_node_read_err_bad_node,
|
||||
0,
|
||||
c, ca, b, i, NULL,
|
||||
btree_node_bad_format,
|
||||
"invalid bkey format: %s\n%s", buf1.buf,
|
||||
@ -508,7 +448,9 @@ static inline int btree_node_read_bkey_cmp(const struct btree *b,
|
||||
?: (int) bkey_deleted(r) - (int) bkey_deleted(l);
|
||||
}
|
||||
|
||||
int bch2_validate_bset_keys(struct bch_fs *c, struct btree *b,
|
||||
int bch2_validate_bset_keys(struct bch_fs *c,
|
||||
struct bch_dev *ca,
|
||||
struct btree *b,
|
||||
struct bset *i, int write,
|
||||
struct bch_io_failures *failed,
|
||||
struct printbuf *err_msg)
|
||||
@ -527,8 +469,8 @@ int bch2_validate_bset_keys(struct bch_fs *c, struct btree *b,
|
||||
unsigned next_good_key;
|
||||
|
||||
if (btree_err_on(bkey_p_next(k) > vstruct_last(i),
|
||||
-BCH_ERR_btree_node_read_err_fixable,
|
||||
c, NULL, b, i, k,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, i, k,
|
||||
btree_node_bkey_past_bset_end,
|
||||
"key extends past end of bset")) {
|
||||
i->u64s = cpu_to_le16((u64 *) k - i->_data);
|
||||
@ -536,15 +478,15 @@ int bch2_validate_bset_keys(struct bch_fs *c, struct btree *b,
|
||||
}
|
||||
|
||||
if (btree_err_on(k->format > KEY_FORMAT_CURRENT,
|
||||
-BCH_ERR_btree_node_read_err_fixable,
|
||||
c, NULL, b, i, k,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, i, k,
|
||||
btree_node_bkey_bad_format,
|
||||
"invalid bkey format %u", k->format))
|
||||
goto drop_this_key;
|
||||
|
||||
if (btree_err_on(!bkeyp_u64s_valid(&b->format, k),
|
||||
-BCH_ERR_btree_node_read_err_fixable,
|
||||
c, NULL, b, i, k,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, i, k,
|
||||
btree_node_bkey_bad_u64s,
|
||||
"bad k->u64s %u (min %u max %zu)", k->u64s,
|
||||
bkeyp_key_u64s(&b->format, k),
|
||||
@ -578,8 +520,8 @@ int bch2_validate_bset_keys(struct bch_fs *c, struct btree *b,
|
||||
prt_printf(&buf, " > ");
|
||||
bch2_bkey_to_text(&buf, u.k);
|
||||
|
||||
if (btree_err(-BCH_ERR_btree_node_read_err_fixable,
|
||||
c, NULL, b, i, k,
|
||||
if (btree_err(FSCK_CAN_FIX,
|
||||
c, ca, b, i, k,
|
||||
btree_node_bkey_out_of_order,
|
||||
"%s", buf.buf))
|
||||
goto drop_this_key;
|
||||
@ -665,13 +607,13 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
|
||||
sort_iter_init(iter, b, (btree_blocks(c) + 1) * 2);
|
||||
|
||||
if (bch2_meta_read_fault("btree"))
|
||||
btree_err(-BCH_ERR_btree_node_read_err_must_retry,
|
||||
btree_err(0,
|
||||
c, ca, b, NULL, NULL,
|
||||
btree_node_fault_injected,
|
||||
"dynamic fault");
|
||||
|
||||
btree_err_on(le64_to_cpu(b->data->magic) != bset_magic(c),
|
||||
-BCH_ERR_btree_node_read_err_must_retry,
|
||||
0,
|
||||
c, ca, b, NULL, NULL,
|
||||
btree_node_bad_magic,
|
||||
"bad magic: want %llx, got %llx",
|
||||
@ -697,8 +639,8 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
|
||||
|
||||
btree_err_on(!good_csum_type,
|
||||
bch2_csum_type_is_encryption(BSET_CSUM_TYPE(i))
|
||||
? -BCH_ERR_btree_node_read_err_must_retry
|
||||
: -BCH_ERR_btree_node_read_err_want_retry,
|
||||
? 0
|
||||
: FSCK_CAN_FIX,
|
||||
c, ca, b, i, NULL,
|
||||
bset_unknown_csum,
|
||||
"unknown checksum type %llu", BSET_CSUM_TYPE(i));
|
||||
@ -706,7 +648,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
|
||||
if (first) {
|
||||
sectors = vstruct_sectors(b->data, c->block_bits);
|
||||
if (btree_err_on(b->written + sectors > (ptr_written ?: btree_sectors(c)),
|
||||
-BCH_ERR_btree_node_read_err_fixable,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, i, NULL,
|
||||
bset_past_end_of_btree_node,
|
||||
"bset past end of btree node (offset %u len %u but written %zu)",
|
||||
@ -719,7 +661,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
|
||||
bch2_io_error(ca, BCH_MEMBER_ERROR_checksum);
|
||||
|
||||
btree_err_on(csum_bad,
|
||||
-BCH_ERR_btree_node_read_err_want_retry,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, i, NULL,
|
||||
bset_bad_csum,
|
||||
"%s",
|
||||
@ -742,7 +684,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
|
||||
bch2_bpos_to_text(&buf, b->data->max_key);
|
||||
|
||||
btree_err_on(b->data->keys.seq != bp->seq,
|
||||
-BCH_ERR_btree_node_read_err_must_retry,
|
||||
0,
|
||||
c, ca, b, NULL, NULL,
|
||||
btree_node_bad_seq,
|
||||
"got wrong btree node: got\n%s",
|
||||
@ -752,7 +694,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
|
||||
buf.buf));
|
||||
} else {
|
||||
btree_err_on(!b->data->keys.seq,
|
||||
-BCH_ERR_btree_node_read_err_must_retry,
|
||||
0,
|
||||
c, ca, b, NULL, NULL,
|
||||
btree_node_bad_seq,
|
||||
"bad btree header: seq 0\n%s",
|
||||
@ -763,14 +705,14 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
|
||||
|
||||
btree_err_on(btree_node_type_is_extents(btree_node_type(b)) &&
|
||||
!BTREE_NODE_NEW_EXTENT_OVERWRITE(b->data),
|
||||
-BCH_ERR_btree_node_read_err_incompatible,
|
||||
c, NULL, b, NULL, NULL,
|
||||
0,
|
||||
c, ca, b, NULL, NULL,
|
||||
btree_node_unsupported_version,
|
||||
"btree node does not have NEW_EXTENT_OVERWRITE set");
|
||||
} else {
|
||||
sectors = vstruct_sectors(bne, c->block_bits);
|
||||
if (btree_err_on(b->written + sectors > (ptr_written ?: btree_sectors(c)),
|
||||
-BCH_ERR_btree_node_read_err_fixable,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, i, NULL,
|
||||
bset_past_end_of_btree_node,
|
||||
"bset past end of btree node (offset %u len %u but written %zu)",
|
||||
@ -783,7 +725,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
|
||||
bch2_io_error(ca, BCH_MEMBER_ERROR_checksum);
|
||||
|
||||
btree_err_on(csum_bad,
|
||||
-BCH_ERR_btree_node_read_err_want_retry,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, i, NULL,
|
||||
bset_bad_csum,
|
||||
"%s",
|
||||
@ -808,7 +750,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
|
||||
if (!b->written)
|
||||
btree_node_set_format(b, b->data->format);
|
||||
|
||||
ret = bch2_validate_bset_keys(c, b, i, READ, failed, err_msg);
|
||||
ret = bch2_validate_bset_keys(c, ca, b, i, READ, failed, err_msg);
|
||||
if (ret)
|
||||
goto fsck_err;
|
||||
|
||||
@ -819,14 +761,14 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
|
||||
true);
|
||||
|
||||
btree_err_on(blacklisted && first,
|
||||
-BCH_ERR_btree_node_read_err_fixable,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, i, NULL,
|
||||
bset_blacklisted_journal_seq,
|
||||
"first btree node btree/bset.has blacklisted journal seq (%llu)",
|
||||
le64_to_cpu(i->journal_seq));
|
||||
|
||||
btree_err_on(blacklisted && ptr_written,
|
||||
-BCH_ERR_btree_node_read_err_fixable,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, i, NULL,
|
||||
first_bset_blacklisted_journal_seq,
|
||||
"found blacklisted bset (journal seq %llu) in btree node at offset %u-%u/%u",
|
||||
@ -847,7 +789,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
|
||||
|
||||
if (ptr_written) {
|
||||
btree_err_on(b->written < ptr_written,
|
||||
-BCH_ERR_btree_node_read_err_want_retry,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, NULL, NULL,
|
||||
btree_node_data_missing,
|
||||
"btree node data missing: expected %u sectors, found %u",
|
||||
@ -860,7 +802,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
|
||||
!bch2_journal_seq_is_blacklisted(c,
|
||||
le64_to_cpu(bne->keys.journal_seq),
|
||||
true),
|
||||
-BCH_ERR_btree_node_read_err_want_retry,
|
||||
FSCK_CAN_FIX,
|
||||
c, ca, b, NULL, NULL,
|
||||
btree_node_bset_after_end,
|
||||
"found bset signature after last bset");
|
||||
@ -955,12 +897,29 @@ static void btree_node_read_work(struct work_struct *work)
|
||||
bch2_btree_pos_to_text(&buf, c, b);
|
||||
prt_newline(&buf);
|
||||
|
||||
goto start;
|
||||
while (1) {
|
||||
ret = bch2_bkey_pick_read_device(c,
|
||||
bkey_i_to_s_c(&b->key),
|
||||
&failed, &rb->pick, -1);
|
||||
if (ret <= 0)
|
||||
if (rb->have_ioref)
|
||||
enumerated_ref_put(&ca->io_ref[READ], BCH_DEV_READ_REF_btree_node_read);
|
||||
rb->have_ioref = false;
|
||||
|
||||
if (!bio->bi_status) {
|
||||
memset(&bio->bi_iter, 0, sizeof(bio->bi_iter));
|
||||
bio->bi_iter.bi_size = btree_buf_bytes(b);
|
||||
|
||||
if (bch2_btree_read_corrupt_device == rb->pick.ptr.dev ||
|
||||
bch2_btree_read_corrupt_device < 0)
|
||||
bch2_maybe_corrupt_bio(bio, bch2_btree_read_corrupt_ratio);
|
||||
|
||||
ret = bch2_btree_node_read_done(c, ca, b, &failed, &buf);
|
||||
} else {
|
||||
ret = __bch2_err_throw(c, -blk_status_to_bch_err(bio->bi_status));
|
||||
bch2_mark_io_failure(&failed, &rb->pick, ret);
|
||||
}
|
||||
|
||||
if (!ret ||
|
||||
bch2_bkey_pick_read_device(c,
|
||||
bkey_i_to_s_c(&b->key),
|
||||
&failed, &rb->pick, -1) <= 0)
|
||||
break;
|
||||
|
||||
ca = bch2_dev_get_ioref(c, rb->pick.ptr.dev, READ, BCH_DEV_READ_REF_btree_node_read);
|
||||
@ -979,29 +938,6 @@ static void btree_node_read_work(struct work_struct *work)
|
||||
|
||||
bch2_account_io_completion(ca, BCH_MEMBER_ERROR_read,
|
||||
rb->start_time, !bio->bi_status);
|
||||
start:
|
||||
if (rb->have_ioref)
|
||||
enumerated_ref_put(&ca->io_ref[READ], BCH_DEV_READ_REF_btree_node_read);
|
||||
rb->have_ioref = false;
|
||||
|
||||
if (bio->bi_status) {
|
||||
bch2_mark_io_failure(&failed, &rb->pick,
|
||||
__bch2_err_throw(c, -blk_status_to_bch_err(bio->bi_status)));
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(&bio->bi_iter, 0, sizeof(bio->bi_iter));
|
||||
bio->bi_iter.bi_size = btree_buf_bytes(b);
|
||||
|
||||
if (bch2_btree_read_corrupt_device == rb->pick.ptr.dev ||
|
||||
bch2_btree_read_corrupt_device < 0)
|
||||
bch2_maybe_corrupt_bio(bio, bch2_btree_read_corrupt_ratio);
|
||||
|
||||
ret = bch2_btree_node_read_done(c, ca, b, &failed, &buf);
|
||||
if (ret != -BCH_ERR_btree_node_read_err_want_retry &&
|
||||
ret != -BCH_ERR_btree_node_read_err_must_retry &&
|
||||
!bch2_err_matches(ret, BCH_ERR_blockdev_io_error))
|
||||
break;
|
||||
}
|
||||
|
||||
bch2_io_failures_to_text(&buf, c, &failed);
|
||||
@ -1019,7 +955,7 @@ start:
|
||||
|
||||
set_btree_node_read_error(b);
|
||||
bch2_btree_lost_data(c, &buf, b->c.btree_id);
|
||||
prt_printf(&buf, "ret %s", bch2_err_str(ret));
|
||||
prt_printf(&buf, "error %s\n", bch2_err_str(ret));
|
||||
} else if (failed.nr) {
|
||||
/* Separate ratelimit states for soft vs. hard errors */
|
||||
buf.suppress = !__bch2_ratelimit(c, &c->btree.read_errors_soft);
|
||||
@ -1028,19 +964,18 @@ start:
|
||||
prt_printf(&buf, "retry success");
|
||||
else
|
||||
prt_printf(&buf, "repair success");
|
||||
|
||||
if ((failed.nr || btree_node_need_rewrite(b)) &&
|
||||
c->recovery.curr_pass != BCH_RECOVERY_PASS_scan_for_btree_nodes) {
|
||||
prt_printf(&buf, " (rewriting node)");
|
||||
bch2_btree_node_rewrite_async(c, b);
|
||||
}
|
||||
|
||||
prt_newline(&buf);
|
||||
} else {
|
||||
buf.suppress = true;
|
||||
}
|
||||
|
||||
if ((failed.nr ||
|
||||
btree_node_need_rewrite(b)) &&
|
||||
!btree_node_read_error(b) &&
|
||||
c->recovery.curr_pass != BCH_RECOVERY_PASS_scan_for_btree_nodes) {
|
||||
prt_printf(&buf, " (rewriting node)");
|
||||
bch2_btree_node_rewrite_async(c, b);
|
||||
}
|
||||
prt_newline(&buf);
|
||||
|
||||
if (!buf.suppress)
|
||||
bch2_print_str(c, ret ? KERN_ERR : KERN_NOTICE, buf.buf);
|
||||
|
||||
|
||||
@ -76,8 +76,8 @@ static inline int bset_encrypt(struct bch_fs *c, struct bset *i, unsigned offset
|
||||
|
||||
void bch2_btree_node_drop_keys_outside_node(struct btree *);
|
||||
|
||||
int bch2_validate_bset_keys(struct bch_fs *, struct btree *,
|
||||
struct bset *, int,
|
||||
int bch2_validate_bset_keys(struct bch_fs *, struct bch_dev *,
|
||||
struct btree *, struct bset *, int,
|
||||
struct bch_io_failures *,
|
||||
struct printbuf *);
|
||||
int bch2_validate_bset(struct bch_fs *, struct bch_dev *,
|
||||
|
||||
@ -173,7 +173,7 @@ static void btree_node_write_work(struct work_struct *work)
|
||||
bch2_devs_list_to_text(&msg.m, c, &d);
|
||||
prt_newline(&msg.m);
|
||||
} else {
|
||||
prt_printf(&msg.m, "%s\n", bch2_err_str(ret));
|
||||
prt_printf(&msg.m, "error %s\n", bch2_err_str(ret));
|
||||
bch2_fs_emergency_read_only2(c, &msg.m);
|
||||
}
|
||||
}
|
||||
@ -241,7 +241,7 @@ static int validate_bset_for_write(struct bch_fs *c, struct btree *b,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = bch2_validate_bset_keys(c, b, i, WRITE, NULL, NULL) ?:
|
||||
ret = bch2_validate_bset_keys(c, NULL, b, i, WRITE, NULL, NULL) ?:
|
||||
bch2_validate_bset(c, NULL, b, i, b->written, WRITE, NULL, NULL);
|
||||
if (ret) {
|
||||
bch2_inconsistent_error(c);
|
||||
|
||||
@ -738,7 +738,7 @@ static void bch2_rbio_retry(struct work_struct *work)
|
||||
if (rbio->self_healing)
|
||||
prt_str(&msg.m, ", self healing");
|
||||
} else
|
||||
prt_str(&msg.m, bch2_err_str(ret));
|
||||
prt_printf(&msg.m, "error %s", bch2_err_str(ret));
|
||||
prt_newline(&msg.m);
|
||||
|
||||
if (!bkey_deleted(&sk.k->k)) {
|
||||
|
||||
@ -610,7 +610,7 @@ static void __bch2_write_index(struct bch_write_op *op)
|
||||
bch2_devs_list_to_text(&msg.m, c, &d);
|
||||
prt_newline(&msg.m);
|
||||
} else {
|
||||
prt_printf(&msg.m, "all replicated writes failed\n");
|
||||
prt_printf(&msg.m, "error %s\n", bch2_err_str(ret));
|
||||
}
|
||||
|
||||
if (ret)
|
||||
|
||||
@ -395,11 +395,6 @@
|
||||
x(BCH_ERR_data_read, data_read_buffer_too_small) \
|
||||
x(BCH_ERR_data_read, data_read_key_overwritten) \
|
||||
x(0, rbio_narrow_crcs_fail) \
|
||||
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_must_retry) \
|
||||
x(BCH_ERR_btree_node_read_err, btree_node_read_err_bad_node) \
|
||||
x(BCH_ERR_btree_node_read_err, btree_node_read_err_incompatible) \
|
||||
x(0, nopromote) \
|
||||
x(BCH_ERR_nopromote, nopromote_may_not) \
|
||||
x(BCH_ERR_nopromote, nopromote_no_rewrites) \
|
||||
|
||||
@ -117,6 +117,19 @@ static unsigned loglevel_opt(struct bch_fs *c)
|
||||
|
||||
void bch2_print_str_loglevel(struct bch_fs *c, int loglevel, const char *str)
|
||||
{
|
||||
unsigned len = strlen(str);
|
||||
/*
|
||||
* printbufs leave extra spaces from indent level after the last
|
||||
* newline; strip them
|
||||
*/
|
||||
unsigned l = len;
|
||||
while (l && str[l - 1] == ' ')
|
||||
--l;
|
||||
if (!l || str[l - 1] == '\n')
|
||||
len = l;
|
||||
if (!len)
|
||||
return;
|
||||
|
||||
if (loglevel < 0)
|
||||
loglevel = c->prev_loglevel;
|
||||
else
|
||||
@ -145,7 +158,7 @@ void bch2_print_str_loglevel(struct bch_fs *c, int loglevel, const char *str)
|
||||
struct stdio_redirect *stdio = bch2_fs_stdio_redirect(c);
|
||||
|
||||
if (unlikely(stdio)) {
|
||||
bch2_stdio_redirect_write(stdio, true, str, strlen(str));
|
||||
bch2_stdio_redirect_write(stdio, true, str, len);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -249,12 +249,7 @@ static CLOSURE_CALLBACK(journal_write_done)
|
||||
bch2_devs_list_to_text(&msg.m, c, &w->devs_written);
|
||||
prt_newline(&msg.m);
|
||||
} else {
|
||||
if (err == -BCH_ERR_journal_write_err)
|
||||
prt_printf(&msg.m, "unable to write journal to sufficient devices\n");
|
||||
else
|
||||
prt_printf(&msg.m, "journal write error marking replicas: %s\n",
|
||||
bch2_err_str(err));
|
||||
|
||||
prt_printf(&msg.m, "error %s\n", bch2_err_str(err));
|
||||
bch2_fs_emergency_read_only2(c, &msg.m);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ static void __printbuf_do_indent(struct printbuf *out, unsigned pos)
|
||||
|
||||
static inline void printbuf_do_indent(struct printbuf *out, unsigned pos)
|
||||
{
|
||||
if (out->has_indent_or_tabstops && !out->suppress_indent_tabstop_handling)
|
||||
if (out->has_indent_or_tabstops)
|
||||
__printbuf_do_indent(out, pos);
|
||||
}
|
||||
|
||||
|
||||
@ -91,7 +91,6 @@ struct printbuf {
|
||||
enum printbuf_si si_units:1;
|
||||
bool human_readable_units:1;
|
||||
bool has_indent_or_tabstops:1;
|
||||
bool suppress_indent_tabstop_handling:1;
|
||||
u8 nr_tabstops;
|
||||
|
||||
/*
|
||||
|
||||
@ -402,7 +402,7 @@ static long bch2_ioctl_subvolume_destroy(struct bch_fs *c, struct file *filp,
|
||||
|
||||
CLASS(printbuf, err)();
|
||||
long ret = __bch2_ioctl_subvolume_destroy(c, filp, arg_v2, &err);
|
||||
if (ret)
|
||||
if (ret && err.buf)
|
||||
bch_err_msg(c, ret, "%s", err.buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user