]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
d4n: Update block `mtime` in filter and change `creationTime` to string
authorSamarah <samarah.uriarte@ibm.com>
Thu, 9 Nov 2023 21:27:04 +0000 (21:27 +0000)
committerPritha Srivastava <prsrivas@redhat.com>
Tue, 2 Apr 2024 15:54:51 +0000 (21:24 +0530)
in directory due to seg faults

Signed-off-by: Samarah <samarah.uriarte@ibm.com>
src/rgw/driver/d4n/d4n_directory.cc
src/rgw/driver/d4n/d4n_directory.h
src/rgw/driver/d4n/rgw_sal_d4n.cc
src/rgw/driver/d4n/rgw_sal_d4n.h
src/test/rgw/test_d4n_directory.cc
src/test/rgw/test_d4n_policy.cc

index b0971349698d07cee17b838811ecda3f3d970204..62b071f80170392b1d632dfe9a82de322c976f32 100644 (file)
@@ -84,7 +84,7 @@ int ObjectDirectory::set(CacheObj* object, optional_yield y) {
   redisValues.push_back("bucketName");
   redisValues.push_back(object->bucketName);
   redisValues.push_back("creationTime");
-  redisValues.push_back(std::to_string(object->creationTime)); 
+  redisValues.push_back(object->creationTime); 
   redisValues.push_back("dirty");
   redisValues.push_back(std::to_string(object->dirty));
   redisValues.push_back("objHosts");
@@ -145,7 +145,7 @@ int ObjectDirectory::get(CacheObj* object, optional_yield y) {
 
       object->objName = std::get<0>(resp).value()[0];
       object->bucketName = std::get<0>(resp).value()[1];
-      object->creationTime = boost::lexical_cast<time_t>(std::get<0>(resp).value()[2]);
+      object->creationTime = std::get<0>(resp).value()[2];
       object->dirty = boost::lexical_cast<bool>(std::get<0>(resp).value()[3]);
 
       {
@@ -354,7 +354,7 @@ int BlockDirectory::set(CacheBlock* block, optional_yield y) {
   redisValues.push_back("bucketName");
   redisValues.push_back(block->cacheObj.bucketName);
   redisValues.push_back("creationTime");
-  redisValues.push_back(std::to_string(block->cacheObj.creationTime)); 
+  redisValues.push_back(block->cacheObj.creationTime); 
   redisValues.push_back("dirty");
   redisValues.push_back(std::to_string(block->cacheObj.dirty));
   redisValues.push_back("objHosts");
@@ -438,7 +438,7 @@ int BlockDirectory::get(CacheBlock* block, optional_yield y) {
 
       block->cacheObj.objName = std::get<0>(resp).value()[5];
       block->cacheObj.bucketName = std::get<0>(resp).value()[6];
-      block->cacheObj.creationTime = boost::lexical_cast<time_t>(std::get<0>(resp).value()[7]);
+      block->cacheObj.creationTime = std::get<0>(resp).value()[7];
       block->cacheObj.dirty = boost::lexical_cast<bool>(std::get<0>(resp).value()[8]);
 
       {
index b98859d70dbe9c9b126912adc67b305b18b3cf4d..e9f62dd5107214fd75f50fea67f7d4be3272af29 100644 (file)
@@ -19,7 +19,7 @@ using boost::redis::response;
 struct CacheObj {
   std::string objName; /* S3 object name */
   std::string bucketName; /* S3 bucket name */
-  time_t creationTime; /* Creation time of the S3 Object */
+  std::string creationTime; /* Creation time of the S3 Object */
   bool dirty;
   std::vector<std::string> hostsList; /* List of hostnames <ip:port> of object locations for multiple backends */
 };
index b1d8e33187aadcb9e19f33a571134a734462505e..622d91dac02518a6fa76d34ff8ed1f23dad105f2 100644 (file)
@@ -645,18 +645,17 @@ int D4NFilterObject::D4NFilterReadOp::D4NFilterGetCB::handle_data(bufferlist& bl
     const std::lock_guard l(d4n_get_data_lock);
     rgw::d4n::CacheBlock block;
     rgw::d4n::BlockDirectory* blockDir = source->driver->get_block_dir();
-    block.version = "";
+    block.version = ""; // TODO: initialize correctly 
     block.hostsList.push_back(blockDir->cct->_conf->rgw_local_cache_address); 
     block.cacheObj.objName = source->get_key().get_oid();
     block.cacheObj.bucketName = source->get_bucket()->get_name();
-    block.cacheObj.creationTime = 0;
-    block.cacheObj.dirty = false;// update hostsList since may overwrite existing hosts -Sam
-    block.cacheObj.hostsList.push_back(blockDir->cct->_conf->rgw_local_cache_address); // Is the entire object getting stored in the local cache as well or only blocks? -Sam
-    Attrs attrs; // empty attrs for block sets
+    block.cacheObj.creationTime = to_iso_8601(source->get_mtime()); 
+    block.cacheObj.dirty = false;
+    Attrs attrs; // empty attrs for cache sets
 
     if (bl.length() > 0 && last_part) { // if bl = bl_rem has data and this is the last part, write it to cache
       std::string oid = this->oid + "_" + std::to_string(ofs) + "_" + std::to_string(bl_len);
-      block.blockID = ofs; // TODO: fill out block correctly
+      block.blockID = ofs; 
       block.size = bl.length();
       if (filter->get_policy_driver()->get_cache_policy()->eviction(dpp, block.size, *y) == 0) {
         if (filter->get_cache_driver()->put_async(dpp, oid, bl, bl.length(), attrs) == 0) {
@@ -702,7 +701,7 @@ int D4NFilterObject::D4NFilterReadOp::D4NFilterGetCB::handle_data(bufferlist& bl
       if (bl_rem.length() == rgw_get_obj_max_req_size) {
         std::string oid = this->oid + "_" + std::to_string(ofs) + "_" + std::to_string(bl_rem.length());
         ofs += bl_rem.length();
-        block.blockID = ofs; // TODO: fill out block correctly
+        block.blockID = ofs;
         block.size = bl_rem.length();
         if (filter->get_policy_driver()->get_cache_policy()->eviction(dpp, block.size, *y) == 0) {
           if (filter->get_cache_driver()->put_async(dpp, oid, bl_rem, bl_rem.length(), attrs) == 0) {
@@ -731,15 +730,13 @@ int D4NFilterObject::D4NFilterReadOp::D4NFilterGetCB::handle_data(bufferlist& bl
 int D4NFilterObject::D4NFilterDeleteOp::delete_obj(const DoutPrefixProvider* dpp,
                                                    optional_yield y, uint32_t flags)
 {
-  rgw::d4n::CacheBlock block = rgw::d4n::CacheBlock{
-                                 .cacheObj = {
-                                   .objName = source->get_key().get_oid(),
-                                   .bucketName = source->get_bucket()->get_name()
-                                 },
-                                 .blockID = 0 // TODO: get correct blockID
-                               };
-  if (source->driver->get_block_dir()->del(&block, y) < 0) 
-    ldpp_dout(dpp, 10) << "D4NFilterObject::" << __func__ << "(): BlockDirectory del method failed." << dendl;
+  rgw::d4n::CacheObj obj = rgw::d4n::CacheObj{ // TODO: Add logic to ObjectDirectory del method to also delete all blocks belonging to that object
+                            .objName = source->get_key().get_oid(),
+                            .bucketName = source->get_bucket()->get_name()
+                          };
+
+  if (source->driver->get_obj_dir()->del(&obj, y) < 0) 
+    ldpp_dout(dpp, 10) << "D4NFilterObject::" << __func__ << "(): ObjectDirectory del method failed." << dendl;
 
   Attrs::iterator attrs;
   Attrs currentattrs = source->get_attrs();
@@ -789,22 +786,16 @@ int D4NFilterWriter::complete(size_t accounted_size, const std::string& etag,
                        const req_context& rctx,
                        uint32_t flags)
 {
-  rgw::d4n::CacheBlock block = rgw::d4n::CacheBlock{
-                                 .cacheObj = {
-                                   .objName = obj->get_key().get_oid(), 
-                                   .bucketName = obj->get_bucket()->get_name(),
-                                   .creationTime = 0, // TODO: get correct value
-                                   .dirty = false,
-                                  .hostsList = { driver->get_block_dir()->cct->_conf->rgw_local_cache_address } 
-                                 },
-                                 .blockID = 0, // TODO: get correct blockID
-                                 .version = "", 
-                                 .size = accounted_size,
-                                 .hostsList = { driver->get_block_dir()->cct->_conf->rgw_local_cache_address }
+  rgw::d4n::CacheObj object = rgw::d4n::CacheObj{
+                                .objName = obj->get_key().get_oid(), 
+                                .bucketName = obj->get_bucket()->get_name(),
+                                .creationTime = to_iso_8601(*mtime), 
+                                .dirty = false,
+                                .hostsList = { driver->get_block_dir()->cct->_conf->rgw_local_cache_address } 
                                };
 
-  if (driver->get_block_dir()->set(&block, y) < 0) 
-    ldpp_dout(save_dpp, 10) << "D4NFilterWriter::" << __func__ << "(): BlockDirectory set method failed." << dendl;
+  if (driver->get_obj_dir()->set(&object, y) < 0) 
+    ldpp_dout(save_dpp, 10) << "D4NFilterWriter::" << __func__ << "(): ObjectDirectory set method failed." << dendl;
    
   /* Retrieve complete set of attrs */
   int ret = next->complete(accounted_size, etag, mtime, set_mtime, attrs,
index a7d7d1c6f8462374e9753df9f31ee97e4933924a..fc7f844ee7c779a807581b67fbd0b9e201296656 100644 (file)
@@ -198,6 +198,7 @@ class D4NFilterObject : public FilterObject {
                                optional_yield y, const DoutPrefixProvider* dpp) override;
     virtual int delete_obj_attrs(const DoutPrefixProvider* dpp, const char* attr_name,
                                optional_yield y) override;
+    virtual ceph::real_time get_mtime(void) const override { return next->get_mtime(); };
 
     virtual std::unique_ptr<ReadOp> get_read_op() override;
     virtual std::unique_ptr<DeleteOp> get_delete_op() override;
index dfb01de2e9461ca91f55550fe56937eadce4190f..8d00a2b023942319aed19895f51999a7103bc74b 100644 (file)
@@ -51,7 +51,7 @@ class ObjectDirectoryFixture: public ::testing::Test {
       obj = new rgw::d4n::CacheObj{
        .objName = "testName",
        .bucketName = "testBucket",
-       .creationTime = 0,
+       .creationTime = "",
        .dirty = false,
        .hostsList = { env->redisHost }
       };
@@ -84,7 +84,7 @@ class ObjectDirectoryFixture: public ::testing::Test {
     net::io_context io;
     connection* conn;
 
-    std::vector<std::string> vals{"testName", "testBucket", "0", "0", env->redisHost};
+    std::vector<std::string> vals{"testName", "testBucket", "", "0", env->redisHost};
     std::vector<std::string> fields{"objName", "bucketName", "creationTime", "dirty", "objHosts"};
 };
 
@@ -96,7 +96,7 @@ class BlockDirectoryFixture: public ::testing::Test {
         .cacheObj = {
          .objName = "testName",
          .bucketName = "testBucket",
-         .creationTime = 0,
+         .creationTime = "",
          .dirty = false,
          .hostsList = { env->redisHost }
        },
@@ -135,7 +135,7 @@ class BlockDirectoryFixture: public ::testing::Test {
     connection* conn;
 
     std::vector<std::string> vals{"0", "", "0", "0", env->redisHost, 
-                                   "testName", "testBucket", "0", "0", env->redisHost};
+                                   "testName", "testBucket", "", "0", env->redisHost};
     std::vector<std::string> fields{"blockID", "version", "size", "globalWeight", "blockHosts", 
                                     "objName", "bucketName", "creationTime", "dirty", "objHosts"};
 };
index 2d299ebf2d1a07ff17ba44d75f21227d906f22d6..5aff9b26a2a6ab33804a0ed0611565012599f67f 100644 (file)
@@ -48,7 +48,7 @@ class LFUDAPolicyFixture : public ::testing::Test {
        .cacheObj = {
          .objName = "testName",
          .bucketName = "testBucket",
-         .creationTime = 0,
+         .creationTime = "",
          .dirty = false,
          .hostsList = { env->redisHost }
        },
@@ -192,7 +192,7 @@ TEST_F(LFUDAPolicyFixture, RemoteGetBlockYield)
       .cacheObj = {
        .objName = "victimName",
        .bucketName = "testBucket",
-       .creationTime = 0,
+       .creationTime = "",
        .dirty = false,
        .hostsList = { env->redisHost }
       },