]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: bucket info uses cache chaining
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 21 Mar 2014 22:09:26 +0000 (15:09 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 11 Jun 2014 06:08:57 +0000 (23:08 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 25bfdc1a9f356974c34eb84f85ca9068aad874df..8fbb1382d5fffc53e2c8997259ff9ee8b5021571 100644 (file)
@@ -5367,13 +5367,14 @@ int RGWRados::get_bucket_instance_info(void *ctx, rgw_bucket& bucket, RGWBucketI
 }
 
 int RGWRados::get_bucket_instance_from_oid(void *ctx, string& oid, RGWBucketInfo& info,
-                                           time_t *pmtime, map<string, bufferlist> *pattrs)
+                                           time_t *pmtime, map<string, bufferlist> *pattrs,
+                                           rgw_cache_entry_info *cache_info)
 {
   ldout(cct, 20) << "reading from " << zone.domain_root << ":" << oid << dendl;
 
   bufferlist epbl;
 
-  int ret = rgw_get_system_obj(this, ctx, zone.domain_root, oid, epbl, &info.objv_tracker, pmtime, pattrs);
+  int ret = rgw_get_system_obj(this, ctx, zone.domain_root, oid, epbl, &info.objv_tracker, pmtime, pattrs, cache_info);
   if (ret < 0) {
     return ret;
   }
@@ -5453,25 +5454,20 @@ struct bucket_info_entry {
   map<string, bufferlist> attrs;
 };
 
-static map<string, bucket_info_entry> binfo_cache;
-static RWLock binfo_lock("binfo_lock");
+static RGWChainedCacheImpl<bucket_info_entry> binfo_cache;
 
 int RGWRados::get_bucket_info(void *ctx, const string& bucket_name, RGWBucketInfo& info,
                               time_t *pmtime, map<string, bufferlist> *pattrs)
 {
-  binfo_lock.get_read();
-  map<string, bucket_info_entry>::iterator uiter = binfo_cache.find(bucket_name);
-  if (uiter != binfo_cache.end()) {
-    bucket_info_entry& e = uiter->second;
+  bucket_info_entry e;
+  if (binfo_cache.find(bucket_name, &e)) {
     info = e.info;
     if (pattrs)
       *pattrs = e.attrs;
     if (pmtime)
       *pmtime = e.mtime;
-    binfo_lock.unlock();
     return 0;
   }
-  binfo_lock.unlock();
 
   bufferlist bl;
 
@@ -5509,9 +5505,9 @@ int RGWRados::get_bucket_info(void *ctx, const string& bucket_name, RGWBucketInf
   string oid;
   get_bucket_meta_oid(entry_point.bucket, oid);
 
-  bucket_info_entry e;
+  rgw_cache_entry_info cache_info;
 
-  ret = get_bucket_instance_from_oid(ctx, oid, e.info, &e.mtime, &e.attrs);
+  ret = get_bucket_instance_from_oid(ctx, oid, e.info, &e.mtime, &e.attrs, &cache_info);
   e.info.ep_objv = ot.read_version;
   info = e.info;
   if (ret < 0) {
@@ -5524,9 +5520,7 @@ int RGWRados::get_bucket_info(void *ctx, const string& bucket_name, RGWBucketInf
   if (pattrs)
     *pattrs = e.attrs;
 
-  binfo_lock.get_write();
-  binfo_cache[bucket_name] = e;
-  binfo_lock.unlock();
+  binfo_cache.put(this, bucket_name, &e, cache_info);
 
   return 0;
 }
index ea1d276e650557832979917573dde09f5ce3d34e..5fe817c2a3035d726c3d3c210f1d6afcce076301 100644 (file)
@@ -1753,7 +1753,8 @@ public:
                                  map<string, bufferlist> *pattrs);
   int get_bucket_instance_info(void *ctx, const string& meta_key, RGWBucketInfo& info, time_t *pmtime, map<string, bufferlist> *pattrs);
   int get_bucket_instance_info(void *ctx, rgw_bucket& bucket, RGWBucketInfo& info, time_t *pmtime, map<string, bufferlist> *pattrs);
-  int get_bucket_instance_from_oid(void *ctx, string& oid, RGWBucketInfo& info, time_t *pmtime, map<string, bufferlist> *pattrs);
+  int get_bucket_instance_from_oid(void *ctx, string& oid, RGWBucketInfo& info, time_t *pmtime, map<string, bufferlist> *pattrs,
+                                   rgw_cache_entry_info *cache_info = NULL);
 
   int convert_old_bucket_info(void *ctx, string& bucket_name);
   virtual int get_bucket_info(void *ctx, const string& bucket_name, RGWBucketInfo& info,