From e145267c050fa6526901ed95990db0b3249585c1 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 12 Apr 2018 11:59:53 -0700 Subject: [PATCH] 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 --- kmod/src/btree.c | 11 ++++------- kmod/src/format.h | 12 +++--------- 2 files changed, 7 insertions(+), 16 deletions(-) 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