]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: D3N cache objects which oid contains slash 51819/head
authorMark Kogan <mkogan@redhat.com>
Mon, 29 May 2023 17:36:56 +0000 (17:36 +0000)
committerMark Kogan <mkogan@redhat.com>
Mon, 19 Jun 2023 14:33:42 +0000 (17:33 +0300)
Fixes: https://tracker.ceph.com/issues/59739
Signed-off-by: Mark Kogan <mkogan@redhat.com>
src/rgw/driver/rados/rgw_d3n_datacache.cc
src/rgw/driver/rados/rgw_d3n_datacache.h
src/rgw/rgw_aio.cc
src/rgw/rgw_d3n_cacherequest.h

index b270eff024c498d178e819816e2a50ea9593ec14..afd0e69134120949e8ff20f4f96ce2eae12325c5 100644 (file)
@@ -25,9 +25,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;
@@ -111,7 +111,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;
@@ -188,7 +188,7 @@ int D3nDataCache::d3n_libaio_create_write_request(bufferlist& bl, unsigned int l
   auto wr = std::make_unique<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;
     return r;
   }
@@ -273,7 +273,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<string, D3nChunkDataInfo*>::iterator iter = d3n_cache_map.find(oid);
@@ -327,7 +327,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;
 }
@@ -363,7 +363,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;
 }
index 3246c0253dc8a43c9d1082dff9ec5adea03088a9..668e224e85b94fb9ea1a7607f546f5894783c4a1 100644 (file)
@@ -48,7 +48,7 @@ struct D3nCacheAioWriteRequest {
        CephContext *cct = nullptr;
 
        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);
index 0bbc1f7bfa8bde2b43eb82975b883016e801e929..02e3411858acf992fcb63427d2a25deaae0e453a 100644 (file)
@@ -102,13 +102,13 @@ Aio::OpFunc aio_abstract(librados::IoCtx ctx, Op&& op,
 }
 
 
-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 c = std::make_unique<D3nL1CacheRequest>();
     lsubdout(g_ceph_context, rgw_datacache, 20) << "D3nDataCache: d3n_cache_aio_abstract(): libaio Read From Cache, oid=" << r.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);
   };
 }
 
@@ -139,8 +139,8 @@ Aio::OpFunc Aio::librados_op(librados::IoCtx ctx,
 }
 
 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
index 9a5d2df3aacf46553fad6ed0aca4c8750746476c..40fc758e2eb42993bdc2989bfaf381c06d1c705f 100644 (file)
@@ -48,14 +48,14 @@ struct D3nL1CacheRequest {
     using Signature = void(boost::system::error_code, bufferlist);
     using Completion = ceph::async::Completion<Signature, AsyncFileReadOp>;
 
-    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)
@@ -96,7 +96,7 @@ struct D3nL1CacheRequest {
   };
 
   template <typename ExecutionContext, typename CompletionToken>
-  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;
@@ -104,8 +104,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,14 +132,14 @@ 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<yield_context, void()> init(yield);
     auto ex = get_associated_executor(init.completion_handler);
 
     ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): oid=" << r.obj.oid << dendl;
-    async_read(dpp, context, file_path+"/"+r.obj.oid, read_ofs, read_len, bind_executor(ex, d3n_libaio_handler{aio, r}));
+    async_read(dpp, context, cache_location+"/"+url_encode(r.obj.oid, true), read_ofs, read_len, bind_executor(ex, d3n_libaio_handler{aio, r}));
   }
 
 };