fellow_busy: Change fellow_busy_seg_memalloc() signature and pull in cram logic

parent a64785e8
...@@ -4238,7 +4238,7 @@ fellow_busy_body_seg_next(struct fellow_busy *fbo) ...@@ -4238,7 +4238,7 @@ fellow_busy_body_seg_next(struct fellow_busy *fbo)
* *
* used for body and auxattr * used for body and auxattr
*/ */
static size_t fellow_busy_seg_memalloc(buddy_t *membuddy, static size_t fellow_busy_seg_memalloc(const struct fellow_busy *fbo,
struct fellow_cache_seg *fcs, int8_t cram) struct fellow_cache_seg *fcs, int8_t cram)
{ {
struct fellow_disk_seg *fds; struct fellow_disk_seg *fds;
...@@ -4257,8 +4257,12 @@ static size_t fellow_busy_seg_memalloc(buddy_t *membuddy, ...@@ -4257,8 +4257,12 @@ static size_t fellow_busy_seg_memalloc(buddy_t *membuddy,
if (FC_INJ) if (FC_INJ)
return (0); return (0);
fcs->alloc = buddy_alloc1_ptr_extent_wait(membuddy, FEP_SPC, if (cram != 0) {
fds->seg.size, cram); cram = buddy_cramlimit_bits(fds->seg.size,
fbo->fc->tune->cram, MIN_FELLOW_BITS);
}
fcs->alloc = buddy_alloc1_ptr_extent_wait(fbo->fc->membuddy,
FEP_SPC, fds->seg.size, cram);
if (fcs->alloc.ptr == NULL) if (fcs->alloc.ptr == NULL)
return (0); return (0);
...@@ -4303,7 +4307,7 @@ fellow_busy_seg_alloc(struct fellow_busy *fbo, ...@@ -4303,7 +4307,7 @@ fellow_busy_seg_alloc(struct fellow_busy *fbo,
if (fdr == NULL) if (fdr == NULL)
return (0); return (0);
fds->seg = *fdr; fds->seg = *fdr;
if (fellow_busy_seg_memalloc(fbo->fc->membuddy, fcs, 0) == 0) if (fellow_busy_seg_memalloc(fbo, fcs, 0) == 0)
// we do not need to free because we use the busy region // we do not need to free because we use the busy region
return (0); return (0);
return (1); return (1);
...@@ -4409,8 +4413,7 @@ fellow_busy_obj_getspace(struct fellow_busy *fbo, size_t *sz, uint8_t **ptr) ...@@ -4409,8 +4413,7 @@ fellow_busy_obj_getspace(struct fellow_busy *fbo, size_t *sz, uint8_t **ptr)
goto out; goto out;
} }
spc = fellow_busy_seg_memalloc(fbo->fc->membuddy, fcs, spc = fellow_busy_seg_memalloc(fbo, fcs, fbo->fc->tune->cram);
buddy_cramlimit_bits(spc, fbo->fc->tune->cram, MIN_FELLOW_BITS));
if (spc == 0) { if (spc == 0) {
fellow_busy_body_seg_return(fbo, fcs->disk_seg); fellow_busy_body_seg_return(fbo, fcs->disk_seg);
fcr = FCR_ALLOCFAIL("body memory seg alloc"); fcr = FCR_ALLOCFAIL("body memory seg alloc");
...@@ -6325,7 +6328,7 @@ t_cache(const char *fn, unsigned chksum) ...@@ -6325,7 +6328,7 @@ t_cache(const char *fn, unsigned chksum)
AN(fbo->body_seg); AN(fbo->body_seg);
assert(fbo->body_seg->state == FCS_DISK); assert(fbo->body_seg->state == FCS_DISK);
fbo->body_seg->state = FCS_USABLE; fbo->body_seg->state = FCS_USABLE;
AN(fellow_busy_seg_memalloc(membuddy, fbo->body_seg, 0)); AN(fellow_busy_seg_memalloc(fbo, fbo->body_seg, 0));
assert(fbo->nregion == FCO_MAX_REGIONS); assert(fbo->nregion == FCO_MAX_REGIONS);
test_bocdone(fbo, TRUST_ME(hash), 1); test_bocdone(fbo, TRUST_ME(hash), 1);
......
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