fellow_cache: Generalize/refactor fellow_cache_seg_deref_locked()

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