fellow_cache: Generalize/refactor fellow_cache_seg_deref_locked()

parent 44a49b98
......@@ -2920,24 +2920,33 @@ fellow_cache_seg_ref_locked(struct fellow_lru_chgbatch *lcb,
return (refcnt);
}
/* return new refcnt */
static inline unsigned
fellow_cache_seg_deref_locked(struct fellow_lru_chgbatch *lcb,
struct fellow_cache_seg *fcs)
fellow_cache_seg_deref_n_locked(struct fellow_lru_chgbatch *lcb,
struct fellow_cache_seg *fcs, unsigned nref)
{
unsigned refcnt;
int o, n;
AN(fcs->refcnt);
refcnt = --fcs->refcnt;
assert(fcs->refcnt >= nref);
fcs->refcnt -= nref;
refcnt = fcs->refcnt;
o = fellow_cache_shouldlru(fcs->state, fcs->fco->oc, refcnt + 1);
o = fellow_cache_shouldlru(fcs->state, fcs->fco->oc, refcnt + nref);
n = fellow_cache_shouldlru(fcs->state, fcs->fco->oc, refcnt);
fellow_cache_lru_chg(lcb, fcs, n - o);
return (refcnt);
}
/* return new refcnt */
static inline unsigned
fellow_cache_seg_deref_locked(struct fellow_lru_chgbatch *lcb,
struct fellow_cache_seg *fcs)
{
return (fellow_cache_seg_deref_n_locked(lcb, fcs, 1));
}
static void
fellow_cache_seg_unbusy(struct fellow_busy *fbo, struct fellow_cache_seg *fcs){
const enum fcos_state from = FCS_BUSY, to = FCS_WRITING;
......
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