From: Yehuda Sadeh Date: Fri, 21 Feb 2014 00:25:21 +0000 (-0800) Subject: rgw: cache bucket info X-Git-Tag: v0.83~97^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7fb6a3d68f4745b277507d9737aaf397b2272ffa;p=ceph.git rgw: cache bucket info This is really a partial implementation, so should only be used for testing. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index b1025e2fd5cc..934ca9651313 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -5447,9 +5447,32 @@ int RGWRados::convert_old_bucket_info(void *ctx, string& bucket_name) return 0; } +struct bucket_info_entry { + RGWBucketInfo info; + time_t mtime; + map attrs; +}; + +static map binfo_cache; +static RWLock binfo_lock("binfo_lock"); + int RGWRados::get_bucket_info(void *ctx, const string& bucket_name, RGWBucketInfo& info, time_t *pmtime, map *pattrs) { + binfo_lock.get_read(); + map::iterator uiter = binfo_cache.find(bucket_name); + if (uiter != binfo_cache.end()) { + bucket_info_entry& e = uiter->second; + info = e.info; + if (pattrs) + *pattrs = e.attrs; + if (pmtime) + *pmtime = e.mtime; + binfo_lock.unlock(); + return 0; + } + binfo_lock.unlock(); + bufferlist bl; RGWBucketEntryPoint entry_point; @@ -5486,12 +5509,25 @@ int RGWRados::get_bucket_info(void *ctx, const string& bucket_name, RGWBucketInf string oid; get_bucket_meta_oid(entry_point.bucket, oid); - ret = get_bucket_instance_from_oid(ctx, oid, info, pmtime, pattrs); - info.ep_objv = ot.read_version; + bucket_info_entry e; + + ret = get_bucket_instance_from_oid(ctx, oid, e.info, &e.mtime, &e.attrs); + e.info.ep_objv = ot.read_version; + info = e.info; if (ret < 0) { info.bucket.name = bucket_name; return ret; } + + if (pmtime) + *pmtime = e.mtime; + if (pattrs) + *pattrs = e.attrs; + + binfo_lock.get_write(); + binfo_cache[bucket_name] = e; + binfo_lock.unlock(); + return 0; } diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 8d6b72deab3c..44e77ea56e2f 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -206,9 +206,6 @@ static RWLock uinfo_lock("uinfo_lock"); int rgw_get_user_info_from_index(RGWRados *store, string& key, rgw_bucket& bucket, RGWUserInfo& info, RGWObjVersionTracker *objv_tracker, time_t *pmtime) { - bufferlist bl; - RGWUID uid; - uinfo_lock.get_read(); map::iterator uiter = uinfo_cache.find(key); if (uiter != uinfo_cache.end()) { @@ -223,6 +220,9 @@ int rgw_get_user_info_from_index(RGWRados *store, string& key, rgw_bucket& bucke } uinfo_lock.unlock(); + bufferlist bl; + RGWUID uid; + user_info_entry e; int ret = rgw_get_system_obj(store, NULL, bucket, key, bl, NULL, &e.mtime);