scoutfs: allow smaller btree keys and values

Now that we're using small file system keys we can dramatically shrink
the maximum allowed btree keys and values.  This more accurately matches
the current users and less us fit more possible items in each block.
Which lets us turn the block size way down and still have multiple worst
case largest items per block.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2018-04-12 11:59:53 -07:00
committed by Zach Brown
parent 31286ad714
commit e145267c05
2 changed files with 7 additions and 16 deletions

View File

@@ -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);
}
/*

View File

@@ -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