@@ -831,7 +831,7 @@ static int bset_key_invalid(struct bch_fs *c, struct btree *b,
831
831
(rw == WRITE ? bch2_bkey_val_invalid (c , k , READ , err ) : 0 );
832
832
}
833
833
834
- static bool __bkey_valid (struct bch_fs * c , struct btree * b ,
834
+ static bool bkey_packed_valid (struct bch_fs * c , struct btree * b ,
835
835
struct bset * i , struct bkey_packed * k )
836
836
{
837
837
if (bkey_p_next (k ) > vstruct_last (i ))
@@ -840,7 +840,7 @@ static bool __bkey_valid(struct bch_fs *c, struct btree *b,
840
840
if (k -> format > KEY_FORMAT_CURRENT )
841
841
return false;
842
842
843
- if (k -> u64s < bkeyp_key_u64s (& b -> format , k ))
843
+ if (! bkeyp_u64s_valid (& b -> format , k ))
844
844
return false;
845
845
846
846
struct printbuf buf = PRINTBUF ;
@@ -884,11 +884,13 @@ static int validate_bset_keys(struct bch_fs *c, struct btree *b,
884
884
"invalid bkey format %u" , k -> format ))
885
885
goto drop_this_key ;
886
886
887
- if (btree_err_on (k -> u64s < bkeyp_key_u64s (& b -> format , k ),
887
+ if (btree_err_on (! bkeyp_u64s_valid (& b -> format , k ),
888
888
- BCH_ERR_btree_node_read_err_fixable ,
889
889
c , NULL , b , i ,
890
890
btree_node_bkey_bad_u64s ,
891
- "k->u64s too small (%u < %u)" , k -> u64s , bkeyp_key_u64s (& b -> format , k )))
891
+ "bad k->u64s %u (min %u max %lu)" , k -> u64s ,
892
+ bkeyp_key_u64s (& b -> format , k ),
893
+ U8_MAX - BKEY_U64s + bkeyp_key_u64s (& b -> format , k )))
892
894
goto drop_this_key ;
893
895
894
896
if (!write )
@@ -947,13 +949,12 @@ static int validate_bset_keys(struct bch_fs *c, struct btree *b,
947
949
* do
948
950
*/
949
951
950
- if (!__bkey_valid (c , b , i , (void * ) ((u64 * ) k + next_good_key ))) {
952
+ if (!bkey_packed_valid (c , b , i , (void * ) ((u64 * ) k + next_good_key ))) {
951
953
for (next_good_key = 1 ;
952
954
next_good_key < (u64 * ) vstruct_last (i ) - (u64 * ) k ;
953
955
next_good_key ++ )
954
- if (__bkey_valid (c , b , i , (void * ) ((u64 * ) k + next_good_key )))
956
+ if (bkey_packed_valid (c , b , i , (void * ) ((u64 * ) k + next_good_key )))
955
957
goto got_good_key ;
956
-
957
958
}
958
959
959
960
/*
0 commit comments