]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Add parameter to `get_storage` to indicate radosgw-admin call 64070/head
authorSamarah <samarah.uriarte@ibm.com>
Thu, 26 Jun 2025 20:31:08 +0000 (20:31 +0000)
committerSamarah <samarah.uriarte@ibm.com>
Mon, 21 Jul 2025 21:54:10 +0000 (21:54 +0000)
Signed-off-by: Samarah <samarah.uriarte@ibm.com>
src/rgw/driver/d4n/rgw_sal_d4n.cc
src/rgw/driver/d4n/rgw_sal_d4n.h
src/rgw/radosgw-admin/radosgw-admin.cc
src/rgw/rgw_sal.cc
src/rgw/rgw_sal.h
src/rgw/rgw_ssd_driver.cc
src/rgw/rgw_ssd_driver.h
src/test/rgw/test_ssd_driver.cc

index 9c3e0730547249f613b4c112e5455a9f80f96b73..de759eb60972f9d31c053643f42c97dd6a5fadef 100644 (file)
@@ -36,16 +36,16 @@ static inline Object* nextObject(Object* t)
   return dynamic_cast<FilterObject*>(t)->get_next();
 }
 
-D4NFilterDriver::D4NFilterDriver(Driver* _next, boost::asio::io_context& io_context) : FilterDriver(_next),
-                                                                                       io_context(io_context),
-                                                                                      y(null_yield)
+D4NFilterDriver::D4NFilterDriver(Driver* _next, boost::asio::io_context& io_context, bool admin) : FilterDriver(_next),
+                                                                                                  io_context(io_context), 
+                                                                                                  y(null_yield)
 {
   rgw::cache::Partition partition_info;
   partition_info.location = g_conf()->rgw_d4n_l1_datacache_persistent_path;
   partition_info.name = "d4n";
   partition_info.type = "read-cache";
   partition_info.size = g_conf()->rgw_d4n_l1_datacache_size;
-  cacheDriver = std::make_unique<rgw::cache::SSDDriver>(partition_info);
+  cacheDriver = std::make_unique<rgw::cache::SSDDriver>(partition_info, admin);
 }
 
 D4NFilterDriver::~D4NFilterDriver() = default;
@@ -3104,9 +3104,9 @@ int D4NFilterMultipartUpload::complete(const DoutPrefixProvider *dpp,
 
 extern "C" {
 
-rgw::sal::Driver* newD4NFilter(rgw::sal::Driver* next, void* io_context)
+rgw::sal::Driver* newD4NFilter(rgw::sal::Driver* next, void* io_context, bool admin)
 {
-  rgw::sal::D4NFilterDriver* driver = new rgw::sal::D4NFilterDriver(next, *static_cast<boost::asio::io_context*>(io_context));
+  rgw::sal::D4NFilterDriver* driver = new rgw::sal::D4NFilterDriver(next, *static_cast<boost::asio::io_context*>(io_context), admin);
 
   return driver;
 }
index d091ede2b73120fc7593b587768e223890b6fa97..65b4f31733d2d673a58d19fec498f28dac7ba30b 100644 (file)
@@ -63,7 +63,7 @@ class D4NFilterDriver : public FilterDriver {
     optional_yield y;
 
   public:
-    D4NFilterDriver(Driver* _next, boost::asio::io_context& io_context);
+    D4NFilterDriver(Driver* _next, boost::asio::io_context& io_context, bool admin);
     virtual ~D4NFilterDriver();
 
     virtual int initialize(CephContext *cct, const DoutPrefixProvider *dpp) override;
index 2a79d9d421ef3ca1d701dc1da7d5ec91b20b2bab..821ead35e4bef8e2fdb19be7b6efd06663f5a1ae 100644 (file)
@@ -4641,7 +4641,7 @@ int main(int argc, const char **argv)
                                         null_yield,
                                        cfgstore.get(),
                                        need_cache && g_conf()->rgw_cache_enabled,
-                                       need_gc);
+                                       need_gc, true /* admin */);
     }
     if (!driver) {
       cerr << "couldn't init storage provider" << std::endl;
index 786da6987b972bf266ecf364b6c9f1b43a8e936d..fe85704d3c8447c877293e0a0354b881982cdabe 100644 (file)
@@ -65,7 +65,7 @@ extern rgw::sal::Driver* newPOSIXDriver(rgw::sal::Driver* next);
 #endif
 extern rgw::sal::Driver* newBaseFilter(rgw::sal::Driver* next);
 #ifdef WITH_RADOSGW_D4N
-extern rgw::sal::Driver* newD4NFilter(rgw::sal::Driver* next, boost::asio::io_context& io_context);
+extern rgw::sal::Driver* newD4NFilter(rgw::sal::Driver* next, boost::asio::io_context& io_context, bool admin);
 #endif
 }
 
@@ -84,7 +84,7 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
                                                     bool use_cache,
                                                     bool use_gc,
                                                     bool background_tasks,
-                                                   optional_yield y, rgw::sal::ConfigStore* cfgstore)
+                                                   optional_yield y, rgw::sal::ConfigStore* cfgstore, bool admin)
 {
   rgw::sal::Driver* driver{nullptr};
 
@@ -215,7 +215,7 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
 #ifdef WITH_RADOSGW_D4N 
   else if (cfg.filter_name.compare("d4n") == 0) {
     rgw::sal::Driver* next = driver;
-    driver = newD4NFilter(next, io_context);
+    driver = newD4NFilter(next, io_context, admin);
 
     if (driver->initialize(cct, dpp) < 0) {
       delete driver;
index 65b3702d7e63de1a7b4bf558da704eb2449f22ab..7a3a55559cca0b6bc9addb0d00be66e5d7cd5f20 100644 (file)
@@ -1943,7 +1943,8 @@ public:
                                      optional_yield y,
               rgw::sal::ConfigStore* cfgstore,
                                      bool use_cache = true,
-                                     bool use_gc = true) {
+                                     bool use_gc = true,
+                                      bool admin = false) {
     rgw::sal::Driver* driver = init_storage_provider(dpp, cct, cfg, io_context,
                                                   site_config,
                                                   use_gc_thread,
@@ -1954,7 +1955,7 @@ public:
                                                   run_reshard_thread,
                run_notification_thread,
                                                   use_cache, use_gc,
-                                                  background_tasks, y, cfgstore);
+                                                  background_tasks, y, cfgstore, admin);
     return driver;
   }
   /** Get a stripped down driver by service name */
@@ -1984,7 +1985,7 @@ public:
             bool run_notification_thread,
                                                bool use_metadata_cache,
                                                bool use_gc, bool background_tasks,
-                                               optional_yield y, rgw::sal::ConfigStore* cfgstore);
+                                               optional_yield y, rgw::sal::ConfigStore* cfgstore, bool admin);
   /** Initialize a new raw Driver */
   static rgw::sal::Driver* init_raw_storage_provider(const DoutPrefixProvider* dpp,
                                                    CephContext* cct,
index 773abe907f95e2322731618f6bd2394cb698cd8c..37f3d308bdb5ca07307a81d249d91be2058fcc3b 100644 (file)
@@ -116,59 +116,61 @@ int SSDDriver::initialize(const DoutPrefixProvider* dpp)
       partition_info.location += "/";
     }
 
-    try {
-        if (efs::exists(partition_info.location)) {
-            if (dpp->get_cct()->_conf->rgw_d4n_l1_evict_cache_on_start) {
-                ldpp_dout(dpp, 5) << "initialize: evicting the persistent storage directory on start" << dendl;
-
-               uid_t uid = dpp->get_cct()->get_set_uid();
-               gid_t gid = dpp->get_cct()->get_set_gid();
-
-               ldpp_dout(dpp, 5) << "initialize:: uid is " << uid << " and gid is " << gid << dendl;
-               ldpp_dout(dpp, 5) << "initialize:: changing permissions for datacache directory." << dendl;
-
-               if (uid) { 
-                  if (chown(partition_info.location.c_str(), uid, gid) == -1) {
-                   ldpp_dout(dpp, 5) << "initialize: chown return error: " << strerror(errno) << dendl;
-                  }
-
-                  if (chmod(partition_info.location.c_str(), S_IRWXU|S_IRWXG|S_IRWXO) == -1) {
-                   ldpp_dout(dpp, 5) << "initialize: chmod return error: " << strerror(errno) << dendl;
-                  }
-               }
-
-                for (auto& p : efs::directory_iterator(partition_info.location)) {
-                    efs::remove_all(p.path());
-                }
-            }
-        } else {
-            ldpp_dout(dpp, 5) << "initialize:: creating the persistent storage directory on start: " << partition_info.location << dendl;
-            std::error_code ec;
-            if (!efs::create_directories(partition_info.location, ec)) {
-                ldpp_dout(dpp, 0) << "initialize::: ERROR initializing the cache storage directory: '" << partition_info.location <<
-                                "' : " << ec.value() << dendl;
-            } else {
-               uid_t uid = dpp->get_cct()->get_set_uid();
-               gid_t gid = dpp->get_cct()->get_set_gid();
-
-               ldpp_dout(dpp, 5) << "initialize:: uid is " << uid << " and gid is " << gid << dendl;
-               ldpp_dout(dpp, 5) << "initialize:: changing permissions for datacache directory." << dendl;
-               
-               if (uid) { 
-                  if (chown(partition_info.location.c_str(), uid, gid) == -1) {
-                   ldpp_dout(dpp, 5) << "initialize: chown return error: " << strerror(errno) << dendl;
-                  }
-
-                  if (chmod(partition_info.location.c_str(), S_IRWXU|S_IRWXG|S_IRWXO) == -1) {
-                   ldpp_dout(dpp, 5) << "initialize: chmod return error: " << strerror(errno) << dendl;
-                  }
-               }
-            }
-        }
-    } catch (const efs::filesystem_error& e) {
-        ldpp_dout(dpp, 0) << "initialize::: ERROR initializing the cache storage directory '" << partition_info.location <<
-                                "' : " << e.what() << dendl;
-        //return -EINVAL; Should return error from here?
+    if (!admin) { // Only initialize or evict cache if radosgw-admin is not responsible for call 
+      try {
+         if (efs::exists(partition_info.location)) {
+             if (dpp->get_cct()->_conf->rgw_d4n_l1_evict_cache_on_start) {
+                 ldpp_dout(dpp, 5) << "initialize: evicting the persistent storage directory on start" << dendl;
+
+                 uid_t uid = dpp->get_cct()->get_set_uid();
+                 gid_t gid = dpp->get_cct()->get_set_gid();
+
+                 ldpp_dout(dpp, 5) << "initialize:: uid is " << uid << " and gid is " << gid << dendl;
+                 ldpp_dout(dpp, 5) << "initialize:: changing permissions for datacache directory." << dendl;
+
+                 if (uid) { 
+                   if (chown(partition_info.location.c_str(), uid, gid) == -1) {
+                     ldpp_dout(dpp, 5) << "initialize: chown return error: " << strerror(errno) << dendl;
+                   }
+
+                   if (chmod(partition_info.location.c_str(), S_IRWXU|S_IRWXG|S_IRWXO) == -1) {
+                     ldpp_dout(dpp, 5) << "initialize: chmod return error: " << strerror(errno) << dendl;
+                   }
+                 }
+
+                 for (auto& p : efs::directory_iterator(partition_info.location)) {
+                     efs::remove_all(p.path());
+                 }
+             }
+         } else {
+             ldpp_dout(dpp, 5) << "initialize:: creating the persistent storage directory on start: " << partition_info.location << dendl;
+             std::error_code ec;
+             if (!efs::create_directories(partition_info.location, ec)) {
+                 ldpp_dout(dpp, 0) << "initialize::: ERROR initializing the cache storage directory: '" << partition_info.location <<
+                                 "' : " << ec.value() << dendl;
+             } else {
+                 uid_t uid = dpp->get_cct()->get_set_uid();
+                 gid_t gid = dpp->get_cct()->get_set_gid();
+
+                 ldpp_dout(dpp, 5) << "initialize:: uid is " << uid << " and gid is " << gid << dendl;
+                 ldpp_dout(dpp, 5) << "initialize:: changing permissions for datacache directory." << dendl;
+                 
+                 if (uid) { 
+                   if (chown(partition_info.location.c_str(), uid, gid) == -1) {
+                     ldpp_dout(dpp, 5) << "initialize: chown return error: " << strerror(errno) << dendl;
+                   }
+
+                   if (chmod(partition_info.location.c_str(), S_IRWXU|S_IRWXG|S_IRWXO) == -1) {
+                     ldpp_dout(dpp, 5) << "initialize: chmod return error: " << strerror(errno) << dendl;
+                   }
+                 }
+             }
+         }
+      } catch (const efs::filesystem_error& e) {
+         ldpp_dout(dpp, 0) << "initialize::: ERROR initializing the cache storage directory '" << partition_info.location <<
+                                 "' : " << e.what() << dendl;
+         //return -EINVAL; Should return error from here?
+      }
     }
 
     #if defined(HAVE_LIBAIO) && defined(__GLIBC__)
index dedf539e0fffc9f5ed0236ccb97490c28545d62c..49d85244cc4823e707f477087776d8d839ecadc8 100644 (file)
@@ -8,7 +8,7 @@ namespace rgw { namespace cache {
 
 class SSDDriver : public CacheDriver {
 public:
-  SSDDriver(Partition& partition_info) : partition_info(partition_info) {}
+  SSDDriver(Partition& partition_info, bool admin) : partition_info(partition_info), admin(admin) {}
   virtual ~SSDDriver() {}
 
   virtual int initialize(const DoutPrefixProvider* dpp) override;
@@ -39,6 +39,7 @@ private:
   uint64_t free_space;
   CephContext* cct;
   std::mutex cache_lock;
+  bool admin;
 
   struct libaio_read_handler {
     rgw::Aio* throttle = nullptr;
index 1ab3009acc2e1cb6c057f13f8afb634e0c740240..01ea4e7be31b8cd6d1a8fd964c726fb6d6f89219 100644 (file)
@@ -87,7 +87,7 @@ class SSDDriverFixture: public ::testing::Test {
   protected:
     virtual void SetUp() {
         rgw::cache::Partition partition_info{.name = "d4n", .type = "read-cache", .location = "rgw_d4n_datacache", .size = 5368709120};
-        cacheDriver = new rgw::cache::SSDDriver{partition_info};
+        cacheDriver = new rgw::cache::SSDDriver{partition_info, false};
 
         ASSERT_NE(cacheDriver, nullptr);