fellow_cache: Fix fellow_cache_seglist_init() size parameter semantics

before this change, it was taken as excluding struct fellow_cache_seglist,
and was correctly used at the call sites changed with this commit
(where (size - sizeof *fcsl) was used as the argument).

However, for the calls from
- fellow_busy_obj_alloc()
- fellow_cache_obj_get()

there was a mismatch with the caller's size value.
parent ca0e1e1e
......@@ -2026,7 +2026,7 @@ fellow_cache_seglist_associate(
}
static struct fellow_cache_seglist *
fellow_cache_seglist_init(void *ptr, size_t space, struct fellow_cache_obj *fco)
fellow_cache_seglist_init(void *ptr, size_t sz, struct fellow_cache_obj *fco)
{
struct fellow_cache_seglist *fcsl = ptr;
size_t lsegs;
......@@ -2034,9 +2034,11 @@ fellow_cache_seglist_init(void *ptr, size_t space, struct fellow_cache_obj *fco)
AN(ptr);
assert(PAOK(ptr));
assert(space >= sizeof *fcsl);
assert(sz > sizeof *fcsl);
INIT_OBJ(fcsl, FELLOW_CACHE_SEGLIST_MAGIC);
lsegs = space / sizeof *fcsl->segs;
sz -= sizeof *fcsl;
lsegs = sz / sizeof *fcsl->segs;
assert(lsegs > 0);
assert(lsegs <= UINT16_MAX);
fcsl->lsegs = (uint16_t)lsegs;
for (u = 0; u < fcsl->lsegs; u++)
......@@ -2236,8 +2238,7 @@ fellow_cache_seglists_load(struct worker *wrk, void *priv)
}
ofcsl = fcsl;
fcsl = fellow_cache_seglist_init(fcsl_mem.ptr,
fcsl_mem.size - sizeof *fcsl, fco);
fcsl = fellow_cache_seglist_init(fcsl_mem.ptr, fcsl_mem.size, fco);
fcsl->next = fcsl_pending;
fcsl->fdsl_sz = fdsl_mem.size;
fcsl->fcsl_sz = fcsl_mem.size;
......@@ -2889,8 +2890,7 @@ fellow_disk_seglist_alloc(struct fellow_busy *fbo,
fdsl = fellow_disk_seglist_init(fdsl_mem.ptr, ldsegs, fht);
AN(fcsl_mem.ptr);
fcsl = fellow_cache_seglist_init(fcsl_mem.ptr,
fcsl_mem.size - sizeof *fcsl, fbo->fco);
fcsl = fellow_cache_seglist_init(fcsl_mem.ptr, fcsl_mem.size, fbo->fco);
fellow_cache_seglist_associate(fcsl, fdsl, FCS_USABLE);
......@@ -5917,8 +5917,7 @@ struct objcore **ocp, uintptr_t priv2, unsigned crit)
err = FC_ERRSTR("first disk seglist fcsl alloc failed");
goto err;
}
fco->fcsl = fellow_cache_seglist_init(fcsl_mem.ptr,
fcsl_mem.size - sizeof *fco->fcsl, fco);
fco->fcsl = fellow_cache_seglist_init(fcsl_mem.ptr, fcsl_mem.size, fco);
AN(fco->fcsl);
fco->fcsl->fcsl_sz = fcsl_mem.size;
}
......
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