Make memstv assertions more precise

Because of #14 I would like to understand if #13 is really a genuine
bug or some odd consequence
parent ba4d52f5
......@@ -238,6 +238,12 @@ stv_stvfe(const struct stevedore *stv)
* memocs mutate to dskocs for memory LRU
*/
#define assert_memstv(stvfe, stv) do { \
assert(stv != NULL); \
assert(stv != stvfe->dskstv); \
assert(stv == stvfe->memstv); \
} while (0)
static inline struct fellow_cache_obj *
stvfe_memoc_fco(const struct stevedore *stv, const struct stvfe *stvfe,
const struct objcore *oc)
......@@ -245,7 +251,7 @@ stvfe_memoc_fco(const struct stevedore *stv, const struct stvfe *stvfe,
void *priv;
CHECK_OBJ_NOTNULL(stvfe, STVFE_MAGIC);
assert(stv == stvfe->memstv);
assert_memstv(stvfe, stv);
AN(oc->stobj->priv2);
// CST implies a memory barrier
priv = __atomic_load_n(/*lint --e(605)*/ &oc->stobj->priv,
......@@ -370,7 +376,7 @@ sfemem_free(struct worker *wrk, struct objcore *memoc)
const struct objhead *oh = memoc->objhead;
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
assert(stv == stvfe->memstv);
assert_memstv(stvfe, stv);
AN(stv->lru);
// ref fellow_busy_done()
......@@ -846,7 +852,7 @@ sfemem_getattr(struct worker *wrk, struct objcore *memoc, enum obj_attr attr,
size_t len;
void *r;
assert(stv == stvfe->memstv);
assert_memstv(stvfe, stv);
r = fellow_cache_obj_getattr(stvfe->fc, fco, attr, &len);
if (slen)
......@@ -898,7 +904,7 @@ sfemem_setattr(struct worker *wrk, struct objcore *memoc, enum obj_attr attr,
const struct stevedore *stv = oc_stv(wrk, memoc);
const struct stvfe *stvfe = stv_stvfe(stv);
assert(stv == stvfe->memstv);
assert_memstv(stvfe, stv);
assert(len >= 0);
return (fellow_busy_setattr(sfe_fbo(memoc), attr, (size_t)len, ptr));
......@@ -911,7 +917,7 @@ sfemem_touch(struct worker *wrk, struct objcore *memoc, vtim_real now)
const struct stvfe *stvfe = stv_stvfe(stv);
struct fellow_cache_obj *fco = stvfe_memoc_fco(stv, stvfe, memoc);
assert(stv == stvfe->memstv);
assert_memstv(stvfe, stv);
if (/*lint --e(641)*/ memoc->flags & OC_F_PRIVATE ||
isnan(memoc->last_lru))
......@@ -1607,7 +1613,7 @@ stvfe_mutate(struct worker *wrk, struct objcore *oc)
const struct stevedore *stv = oc_stv(wrk, oc);
const struct stvfe *stvfe = stv_stvfe(stv);
assert(stv == stvfe->memstv);
assert_memstv(stvfe, stv);
AN(oc->stobj->priv);
AN(oc->stobj->priv2);
......
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