fellow_cache_obj: Make fco mem an extent to enable trimming

parent 0767fa84
......@@ -626,7 +626,7 @@ struct fellow_cache_obj {
struct fellow_cache_lru *lru;
uint64_t ntouched;
struct buddy_ptr_page fco_mem; // nil == embedded
struct buddy_ptr_extent fco_mem;
struct buddy_ptr_page fco_dowry;
pthread_mutex_t mtx;
......@@ -1544,7 +1544,7 @@ fellow_cache_obj_free(const struct fellow_cache *fc,
{
struct fellow_cache_obj *fco;
struct fellow_cache_seg *fcs;
struct buddy_ptr_page mem;
struct buddy_ptr_extent mem;
TAKE_OBJ_NOTNULL(fco, fcop, FELLOW_CACHE_OBJ_MAGIC);
......@@ -1577,10 +1577,8 @@ fellow_cache_obj_free(const struct fellow_cache *fc,
if (fco->fco_dowry.bits)
buddy_return1_ptr_page(fc->membuddy, &fco->fco_dowry);
TAKE(mem, fco->fco_mem);
if (mem.bits) {
assert(mem.ptr == fco);
buddy_return1_ptr_page(fc->membuddy, &mem);
}
assert(mem.ptr == fco);
buddy_return1_ptr_extent(fc->membuddy, &mem);
}
/*
......@@ -1954,7 +1952,7 @@ fellow_cache_obj_new(
struct fellow_cache_res fcr;
struct fellow_cache_seg *fcs;
struct buddy_reqs *reqs;
struct buddy_ptr_page fco_mem = buddy_ptr_page_nil;
struct buddy_ptr_extent fco_mem = buddy_ptr_extent_nil;
struct buddy_ptr_extent fdo_mem = buddy_ptr_extent_nil;
size_t asz, mem_sz, ssz;
unsigned u;
......@@ -1972,7 +1970,7 @@ fellow_cache_obj_new(
nseg_guess = 1;
}
mem_sz = sizeof *fco + nseg_guess * sizeof *fcs;
mem_sz = (size_t)1 << log2up(sizeof *fco + nseg_guess * sizeof *fcs);
asz = (size_t)1 << log2up(dsk_sz);
// dowry is largest, so we allocate it first
......@@ -1982,7 +1980,7 @@ fellow_cache_obj_new(
AN(buddy_req_page(reqs, fc->tune->chunk_exponent, 0));
if (fbo_mem != NULL)
AN(buddy_req_extent(reqs, sizeof(struct fellow_busy), 0));
AN(buddy_req_page(reqs, log2up(mem_sz), 0));
AN(buddy_req_extent(reqs, mem_sz, 0));
AN(buddy_req_extent(reqs, asz, 0));
u = buddy_alloc_wait(reqs);
......@@ -1999,7 +1997,7 @@ fellow_cache_obj_new(
if (fbo_mem != NULL)
*fbo_mem = buddy_get_next_ptr_extent(reqs);
fco_mem = buddy_get_next_ptr_page(reqs);
fco_mem = buddy_get_next_ptr_extent(reqs);
fdo_mem = buddy_get_next_ptr_extent(reqs);
buddy_alloc_wait_done(reqs);
......@@ -2018,7 +2016,7 @@ fellow_cache_obj_new(
AZ(pthread_mutex_init(&fco->mtx, &fc_mtxattr_errorcheck));
AZ(pthread_cond_init(&fco->cond, NULL));
ssz = ((size_t)1 << fco_mem.bits) - sizeof *fco;
ssz = fco_mem.size - sizeof *fco;
(void) fellow_cache_seglist_init(&fco->seglist, ssz, fco);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment