diff --git a/kmod/src/btree.c b/kmod/src/btree.c index 104b4e54..7fdb2b72 100644 --- a/kmod/src/btree.c +++ b/kmod/src/btree.c @@ -142,11 +142,10 @@ enum { /* * This greatest key value is stored down the right spine of the tree * and has to be sorted by memcmp() greater than all possible keys in - * all btrees. We give it room for a decent number of big-endian - * primary sort values. + * all btrees. */ -static char max_key[SCOUTFS_BTREE_GREATEST_KEY_LEN] = { - [0 ... (SCOUTFS_BTREE_GREATEST_KEY_LEN - 1)] = 0xff, +static char max_key[SCOUTFS_BTREE_MAX_KEY_LEN] = { + [0 ... (SCOUTFS_BTREE_MAX_KEY_LEN - 1)] = 0xff, }; /* number of contiguous bytes used by the item header, key, and value */ @@ -1262,9 +1261,7 @@ static bool invalid_item(void *key, unsigned key_len, unsigned val_len) { return WARN_ON_ONCE(key_len == 0) || WARN_ON_ONCE(key_len > SCOUTFS_BTREE_MAX_KEY_LEN) || - WARN_ON_ONCE(val_len > SCOUTFS_BTREE_MAX_VAL_LEN) || - WARN_ON_ONCE(key_len > SCOUTFS_BTREE_GREATEST_KEY_LEN && - cmp_keys(key, key_len, max_key, sizeof(max_key)) > 0); + WARN_ON_ONCE(val_len > SCOUTFS_BTREE_MAX_VAL_LEN); } /* diff --git a/kmod/src/format.h b/kmod/src/format.h index 27e467a5..29ea140c 100644 --- a/kmod/src/format.h +++ b/kmod/src/format.h @@ -121,15 +121,9 @@ struct scoutfs_key_be { __u8 _sk_fourth; }__packed; -/* - * Assert that we'll be able to represent all possible keys with 8 64bit - * primary sort values. - */ -#define SCOUTFS_BTREE_GREATEST_KEY_LEN 32 -/* level >0 segments can have a full key and some metadata */ -#define SCOUTFS_BTREE_MAX_KEY_LEN 320 -/* level 0 segments can have two full keys in the value :/ */ -#define SCOUTFS_BTREE_MAX_VAL_LEN 768 +/* chose reasonable max key and value lens that have room for some u64s */ +#define SCOUTFS_BTREE_MAX_KEY_LEN 40 +#define SCOUTFS_BTREE_MAX_VAL_LEN 64 /* * The min number of free bytes we must leave in a parent as we descend