cache: resize struct namecache to a multiply of alignment
For example struct namecache on amd64 is 100 bytes, but it has to occupies 104. Use the extra bytes to support longer names.
This commit is contained in:
parent
8b62cebea7
commit
bb48255cf5
@ -159,6 +159,17 @@ struct namecache_ts {
|
||||
* alignment for everyone. Note this is a nop for 64-bit platforms.
|
||||
*/
|
||||
#define CACHE_ZONE_ALIGNMENT UMA_ALIGNOF(time_t)
|
||||
#define CACHE_PATH_CUTOFF 39
|
||||
|
||||
#define CACHE_ZONE_SMALL_SIZE (sizeof(struct namecache) + CACHE_PATH_CUTOFF + 1)
|
||||
#define CACHE_ZONE_SMALL_TS_SIZE (sizeof(struct namecache_ts) + CACHE_PATH_CUTOFF + 1)
|
||||
#define CACHE_ZONE_LARGE_SIZE (sizeof(struct namecache) + NAME_MAX + 1)
|
||||
#define CACHE_ZONE_LARGE_TS_SIZE (sizeof(struct namecache_ts) + NAME_MAX + 1)
|
||||
|
||||
_Static_assert((CACHE_ZONE_SMALL_SIZE % (CACHE_ZONE_ALIGNMENT + 1)) == 0, "bad zone size");
|
||||
_Static_assert((CACHE_ZONE_SMALL_TS_SIZE % (CACHE_ZONE_ALIGNMENT + 1)) == 0, "bad zone size");
|
||||
_Static_assert((CACHE_ZONE_LARGE_SIZE % (CACHE_ZONE_ALIGNMENT + 1)) == 0, "bad zone size");
|
||||
_Static_assert((CACHE_ZONE_LARGE_TS_SIZE % (CACHE_ZONE_ALIGNMENT + 1)) == 0, "bad zone size");
|
||||
|
||||
#define nc_vp n_un.nu_vp
|
||||
#define nc_neg n_un.nu_neg
|
||||
@ -339,8 +350,6 @@ static uma_zone_t __read_mostly cache_zone_small_ts;
|
||||
static uma_zone_t __read_mostly cache_zone_large;
|
||||
static uma_zone_t __read_mostly cache_zone_large_ts;
|
||||
|
||||
#define CACHE_PATH_CUTOFF 35
|
||||
|
||||
static struct namecache *
|
||||
cache_alloc(int len, int ts)
|
||||
{
|
||||
@ -2095,22 +2104,14 @@ nchinit(void *dummy __unused)
|
||||
{
|
||||
u_int i;
|
||||
|
||||
cache_zone_small = uma_zcreate("S VFS Cache",
|
||||
sizeof(struct namecache) + CACHE_PATH_CUTOFF + 1,
|
||||
NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT,
|
||||
UMA_ZONE_ZINIT);
|
||||
cache_zone_small_ts = uma_zcreate("STS VFS Cache",
|
||||
sizeof(struct namecache_ts) + CACHE_PATH_CUTOFF + 1,
|
||||
NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT,
|
||||
UMA_ZONE_ZINIT);
|
||||
cache_zone_large = uma_zcreate("L VFS Cache",
|
||||
sizeof(struct namecache) + NAME_MAX + 1,
|
||||
NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT,
|
||||
UMA_ZONE_ZINIT);
|
||||
cache_zone_large_ts = uma_zcreate("LTS VFS Cache",
|
||||
sizeof(struct namecache_ts) + NAME_MAX + 1,
|
||||
NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT,
|
||||
UMA_ZONE_ZINIT);
|
||||
cache_zone_small = uma_zcreate("S VFS Cache", CACHE_ZONE_SMALL_SIZE,
|
||||
NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT, UMA_ZONE_ZINIT);
|
||||
cache_zone_small_ts = uma_zcreate("STS VFS Cache", CACHE_ZONE_SMALL_TS_SIZE,
|
||||
NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT, UMA_ZONE_ZINIT);
|
||||
cache_zone_large = uma_zcreate("L VFS Cache", CACHE_ZONE_LARGE_SIZE,
|
||||
NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT, UMA_ZONE_ZINIT);
|
||||
cache_zone_large_ts = uma_zcreate("LTS VFS Cache", CACHE_ZONE_LARGE_TS_SIZE,
|
||||
NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT, UMA_ZONE_ZINIT);
|
||||
|
||||
VFS_SMR_ZONE_SET(cache_zone_small);
|
||||
VFS_SMR_ZONE_SET(cache_zone_small_ts);
|
||||
|
Loading…
Reference in New Issue
Block a user