}
--num;
}
- void _touch(BlueStore::Onode* o) override
- {
- ceph_assert(o->cached);
- if (!o->pinned) {
- lru.erase(lru.iterator_to(*o));
- lru.push_front(*o);
- }
- }
void _pin(BlueStore::Onode* o) override
{
lru.erase(lru.iterator_to(*o));
} else {
ldout(cache->cct, 30) << __func__ << " " << oid << " hit " << p->second
<< dendl;
- // assign before _touch to pin object if needed and avoid
- // cache touch
+ // This will pin onode and implicitly touch the cache when Onode
+ // eventually will become unpinned
o = p->second;
- cache->_touch(p->second.get());
+ ceph_assert(!o->cached || o->pinned);
+
hit = true;
}
}
oldo.reset(new Onode(o->c, old_oid, o->key));
po->second = oldo;
cache->_add(oldo.get(), 1);
- // add at new position and fix oid, key
+ // add at new position and fix oid, key.
+ // This will pin 'o' and implicitly touch cache
+ // when it will eventually become unpinned
onode_map.insert(make_pair(new_oid, o));
- cache->_touch(o.get());
+ ceph_assert(o->pinned);
+
o->oid = new_oid;
o->key = new_okey;
cache->_trim();
PerfCounters *logger);
virtual void _add(Onode* o, int level) = 0;
virtual void _rm(Onode* o) = 0;
- virtual void _touch(Onode* o) = 0;
void pin(Onode* o, std::function<bool ()> validator) {
std::lock_guard l(lock);