From 45b1db15f677b36d971909b406fc2f210a3dca7d Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Sat, 25 Jan 2020 02:00:29 +0300 Subject: [PATCH] os/bluestore: get rid off OnodeShardCache::_touch. Onode pinning does the same for us. Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueStore.cc | 22 +++++++++------------- src/os/bluestore/BlueStore.h | 1 - 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 66a60d6620c15..b36a045720509 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -813,14 +813,6 @@ struct LruOnodeCacheShard : public BlueStore::OnodeCacheShard { } --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)); @@ -1589,10 +1581,11 @@ BlueStore::OnodeRef BlueStore::OnodeSpace::lookup(const ghobject_t& oid) } 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; } } @@ -1648,9 +1641,12 @@ void BlueStore::OnodeSpace::rename( 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(); diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 24d83aafbd3fc..f07d0fad770b6 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1216,7 +1216,6 @@ public: 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 validator) { std::lock_guard l(lock); -- 2.39.5