]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
quincy: rgw: D3N cache objects which oid contains slash 52320/head
authorMark Kogan <mkogan@redhat.com>
Mon, 29 May 2023 17:36:56 +0000 (17:36 +0000)
committerMark Kogan <mkogan@redhat.com>
Wed, 5 Jul 2023 15:15:04 +0000 (18:15 +0300)
Fixes: https://tracker.ceph.com/issues/59739
Signed-off-by: Mark Kogan <mkogan@redhat.com>
(cherry picked from commit fcb91f3e2a6fd8066ac33950d421e0a9b9b4b490)

 Conflicts:
src/rgw/rgw_aio.cc
src/rgw/rgw_d3n_cacherequest.h
src/rgw/rgw_d3n_datacache.cc

src/rgw/rgw_aio.cc
src/rgw/rgw_d3n_cacherequest.h
src/rgw/rgw_d3n_datacache.cc
src/rgw/rgw_d3n_datacache.h

index afab8b75b0bd52caf013dc589152ef54349dd495..4fba513b836084ca700416ee6635fd2f476e72d9 100644 (file)
@@ -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<D3nL1CacheRequest>();
     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
index ad93a689f9c68afc6295b1a20962f75f0b86a01e..988bfed1f9612dd621cf73e869005985eaa047ef 100644 (file)
@@ -49,14 +49,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)
@@ -97,7 +97,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;
@@ -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<yield_context, void()> 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}));
   }
 
 };
index 472d2d57d590bc2b890e3cab684faf63e7435b46..4995b2e6a25de844241f2f96fcf4ca82aaee5595 100644 (file)
@@ -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<string, D3nChunkDataInfo*>::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;
 }
index 5d3537f3b148479533835960867f193c2e3ab03e..874a4b06b7f9e62700f8487b9da4c827ec601023 100644 (file)
@@ -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);