/** * mds_bmap_timeotbl_mdsi - * Returns bmapseqno. */ uint64_t mds_bmap_timeotbl_mdsi(struct bmap_mds_lease *bml, int flags) { uint64_t seq = 0; if (flags & BTE_DEL) { bml->bml_flags &= ~BML_TIMEOQ; mds_bmap_timeotbl_remove(bml); return (BMAPSEQ_ANY); } if (flags & BTE_REATTACH) { /* BTE_REATTACH is only called from startup context. */ spinlock(&mdsBmapTimeoTbl.btt_lock); if (mdsBmapTimeoTbl.btt_maxseq < bml->bml_seq) /* * A lease has been found in odtable whose * issuance was after that of the last HWM * journal entry. (HWM's are journaled every * BMAP_SEQLOG_FACTOR times.) */ seq = mdsBmapTimeoTbl.btt_maxseq = bml->bml_seq; else if (mdsBmapTimeoTbl.btt_minseq > bml->bml_seq) /* This lease has already expired. */ seq = BMAPSEQ_ANY; else seq = bml->bml_seq; freelock(&mdsBmapTimeoTbl.btt_lock); } else { seq = mds_bmap_timeotbl_getnextseq(); } BML_LOCK(bml); if (bml->bml_flags & BML_TIMEOQ) { mds_bmap_timeotbl_remove(bml); pll_addtail(&mdsBmapTimeoTbl.btt_leases, bml); } else { bml->bml_flags |= BML_TIMEOQ; pll_addtail(&mdsBmapTimeoTbl.btt_leases, bml); } BML_ULOCK(bml); return (seq); }
void _lc_move(struct psc_listcache *plc, void *p, int flags) { int locked; locked = LIST_CACHE_RLOCK(plc); lc_remove(plc, p); if (flags & PLCBF_TAIL) pll_addtail(&plc->plc_pll, p); else pll_addhead(&plc->plc_pll, p); LIST_CACHE_URLOCK(plc, locked); }
/* * Add an item entry to a list cache. * @plc: the list cache to add to. * @p: item to add. * @flags: PLCBF_* operational behavior flags. */ int _lc_add(struct psc_listcache *plc, void *p, int flags, void *cmpf) { int locked; locked = LIST_CACHE_RLOCK(plc); if (plc->plc_flags & PLCF_DYING) { pfl_assert(flags & PLCBF_DYINGOK); LIST_CACHE_URLOCK(plc, locked); return (0); } if (cmpf && (flags & PLCBF_REVERSE)) pll_add_sorted_backwards(&plc->plc_pll, p, cmpf); else if (cmpf) pll_add_sorted(&plc->plc_pll, p, cmpf); else if (flags & PLCBF_TAIL) pll_addtail(&plc->plc_pll, p); else pll_addhead(&plc->plc_pll, p); if (plc->plc_nseen) pfl_opstat_incr(plc->plc_nseen); /* * There is now an item available; wake up waiters who think the * list is empty. */ if (flags & PLCBF_WAKEALL) pfl_waitq_wakeall(&plc->plc_wq_empty); else pfl_waitq_wakeone(&plc->plc_wq_empty); LIST_CACHE_URLOCK(plc, locked); return (1); }