From: Adam C. Emerson Date: Wed, 20 Dec 2017 22:06:32 +0000 (-0500) Subject: rgw: Plumb refresh logic into object cache X-Git-Tag: v10.2.11~170^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F19769%2Fhead;p=ceph.git rgw: Plumb refresh logic into object cache Now when we force a refetch of bucket info it will actually go to the OSD rather than simply using the objects in the object cache. Fixes: http://tracker.ceph.com/issues/22517 Signed-off-by: Adam C. Emerson (cherry picked from commit d997f657750faf920170843e62deacab70008d8b) Signed-off-by: Matt Benjamin --- diff --git a/src/rgw/rgw_cache.h b/src/rgw/rgw_cache.h index c984c48a4ec13..989d1cd7bd0f6 100644 --- a/src/rgw/rgw_cache.h +++ b/src/rgw/rgw_cache.h @@ -242,7 +242,8 @@ public: RGWObjVersionTracker *objv_tracker, rgw_obj& obj, bufferlist& bl, off_t ofs, off_t end, map *attrs, - rgw_cache_entry_info *cache_info); + rgw_cache_entry_info *cache_info, + boost::optional refresh_version = boost::none) override; int raw_obj_stat(rgw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch, map *attrs, bufferlist *first_chunk, RGWObjVersionTracker *objv_tracker); @@ -287,7 +288,8 @@ int RGWCache::get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::R RGWObjVersionTracker *objv_tracker, rgw_obj& obj, bufferlist& obl, off_t ofs, off_t end, map *attrs, - rgw_cache_entry_info *cache_info) + rgw_cache_entry_info *cache_info, + boost::optional refresh_version) { rgw_bucket bucket; string oid; @@ -304,8 +306,9 @@ int RGWCache::get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::R flags |= CACHE_FLAG_OBJV; if (attrs) flags |= CACHE_FLAG_XATTRS; - - if (cache.get(name, info, flags, cache_info) == 0) { + + if ((cache.get(name, info, flags, cache_info) == 0) && + (!refresh_version || !info.version.compare(&(*refresh_version)))) { if (info.status < 0) return info.status; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index bdee507d9f048..5a7abf9aac26c 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -9258,7 +9258,8 @@ int RGWRados::get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read RGWObjVersionTracker *objv_tracker, rgw_obj& obj, bufferlist& bl, off_t ofs, off_t end, map *attrs, - rgw_cache_entry_info *cache_info) + rgw_cache_entry_info *cache_info, + boost::optional) { rgw_bucket bucket; std::string oid, key; @@ -9309,12 +9310,16 @@ int RGWRados::get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read return bl.length(); } -int RGWRados::SystemObject::Read::read(int64_t ofs, int64_t end, bufferlist& bl, RGWObjVersionTracker *objv_tracker) +int RGWRados::SystemObject::Read::read(int64_t ofs, int64_t end, bufferlist& bl, + RGWObjVersionTracker *objv_tracker, + boost::optional refresh_version) { RGWRados *store = source->get_store(); rgw_obj& obj = source->get_obj(); - return store->get_system_obj(source->get_ctx(), state, objv_tracker, obj, bl, ofs, end, read_params.attrs, read_params.cache_info); + return store->get_system_obj(source->get_ctx(), state, objv_tracker, obj, bl, + ofs, end, read_params.attrs, + read_params.cache_info, refresh_version); } int RGWRados::SystemObject::Read::get_attr(const char *name, bufferlist& dest) @@ -10767,8 +10772,7 @@ void RGWRados::get_bucket_instance_obj(const rgw_bucket& bucket, rgw_obj& obj) } } -int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, const string& meta_key, RGWBucketInfo& info, - real_time *pmtime, map *pattrs) +int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, const string& meta_key, RGWBucketInfo& info, ceph::real_time *pmtime, std::map *pattrs) { int pos = meta_key.find(':'); if (pos < 0) { @@ -10780,8 +10784,7 @@ int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, const string& meta return get_bucket_instance_from_oid(obj_ctx, oid, info, pmtime, pattrs); } -int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, rgw_bucket& bucket, RGWBucketInfo& info, - real_time *pmtime, map *pattrs) +int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, const rgw_bucket& bucket, RGWBucketInfo& info, ceph::real_time *pmtime, std::map *pattrs) { string oid; if (bucket.oid.empty()) { @@ -10793,15 +10796,15 @@ int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, rgw_bucket& bucket return get_bucket_instance_from_oid(obj_ctx, oid, info, pmtime, pattrs); } -int RGWRados::get_bucket_instance_from_oid(RGWObjectCtx& obj_ctx, string& oid, RGWBucketInfo& info, - real_time *pmtime, map *pattrs, - rgw_cache_entry_info *cache_info) +int RGWRados::get_bucket_instance_from_oid(RGWObjectCtx& obj_ctx, const std::string& oid, RGWBucketInfo& info, ceph::real_time *pmtime, std::map *pattrs, rgw_cache_entry_info *cache_info, boost::optional refresh_version) { ldout(cct, 20) << "reading from " << get_zone_params().domain_root << ":" << oid << dendl; bufferlist epbl; - int ret = rgw_get_system_obj(this, obj_ctx, get_zone_params().domain_root, oid, epbl, &info.objv_tracker, pmtime, pattrs, cache_info); + int ret = rgw_get_system_obj(this, obj_ctx, get_zone_params().domain_root, + oid, epbl, &info.objv_tracker, pmtime, pattrs, + cache_info, refresh_version); if (ret < 0) { return ret; } @@ -10824,13 +10827,16 @@ int RGWRados::get_bucket_entrypoint_info(RGWObjectCtx& obj_ctx, RGWObjVersionTracker *objv_tracker, real_time *pmtime, map *pattrs, - rgw_cache_entry_info *cache_info) + rgw_cache_entry_info *cache_info, + boost::optional refresh_version) { bufferlist bl; string bucket_entry; rgw_make_bucket_entry_name(tenant_name, bucket_name, bucket_entry); - int ret = rgw_get_system_obj(this, obj_ctx, get_zone_params().domain_root, bucket_entry, bl, objv_tracker, pmtime, pattrs, cache_info); + int ret = rgw_get_system_obj(this, obj_ctx, get_zone_params().domain_root, + bucket_entry, bl, objv_tracker, pmtime, pattrs, + cache_info, refresh_version); if (ret < 0) { return ret; } @@ -10917,7 +10923,9 @@ int RGWRados::_get_bucket_info(RGWObjectCtx& obj_ctx, real_time ep_mtime; RGWObjVersionTracker ot; rgw_cache_entry_info entry_cache_info; - int ret = get_bucket_entrypoint_info(obj_ctx, tenant, bucket_name, entry_point, &ot, &ep_mtime, pattrs, &entry_cache_info); + int ret = get_bucket_entrypoint_info(obj_ctx, tenant, bucket_name, + entry_point, &ot, &ep_mtime, pattrs, + &entry_cache_info, refresh_version); if (ret < 0) { /* only init these fields */ info.bucket.tenant = tenant; @@ -10951,7 +10959,8 @@ int RGWRados::_get_bucket_info(RGWObjectCtx& obj_ctx, rgw_cache_entry_info cache_info; - ret = get_bucket_instance_from_oid(obj_ctx, oid, e.info, &e.mtime, &e.attrs, &cache_info); + ret = get_bucket_instance_from_oid(obj_ctx, oid, e.info, &e.mtime, &e.attrs, + &cache_info, refresh_version); e.info.ep_objv = ot.read_version; info = e.info; if (ret < 0) { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 221cc6b5ee622..3c37803092091 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -5,6 +5,7 @@ #define CEPH_RGWRADOS_H #include +#include #include "include/rados/librados.hpp" #include "include/Context.h" @@ -2199,7 +2200,8 @@ public: explicit Read(RGWRados::SystemObject *_source) : source(_source) {} int stat(RGWObjVersionTracker *objv_tracker); - int read(int64_t ofs, int64_t end, bufferlist& bl, RGWObjVersionTracker *objv_tracker); + int read(int64_t ofs, int64_t end, bufferlist& bl, RGWObjVersionTracker *objv_tracker, + boost::optional refresh_version = boost::none); int get_attr(const char *name, bufferlist& dest); }; }; @@ -2732,7 +2734,9 @@ public: RGWObjVersionTracker *objv_tracker, rgw_obj& obj, bufferlist& bl, off_t ofs, off_t end, map *attrs, - rgw_cache_entry_info *cache_info); + rgw_cache_entry_info *cache_info, + boost::optional refresh_version = + boost::none); virtual void register_chained_cache(RGWChainedCache *cache) {} virtual bool chain_cache_entry(list& cache_info_entries, RGWChainedCache::Entry *chained_entry) { return false; } @@ -2839,11 +2843,13 @@ public: int put_bucket_instance_info(RGWBucketInfo& info, bool exclusive, ceph::real_time mtime, map *pattrs); int get_bucket_entrypoint_info(RGWObjectCtx& obj_ctx, const string& tenant_name, const string& bucket_name, RGWBucketEntryPoint& entry_point, RGWObjVersionTracker *objv_tracker, - ceph::real_time *pmtime, map *pattrs, rgw_cache_entry_info *cache_info = NULL); + ceph::real_time *pmtime, map *pattrs, rgw_cache_entry_info *cache_info = NULL, + boost::optional refresh_version = boost::none); int get_bucket_instance_info(RGWObjectCtx& obj_ctx, const string& meta_key, RGWBucketInfo& info, ceph::real_time *pmtime, map *pattrs); - int get_bucket_instance_info(RGWObjectCtx& obj_ctx, rgw_bucket& bucket, RGWBucketInfo& info, ceph::real_time *pmtime, map *pattrs); - int get_bucket_instance_from_oid(RGWObjectCtx& obj_ctx, string& oid, RGWBucketInfo& info, ceph::real_time *pmtime, map *pattrs, - rgw_cache_entry_info *cache_info = NULL); + int get_bucket_instance_info(RGWObjectCtx& obj_ctx, const rgw_bucket& bucket, RGWBucketInfo& info, ceph::real_time *pmtime, std::map *pattrs); + int get_bucket_instance_from_oid(RGWObjectCtx& obj_ctx, const string& oid, RGWBucketInfo& info, ceph::real_time *pmtime, std::map *pattrs, + rgw_cache_entry_info *cache_info = NULL, + boost::optional refresh_version = boost::none); int convert_old_bucket_info(RGWObjectCtx& obj_ctx, const string& tenant_name, const string& bucket_name); static void make_bucket_entry_name(const string& tenant_name, const string& bucket_name, string& bucket_entry); diff --git a/src/rgw/rgw_tools.cc b/src/rgw/rgw_tools.cc index 26bb90688a082..857e3a4b4b6e9 100644 --- a/src/rgw/rgw_tools.cc +++ b/src/rgw/rgw_tools.cc @@ -40,7 +40,7 @@ int rgw_put_system_obj(RGWRados *rgwstore, rgw_bucket& bucket, const string& oid int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, rgw_bucket& bucket, const string& key, bufferlist& bl, RGWObjVersionTracker *objv_tracker, real_time *pmtime, map *pattrs, - rgw_cache_entry_info *cache_info) + rgw_cache_entry_info *cache_info, boost::optional refresh_version) { struct rgw_err err; bufferlist::iterator iter; @@ -61,7 +61,7 @@ int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, rgw_bucket& bu rop.read_params.cache_info = cache_info; - ret = rop.read(0, request_len - 1, bl, objv_tracker); + ret = rop.read(0, request_len - 1, bl, objv_tracker, refresh_version); if (ret == -ECANCELED) { /* raced, restart */ continue; diff --git a/src/rgw/rgw_tools.h b/src/rgw/rgw_tools.h index e44d615b3db08..8b196a28872bb 100644 --- a/src/rgw/rgw_tools.h +++ b/src/rgw/rgw_tools.h @@ -20,8 +20,8 @@ int rgw_put_system_obj(RGWRados *rgwstore, rgw_bucket& bucket, const string& oid RGWObjVersionTracker *objv_tracker, real_time set_mtime, map *pattrs = NULL); int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, rgw_bucket& bucket, const string& key, bufferlist& bl, RGWObjVersionTracker *objv_tracker, real_time *pmtime, map *pattrs = NULL, - rgw_cache_entry_info *cache_info = NULL); - + rgw_cache_entry_info *cache_info = NULL, + boost::optional refresh_version = boost::none); int rgw_tools_init(CephContext *cct); void rgw_tools_cleanup(); const char *rgw_find_mime_by_ext(string& ext);