Differentiate memory allocation priorities

Fixes #11 I hope
parent ed28758e
......@@ -1608,7 +1608,7 @@ fellow_cache_seglists_load(const struct fellow_cache *fc,
static struct fellow_cache_res
fellow_cache_obj_new(const struct fellow_cache *fc,
size_t dsk_sz, unsigned nseg_guess)
size_t dsk_sz, unsigned nseg_guess, uint8_t pri)
{
struct fellow_disk_obj *fdo;
struct fellow_cache_obj *fco;
......@@ -1647,7 +1647,7 @@ fellow_cache_obj_new(const struct fellow_cache *fc,
assert(u <= UINT8_MAX);
bits = (uint8_t)u;
fco_mem = buddy_alloc1_ptr_page_wait(fc->membuddy,
FEP_GET, bits, 0);
pri, bits, 0);
if (FC_INJ || fco_mem.ptr == NULL) {
fcr = FCR_ALLOCFAIL("fco_mem alloc failed");
goto err;
......@@ -1657,7 +1657,7 @@ fellow_cache_obj_new(const struct fellow_cache *fc,
}
fdo_mem = buddy_alloc1_ptr_extent_wait(fc->membuddy,
FEP_GET, asz, 0);
pri, asz, 0);
if (FC_INJ || fdo_mem.ptr == NULL) {
fcr = FCR_ALLOCFAIL("fdo_mem alloc failed");
......@@ -1726,7 +1726,7 @@ fellow_busy_obj_alloc(struct fellow_cache *fc,
size_t sz, asz, dsk_sz;
uint16_t ldsegs;
fbo_mem = buddy_alloc1_ptr_extent_wait(fc->membuddy, FEP_GET,
fbo_mem = buddy_alloc1_ptr_extent_wait(fc->membuddy, FEP_NEW,
sizeof *fbo, 0);
fbo = fbo_mem.ptr;
if (fbo == NULL) {
......@@ -1763,7 +1763,7 @@ fellow_busy_obj_alloc(struct fellow_cache *fc,
// XXX delay to allow new objects during FP_INIT ?
fds_seg = FC_INJ ? buddy_off_extent_nil :
fellow_region_alloc(fc->ffd, FEP_GET, dsk_sz, 0);
fellow_region_alloc(fc->ffd, FEP_NEW, dsk_sz, 0);
if (fds_seg.off < 0) {
fcr = FCR_ALLOCFAIL("fds region");
fellow_cache_res_check(fc, fcr);
......@@ -1771,7 +1771,7 @@ fellow_busy_obj_alloc(struct fellow_cache *fc,
return (fcr);
}
fcr = fellow_cache_obj_new(fc, dsk_sz, ldsegs);
fcr = fellow_cache_obj_new(fc, dsk_sz, ldsegs, FEP_NEW);
if (fcr.status != fcr_ok) {
fellow_cache_res_check(fc, fcr);
fellow_region_free(fc->ffd, &fds_seg);
......@@ -1872,7 +1872,7 @@ fellow_busy_region_alloc(struct fellow_busy *fbo, size_t size, int8_t cram)
fdr = &fbo->region[fbo->nregion];
*fdr = FC_INJ ? buddy_off_extent_nil :
fellow_region_alloc(fc->ffd, FEP_GET, size, cram);
fellow_region_alloc(fc->ffd, FEP_SPC, size, cram);
if (fdr->off < 0) {
return (NULL);
......@@ -3098,7 +3098,6 @@ fellow_cache_seg_ref_in(struct fellow_cache *fc, enum fellow_cache_io_e type,
assert(n <= BUDDY_REQS_MAX);
reqs = BUDDY_REQS_STK(fc->membuddy, BUDDY_REQS_MAX);
BUDDY_REQS_PRI(reqs, FEP_GET);
rets = BUDDY_RETURNS_STK(fc->membuddy, BUDDY_RETURNS_MAX);
memset(iosegs, 0, sizeof iosegs);
......@@ -3110,6 +3109,7 @@ fellow_cache_seg_ref_in(struct fellow_cache *fc, enum fellow_cache_io_e type,
for (r = 0, u = 0; u < n; u++) {
struct fellow_disk_seg *fds;
BUDDY_REQS_PRI(reqs, FEP_ITER);
fcs = segs[u];
CHECK_OBJ_NOTNULL(fcs, FELLOW_CACHE_SEG_MAGIC);
......@@ -3469,7 +3469,7 @@ static size_t fellow_busy_seg_memalloc(buddy_t *membuddy,
AZ(fcs->alloc.ptr);
AZ(fcs->alloc.size);
fcs->alloc = buddy_alloc1_ptr_extent_wait(membuddy, FEP_GET,
fcs->alloc = buddy_alloc1_ptr_extent_wait(membuddy, FEP_SPC,
fds->seg.size, 0);
if (fcs->alloc.ptr == NULL)
......@@ -3971,7 +3971,7 @@ fellow_cache_obj_prepread(const struct fellow_cache *fc, fellow_disk_block fdba)
if (! PAOK(sz))
return (FCR_IOFAIL("bad size"));
fcr = fellow_cache_obj_new(fc, sz, 0);
fcr = fellow_cache_obj_new(fc, sz, 0, FEP_GET);
if (fcr.status != fcr_ok)
return (fcr);
......
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