From 68d7a2e2cb21d34f10b75ac49913123a714f8205 Mon Sep 17 00:00:00 2001 From: Andy Grover Date: Thu, 8 Oct 2020 10:44:17 -0700 Subject: [PATCH] scoutfs: align items in item cache to 8 bytes This will ensure structs, which are internally 8 byte aligned, will remain so when in the item cache. 16 bytes alignment doesn't seem like it's needed so just do 8. Signed-off-by: Andy Grover --- kmod/src/item.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kmod/src/item.c b/kmod/src/item.c index 06104ad4..c25e74a5 100644 --- a/kmod/src/item.c +++ b/kmod/src/item.c @@ -145,11 +145,11 @@ struct cached_item { char val[0]; }; -#define CACHED_ITEM_ALIGN 16 +#define CACHED_ITEM_ALIGN 8 static int item_val_bytes(int val_len) { - return offsetof(struct cached_item, val[val_len]); + return round_up(offsetof(struct cached_item, val[val_len]), CACHED_ITEM_ALIGN); } /* @@ -400,7 +400,7 @@ static struct cached_item *alloc_item(struct cached_page *pg, return NULL; item = page_address(pg->page) + pg->page_off; - pg->page_off += round_up(item_val_bytes(val_len), CACHED_ITEM_ALIGN); + pg->page_off += item_val_bytes(val_len); RB_CLEAR_NODE(&item->node); INIT_LIST_HEAD(&item->dirty_head);