MT#55283 store metadata head pointer

Put a pointer to the shard itself in the beginning of the buffer. This
facilitates quick lookup.

Change-Id: I0109d77e56afac3189775dd708970288f175dfe6
pull/1923/head
Richard Fuchs 1 month ago
parent f7fbe490b0
commit 69e634f94a

@ -90,9 +90,17 @@ static struct bpool_shard *bufferpool_new_shard(struct bufferpool *bp) {
struct bpool_shard *ret = g_new0(__typeof(*ret), 1);
ret->bp = bp;
ret->buf = buf;
ret->end = buf + BUFFERPOOL_SHARD_SIZE;
struct bpool_shard **head = buf;
*head = ret;
static_assert(BUFFERPOOL_ALIGN(sizeof(void *)) == BUFFERPOOL_OVERHEAD,
"wrong BUFFERPOOL_OVERHEAD size");
buf += BUFFERPOOL_ALIGN(sizeof(void *));
ret->empty = buf;
ret->head = buf;
ret->end = buf + BUFFERPOOL_SHARD_SIZE;
RWLOCK_W(&bpool_shards_lock);

@ -7,7 +7,7 @@
#define BUFFERPOOL_ALIGN(x) (((x + BUFFERPOOL_ALIGNMENT - 1) / BUFFERPOOL_ALIGNMENT) * BUFFERPOOL_ALIGNMENT)
#define BUFFERPOOL_SHARD_SIZE (1LL<<24) // 16 MB, must be a power of two
#define BUFFERPOOL_OVERHEAD (0) // storage space not available
#define BUFFERPOOL_OVERHEAD BUFFERPOOL_ALIGN(sizeof(void *)) // storage space not available
#define BUFFERPOOL_BOTTOM_MASK (BUFFERPOOL_SHARD_SIZE - 1)
#define BUFFERPOOL_TOP_MASK (~BUFFERPOOL_BOTTOM_MASK)

Loading…
Cancel
Save