From: Yehuda Sadeh Date: Fri, 23 May 2014 23:50:41 +0000 (-0700) Subject: rgw: chain binfo_cache to multiple cache entries X-Git-Tag: v0.83~97^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c616358fe0f46bbfc46c56f2889ecf9225872ff5;p=ceph.git rgw: chain binfo_cache to multiple cache entries Need to chain it to both the entry point and to the instance. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_cache.cc b/src/rgw/rgw_cache.cc index c402352a02ad..9eb4a4bb765a 100644 --- a/src/rgw/rgw_cache.cc +++ b/src/rgw/rgw_cache.cc @@ -61,14 +61,16 @@ bool ObjectCache::chain_cache_entry(rgw_cache_entry_info& cache_info, RGWChained { RWLock::WLocker l(lock); - ldout(cct, 10) << "cache put: name=" << cache_info.cache_locator << dendl; + ldout(cct, 10) << "chain_cache_entry: cache_locator=" << cache_info.cache_locator << dendl; map::iterator iter = cache_map.find(cache_info.cache_locator); if (iter == cache_map.end()) { + ldout(cct, 20) << "chain_cache_entry: couldn't find cachce locator" << dendl; return false; } ObjectCacheEntry& entry = iter->second; if (entry.gen != cache_info.gen) { + ldout(cct, 20) << "chain_cache_entry: entry.gen (" << entry.gen << ") != cache_info.gen (" << cache_info.gen << ")" << dendl; return false; } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 8fbb1382d5ff..468c932532db 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -5394,11 +5394,12 @@ int RGWRados::get_bucket_entrypoint_info(void *ctx, const string& bucket_name, RGWBucketEntryPoint& entry_point, RGWObjVersionTracker *objv_tracker, time_t *pmtime, - map *pattrs) + map *pattrs, + rgw_cache_entry_info *cache_info) { bufferlist bl; - int ret = rgw_get_system_obj(this, ctx, zone.domain_root, bucket_name, bl, objv_tracker, pmtime, pattrs); + int ret = rgw_get_system_obj(this, ctx, zone.domain_root, bucket_name, bl, objv_tracker, pmtime, pattrs, cache_info); if (ret < 0) { return ret; } @@ -5474,7 +5475,8 @@ int RGWRados::get_bucket_info(void *ctx, const string& bucket_name, RGWBucketInf RGWBucketEntryPoint entry_point; time_t ep_mtime; RGWObjVersionTracker ot; - int ret = get_bucket_entrypoint_info(ctx, bucket_name, entry_point, &ot, &ep_mtime, pattrs); + rgw_cache_entry_info entry_cache_info; + int ret = get_bucket_entrypoint_info(ctx, bucket_name, entry_point, &ot, &ep_mtime, pattrs, &entry_cache_info); if (ret < 0) { info.bucket.name = bucket_name; /* only init this field */ return ret; @@ -5520,7 +5522,10 @@ int RGWRados::get_bucket_info(void *ctx, const string& bucket_name, RGWBucketInf if (pattrs) *pattrs = e.attrs; - binfo_cache.put(this, bucket_name, &e, cache_info); + /* chain to both bucket entry point and bucket instance */ + if (binfo_cache.put(this, bucket_name, &e, entry_cache_info)) { + binfo_cache.put(this, bucket_name, &e, cache_info); + } return 0; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 5fe817c2a303..04128e0fd836 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1750,7 +1750,7 @@ public: map *pattrs); int put_bucket_instance_info(RGWBucketInfo& info, bool exclusive, time_t mtime, map *pattrs); int get_bucket_entrypoint_info(void *ctx, const string& bucket_name, RGWBucketEntryPoint& entry_point, RGWObjVersionTracker *objv_tracker, time_t *pmtime, - map *pattrs); + map *pattrs, rgw_cache_entry_info *cache_info = NULL); int get_bucket_instance_info(void *ctx, const string& meta_key, RGWBucketInfo& info, time_t *pmtime, map *pattrs); int get_bucket_instance_info(void *ctx, rgw_bucket& bucket, RGWBucketInfo& info, time_t *pmtime, map *pattrs); int get_bucket_instance_from_oid(void *ctx, string& oid, RGWBucketInfo& info, time_t *pmtime, map *pattrs,