bcachefs: Add an .invalid method for bch2_btree_ptr_v2
It was using the method for btree_ptr_v1, but that wasn't checking all the fields. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
1fe9b1d33c
commit
fad7cfed79
2 changed files with 19 additions and 2 deletions
|
@ -157,7 +157,7 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k,
|
|||
|
||||
const char *bch2_btree_ptr_invalid(const struct bch_fs *c, struct bkey_s_c k)
|
||||
{
|
||||
if (bkey_val_u64s(k.k) > BKEY_BTREE_PTR_VAL_U64s_MAX)
|
||||
if (bkey_val_u64s(k.k) > BCH_REPLICAS_MAX)
|
||||
return "value too big";
|
||||
|
||||
return bch2_bkey_ptrs_invalid(c, k);
|
||||
|
@ -169,6 +169,22 @@ void bch2_btree_ptr_to_text(struct printbuf *out, struct bch_fs *c,
|
|||
bch2_bkey_ptrs_to_text(out, c, k);
|
||||
}
|
||||
|
||||
const char *bch2_btree_ptr_v2_invalid(const struct bch_fs *c, struct bkey_s_c k)
|
||||
{
|
||||
struct bkey_s_c_btree_ptr_v2 bp = bkey_s_c_to_btree_ptr_v2(k);
|
||||
|
||||
if (bkey_val_bytes(k.k) <= sizeof(*bp.v))
|
||||
return "value too small";
|
||||
|
||||
if (bkey_val_u64s(k.k) > BKEY_BTREE_PTR_VAL_U64s_MAX)
|
||||
return "value too big";
|
||||
|
||||
if (bp.v->min_key.snapshot)
|
||||
return "invalid min_key.snapshot";
|
||||
|
||||
return bch2_bkey_ptrs_invalid(c, k);
|
||||
}
|
||||
|
||||
void bch2_btree_ptr_v2_to_text(struct printbuf *out, struct bch_fs *c,
|
||||
struct bkey_s_c k)
|
||||
{
|
||||
|
|
|
@ -371,6 +371,7 @@ const char *bch2_btree_ptr_invalid(const struct bch_fs *, struct bkey_s_c);
|
|||
void bch2_btree_ptr_to_text(struct printbuf *, struct bch_fs *,
|
||||
struct bkey_s_c);
|
||||
|
||||
const char *bch2_btree_ptr_v2_invalid(const struct bch_fs *, struct bkey_s_c);
|
||||
void bch2_btree_ptr_v2_to_text(struct printbuf *, struct bch_fs *,
|
||||
struct bkey_s_c);
|
||||
void bch2_btree_ptr_v2_compat(enum btree_id, unsigned, unsigned,
|
||||
|
@ -383,7 +384,7 @@ void bch2_btree_ptr_v2_compat(enum btree_id, unsigned, unsigned,
|
|||
}
|
||||
|
||||
#define bch2_bkey_ops_btree_ptr_v2 (struct bkey_ops) { \
|
||||
.key_invalid = bch2_btree_ptr_invalid, \
|
||||
.key_invalid = bch2_btree_ptr_v2_invalid, \
|
||||
.val_to_text = bch2_btree_ptr_v2_to_text, \
|
||||
.swab = bch2_ptr_swab, \
|
||||
.compat = bch2_btree_ptr_v2_compat, \
|
||||
|
|
Loading…
Reference in a new issue