From: Mark Kogan Date: Mon, 29 May 2023 17:36:56 +0000 (+0000) Subject: quincy: rgw: D3N cache objects which oid contains slash X-Git-Tag: v17.2.7~223^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0d49df09fa31b968e8e658ec3f085906442e2940;p=ceph.git quincy: rgw: D3N cache objects which oid contains slash Fixes: https://tracker.ceph.com/issues/59739 Signed-off-by: Mark Kogan (cherry picked from commit fcb91f3e2a6fd8066ac33950d421e0a9b9b4b490) Conflicts: src/rgw/rgw_aio.cc src/rgw/rgw_d3n_cacherequest.h src/rgw/rgw_d3n_datacache.cc --- diff --git a/src/rgw/rgw_aio.cc b/src/rgw/rgw_aio.cc index afab8b75b0bd5..4fba513b83608 100644 --- a/src/rgw/rgw_aio.cc +++ b/src/rgw/rgw_aio.cc @@ -95,14 +95,14 @@ Aio::OpFunc aio_abstract(Op&& op, boost::asio::io_context& context, } -Aio::OpFunc d3n_cache_aio_abstract(const DoutPrefixProvider *dpp, optional_yield y, off_t read_ofs, off_t read_len, std::string& location) { - return [dpp, y, read_ofs, read_len, location] (Aio* aio, AioResult& r) mutable { +Aio::OpFunc d3n_cache_aio_abstract(const DoutPrefixProvider *dpp, optional_yield y, off_t read_ofs, off_t read_len, std::string& cache_location) { + return [dpp, y, read_ofs, read_len, cache_location] (Aio* aio, AioResult& r) mutable { // d3n data cache requires yield context (rgw_beast_enable_async=true) ceph_assert(y); auto& ref = r.obj.get_ref(); auto c = std::make_unique(); lsubdout(g_ceph_context, rgw_datacache, 20) << "D3nDataCache: d3n_cache_aio_abstract(): libaio Read From Cache, oid=" << ref.obj.oid << dendl; - c->file_aio_read_abstract(dpp, y.get_io_context(), y.get_yield_context(), location, read_ofs, read_len, aio, r); + c->file_aio_read_abstract(dpp, y.get_io_context(), y.get_yield_context(), cache_location, read_ofs, read_len, aio, r); }; } @@ -131,8 +131,8 @@ Aio::OpFunc Aio::librados_op(librados::ObjectWriteOperation&& op, } Aio::OpFunc Aio::d3n_cache_op(const DoutPrefixProvider *dpp, optional_yield y, - off_t read_ofs, off_t read_len, std::string& location) { - return d3n_cache_aio_abstract(dpp, y, read_ofs, read_len, location); + off_t read_ofs, off_t read_len, std::string& cache_location) { + return d3n_cache_aio_abstract(dpp, y, read_ofs, read_len, cache_location); } } // namespace rgw diff --git a/src/rgw/rgw_d3n_cacherequest.h b/src/rgw/rgw_d3n_cacherequest.h index ad93a689f9c68..988bfed1f9612 100644 --- a/src/rgw/rgw_d3n_cacherequest.h +++ b/src/rgw/rgw_d3n_cacherequest.h @@ -49,14 +49,14 @@ struct D3nL1CacheRequest { using Signature = void(boost::system::error_code, bufferlist); using Completion = ceph::async::Completion; - int init(const DoutPrefixProvider *dpp, const std::string& file_path, off_t read_ofs, off_t read_len, void* arg) { - ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): file_path=" << file_path << dendl; + int init_async_read(const DoutPrefixProvider *dpp, const std::string& location, off_t read_ofs, off_t read_len, void* arg) { + ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): location=" << location << dendl; aio_cb.reset(new struct aiocb); memset(aio_cb.get(), 0, sizeof(struct aiocb)); - aio_cb->aio_fildes = TEMP_FAILURE_RETRY(::open(file_path.c_str(), O_RDONLY|O_CLOEXEC|O_BINARY)); + aio_cb->aio_fildes = TEMP_FAILURE_RETRY(::open(location.c_str(), O_RDONLY|O_CLOEXEC|O_BINARY)); if(aio_cb->aio_fildes < 0) { int err = errno; - ldpp_dout(dpp, 1) << "ERROR: D3nDataCache: " << __func__ << "(): can't open " << file_path << " : " << cpp_strerror(err) << dendl; + ldpp_dout(dpp, 1) << "ERROR: D3nDataCache: " << __func__ << "(): can't open " << location << " : " << cpp_strerror(err) << dendl; return -err; } if (g_conf()->rgw_d3n_l1_fadvise != POSIX_FADV_NORMAL) @@ -97,7 +97,7 @@ struct D3nL1CacheRequest { }; template - auto async_read(const DoutPrefixProvider *dpp, ExecutionContext& ctx, const std::string& file_path, + auto async_read(const DoutPrefixProvider *dpp, ExecutionContext& ctx, const std::string& location, off_t read_ofs, off_t read_len, CompletionToken&& token) { using Op = AsyncFileReadOp; using Signature = typename Op::Signature; @@ -105,8 +105,8 @@ struct D3nL1CacheRequest { auto p = Op::create(ctx.get_executor(), init.completion_handler); auto& op = p->user_data; - ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): file_path=" << file_path << dendl; - int ret = op.init(dpp, file_path, read_ofs, read_len, p.get()); + ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): location=" << location << dendl; + int ret = op.init_async_read(dpp, location, read_ofs, read_len, p.get()); if(0 == ret) { ret = ::aio_read(op.aio_cb.get()); } @@ -132,7 +132,7 @@ struct D3nL1CacheRequest { }; void file_aio_read_abstract(const DoutPrefixProvider *dpp, boost::asio::io_context& context, yield_context yield, - std::string& file_path, off_t read_ofs, off_t read_len, + std::string& cache_location, off_t read_ofs, off_t read_len, rgw::Aio* aio, rgw::AioResult& r) { using namespace boost::asio; async_completion init(yield); @@ -140,7 +140,7 @@ struct D3nL1CacheRequest { auto& ref = r.obj.get_ref(); ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): oid=" << ref.obj.oid << dendl; - async_read(dpp, context, file_path+"/"+ref.obj.oid, read_ofs, read_len, bind_executor(ex, d3n_libaio_handler{aio, r})); + async_read(dpp, context, cache_location+"/"+url_encode(ref.obj.oid, true), read_ofs, read_len, bind_executor(ex, d3n_libaio_handler{aio, r})); } }; diff --git a/src/rgw/rgw_d3n_datacache.cc b/src/rgw/rgw_d3n_datacache.cc index 472d2d57d590b..4995b2e6a25de 100644 --- a/src/rgw/rgw_d3n_datacache.cc +++ b/src/rgw/rgw_d3n_datacache.cc @@ -22,9 +22,9 @@ namespace efs = std::experimental::filesystem; using namespace std; -int D3nCacheAioWriteRequest::d3n_prepare_libaio_write_op(bufferlist& bl, unsigned int len, string oid, string cache_location) +int D3nCacheAioWriteRequest::d3n_libaio_prepare_write_op(bufferlist& bl, unsigned int len, string oid, string cache_location) { - std::string location = cache_location + oid; + std::string location = cache_location + url_encode(oid, true); int r = 0; lsubdout(g_ceph_context, rgw_datacache, 20) << "D3nDataCache: " << __func__ << "(): Write To Cache, location=" << location << dendl; @@ -110,7 +110,7 @@ void D3nDataCache::init(CephContext *_cct) { int D3nDataCache::d3n_io_write(bufferlist& bl, unsigned int len, std::string oid) { D3nChunkDataInfo* chunk_info = new D3nChunkDataInfo; - std::string location = cache_location + oid; + std::string location = cache_location + url_encode(oid, true); lsubdout(g_ceph_context, rgw_datacache, 20) << "D3nDataCache: " << __func__ << "(): location=" << location << dendl; FILE *cache_file = nullptr; @@ -185,7 +185,7 @@ int D3nDataCache::d3n_libaio_create_write_request(bufferlist& bl, unsigned int l lsubdout(g_ceph_context, rgw_datacache, 30) << "D3nDataCache: " << __func__ << "(): Write To Cache, oid=" << oid << ", len=" << len << dendl; struct D3nCacheAioWriteRequest* wr = new struct D3nCacheAioWriteRequest(cct); int r=0; - if ((r = wr->d3n_prepare_libaio_write_op(bl, len, oid, cache_location)) < 0) { + if ((r = wr->d3n_libaio_prepare_write_op(bl, len, oid, cache_location)) < 0) { ldout(cct, 0) << "ERROR: D3nDataCache: " << __func__ << "() prepare libaio write op r=" << r << dendl; goto done; } @@ -270,7 +270,7 @@ bool D3nDataCache::get(const string& oid, const off_t len) { const std::lock_guard l(d3n_cache_lock); bool exist = false; - string location = cache_location + oid; + string location = cache_location + url_encode(oid, true); lsubdout(g_ceph_context, rgw_datacache, 20) << "D3nDataCache: " << __func__ << "(): location=" << location << dendl; std::unordered_map::iterator iter = d3n_cache_map.find(oid); @@ -324,7 +324,7 @@ size_t D3nDataCache::random_eviction() d3n_cache_map.erase(del_oid); // oid } - location = cache_location + del_oid; + location = cache_location + url_encode(del_oid, true); ::remove(location.c_str()); return freed_size; } @@ -360,7 +360,7 @@ size_t D3nDataCache::lru_eviction() } freed_size = del_entry->size; delete del_entry; - location = cache_location + del_oid; + location = cache_location + url_encode(del_oid, true); ::remove(location.c_str()); return freed_size; } diff --git a/src/rgw/rgw_d3n_datacache.h b/src/rgw/rgw_d3n_datacache.h index 5d3537f3b1484..874a4b06b7f9e 100644 --- a/src/rgw/rgw_d3n_datacache.h +++ b/src/rgw/rgw_d3n_datacache.h @@ -49,7 +49,7 @@ struct D3nCacheAioWriteRequest { CephContext *cct; D3nCacheAioWriteRequest(CephContext *_cct) : cct(_cct) {} - int d3n_prepare_libaio_write_op(bufferlist& bl, unsigned int len, std::string oid, std::string cache_location); + int d3n_libaio_prepare_write_op(bufferlist& bl, unsigned int len, std::string oid, std::string cache_location); ~D3nCacheAioWriteRequest() { ::close(fd);