From 9e12d7e7d140b1440e636a08df166d29450140b0 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Wed, 14 Jul 2021 10:57:02 -0400 Subject: [PATCH] rgw: Rename REMOVE_OBJ to INVALIDATE_OBJ Also rename ObjectCache::remove to ObjectCache::invalidate_remove Since we're depending on these message types/functions having invalidate semantics but NOT caching a negative result, rename and leave a comment for clarity. Fixes: https://tracker.ceph.com/issues/51674 Signed-off-by: Adam C. Emerson --- src/rgw/rgw_cache.cc | 4 +++- src/rgw/rgw_cache.h | 4 ++-- src/rgw/services/svc_sys_obj_cache.cc | 16 ++++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/rgw/rgw_cache.cc b/src/rgw/rgw_cache.cc index e82c142eb02..b46c26d5b99 100644 --- a/src/rgw/rgw_cache.cc +++ b/src/rgw/rgw_cache.cc @@ -212,7 +212,9 @@ void ObjectCache::put(const DoutPrefixProvider *dpp, const string& name, ObjectC target.version = info.version; } -bool ObjectCache::remove(const DoutPrefixProvider *dpp, const string& name) +// WARNING: This function /must not/ be modified to cache a +// negative lookup. It must only invalidate. +bool ObjectCache::invalidate_remove(const DoutPrefixProvider *dpp, const string& name) { std::unique_lock l{lock}; diff --git a/src/rgw/rgw_cache.h b/src/rgw/rgw_cache.h index c00d1a36c8f..08eaffca226 100644 --- a/src/rgw/rgw_cache.h +++ b/src/rgw/rgw_cache.h @@ -17,7 +17,7 @@ enum { UPDATE_OBJ, - REMOVE_OBJ, + INVALIDATE_OBJ, }; #define CACHE_FLAG_DATA 0x01 @@ -204,7 +204,7 @@ public: } void put(const DoutPrefixProvider *dpp, const std::string& name, ObjectCacheInfo& bl, rgw_cache_entry_info *cache_info); - bool remove(const DoutPrefixProvider *dpp, const std::string& name); + bool invalidate_remove(const DoutPrefixProvider *dpp, const std::string& name); void set_ctx(CephContext *_cct) { cct = _cct; lru_window = cct->_conf->rgw_cache_lru_size / 2; diff --git a/src/rgw/services/svc_sys_obj_cache.cc b/src/rgw/services/svc_sys_obj_cache.cc index a914067ca75..5690f8d14c5 100644 --- a/src/rgw/services/svc_sys_obj_cache.cc +++ b/src/rgw/services/svc_sys_obj_cache.cc @@ -94,10 +94,10 @@ int RGWSI_SysObj_Cache::remove(const DoutPrefixProvider *dpp, normalize_pool_and_obj(obj.pool, obj.oid, pool, oid); string name = normal_name(pool, oid); - cache.remove(dpp, name); + cache.invalidate_remove(dpp, name); ObjectCacheInfo info; - int r = distribute_cache(dpp, name, obj, info, REMOVE_OBJ, y); + int r = distribute_cache(dpp, name, obj, info, INVALIDATE_OBJ, y); if (r < 0) { ldpp_dout(dpp, 0) << "ERROR: " << __func__ << "(): failed to distribute cache: r=" << r << dendl; } @@ -270,7 +270,7 @@ int RGWSI_SysObj_Cache::set_attrs(const DoutPrefixProvider *dpp, if (r < 0) ldpp_dout(dpp, 0) << "ERROR: failed to distribute cache for " << obj << dendl; } else { - cache.remove(dpp, name); + cache.invalidate_remove(dpp, name); } return ret; @@ -314,7 +314,7 @@ int RGWSI_SysObj_Cache::write(const DoutPrefixProvider *dpp, if (r < 0) ldpp_dout(dpp, 0) << "ERROR: failed to distribute cache for " << obj << dendl; } else { - cache.remove(dpp, name); + cache.invalidate_remove(dpp, name); } return ret; @@ -349,7 +349,7 @@ int RGWSI_SysObj_Cache::write_data(const DoutPrefixProvider *dpp, if (r < 0) ldpp_dout(dpp, 0) << "ERROR: failed to distribute cache for " << obj << dendl; } else { - cache.remove(dpp, name); + cache.invalidate_remove(dpp, name); } return ret; @@ -461,8 +461,8 @@ int RGWSI_SysObj_Cache::watch_cb(const DoutPrefixProvider *dpp, case UPDATE_OBJ: cache.put(dpp, name, info.obj_info, NULL); break; - case REMOVE_OBJ: - cache.remove(dpp, name); + case INVALIDATE_OBJ: + cache.invalidate_remove(dpp, name); break; default: ldpp_dout(dpp, 0) << "WARNING: got unknown notification op: " << info.op << dendl; @@ -633,7 +633,7 @@ int RGWSI_SysObj_Cache::ASocketHandler::call_inspect(const std::string& target, int RGWSI_SysObj_Cache::ASocketHandler::call_erase(const std::string& target) { - return svc->cache.remove(dpp, target); + return svc->cache.invalidate_remove(dpp, target); } int RGWSI_SysObj_Cache::ASocketHandler::call_zap() -- 2.39.5