]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/posix: Remove DBStore dependency
authorSamarah Uriarte <samarah.uriarte@ibm.com>
Wed, 11 Jun 2025 17:31:16 +0000 (12:31 -0500)
committerSamarah Uriarte <samarah.uriarte@ibm.com>
Wed, 16 Jul 2025 17:06:52 +0000 (12:06 -0500)
Signed-off-by: Samarah Uriarte <samarah.uriarte@ibm.com>
src/common/options/rgw.yaml.in
src/rgw/CMakeLists.txt
src/rgw/driver/posix/posixDB.h
src/rgw/driver/posix/rgw_sal_posix.cc
src/rgw/driver/posix/rgw_sal_posix.h
src/rgw/rgw_common.cc
src/rgw/rgw_sal.cc
src/vstart.sh

index 232908c2206be4eca1daefd83e4c2c5efc261d69..2d3bece871c461cb5468edd20d3591a86ea0ec71 100644 (file)
@@ -3967,6 +3967,7 @@ options:
   - dbstore
   - motr
   - daos
+  - posix
 - name: rgw_config_store
   type: str
   level: advanced
@@ -3990,7 +3991,6 @@ options:
   - none
   - base
   - d4n
-  - posix
 - name: dbstore_db_dir
   type: str
   level: advanced
index 2f4bd0665cbdcf380dcf1457de11dd8aa52d37bf..2547a7a244bf3dac3a6a2e5994e3436d488be87c 100644 (file)
@@ -370,6 +370,10 @@ if(WITH_RADOSGW_DBSTORE)
   target_link_libraries(rgw_common PRIVATE global dbstore)
 endif()
 
+if(WITH_RADOSGW_POSIX)
+  target_link_libraries(rgw_common PRIVATE global dbstore)
+endif()
+
 if(WITH_RADOSGW_MOTR)
   find_package(motr REQUIRED)
   target_link_libraries(rgw_common PRIVATE motr::motr)
index c439bb3e1b7a0d5ed1409a516b8b677e26e7bf07..26f9e5aec11dadea31f8a91eb82a00ac6d1a2707 100644 (file)
@@ -115,16 +115,18 @@ class POSIXUserDB : public SQLiteDB {
 
   public:
     POSIXUserDB(std::string db_name, CephContext *_cct) : SQLiteDB(db_name, _cct),
-    db_name(db_name),
-    user_table(db_name+"_user_table"),
-    cct(_cct),
-    dp(_cct, ceph_subsys_rgw, "rgw POSIXUserDBStore backend: ")
-    {}
+               db_name(db_name),
+               user_table(db_name+"_user_table"),
+               cct(_cct),
+               dp(_cct, ceph_subsys_rgw, "rgw POSIXUserDBStore backend: ")
+                { DB::set_context(cct); }
     /* POSIXUserDB() {}*/
 
     int Initialize(std::string logfile, int loglevel);
     int Destroy(const DoutPrefixProvider *dpp);
 
+    CephContext* ctx() { return this->cct; }
+
     virtual int InitPrepareParams(const DoutPrefixProvider *dpp,
                                   DBOpPrepareParams &p_params,
                                   DBOpParams* params) { return 0; } // TODO
index e128a1de5f17ba3893cc4d72747b4a0c8a33cab6..73a37fa1769d300314efc36e34e42b9ea5a00182 100644 (file)
@@ -22,8 +22,6 @@
 #include "include/scope_guard.h"
 #include "common/Clock.h" // for ceph_clock_now()
 #include "common/errno.h"
-#include "driver/dbstore/common/dbstore.h"
-#include "rgw_sal_dbstore.h"
 
 #define dout_subsys ceph_subsys_rgw
 #define dout_context g_ceph_context
@@ -1865,24 +1863,98 @@ int VersionedDirectory::remove_symlink(const DoutPrefixProvider *dpp, optional_y
   return 0;
 }
 
-int POSIXDriver::initialize(CephContext *cct, const DoutPrefixProvider *dpp)
+bool POSIXZoneGroup::placement_target_exists(std::string& target) const {
+  return !!group->placement_targets.count(target);
+}
+
+void POSIXZoneGroup::get_placement_target_names(std::set<std::string>& names) const {
+  for (const auto& target : group->placement_targets) {
+    names.emplace(target.second.name);
+  }
+}
+
+ZoneGroup& POSIXZone::get_zonegroup() {
+  return *zonegroup;
+}
+
+const RGWZoneParams& POSIXZone::get_rgw_params() {
+  return *zone_params;
+}
+
+const std::string& POSIXZone::get_id() {
+  return zone_params->get_id();
+}
+
+const std::string& POSIXZone::get_name() const {
+  return zone_params->get_name();
+}
+
+bool POSIXZone::is_writeable() {
+  return true;
+}
+
+bool POSIXZone::get_redirect_endpoint(std::string* endpoint) {
+  return false;
+}
+
+const std::string& POSIXZone::get_current_period_id() {
+  return current_period->get_id();
+}
+
+const RGWAccessKey& POSIXZone::get_system_key() {
+  return zone_params->system_key;
+}
+
+const std::string& POSIXZone::get_realm_name() {
+  return realm->get_name();
+}
+
+const std::string& POSIXZone::get_realm_id() {
+  return realm->get_id();
+}
+
+RGWBucketSyncPolicyHandlerRef POSIXZone::get_sync_policy_handler() {
+  return nullptr;
+}
+
+int POSIXLuaManager::get_script(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key, std::string& script)
 {
-  FilterDriver::initialize(cct, dpp);
+  return -ENOENT;
+}
 
-  int ret = -1;
-  const static std::string tenant = "default_ns";
-  const auto& db_path = g_conf().get_val<std::string>("dbstore_db_dir");
-  const auto& db_name = g_conf().get_val<std::string>("dbstore_db_name_prefix") + "-" + tenant;
-  auto db_full_path = std::filesystem::path(db_path) / db_name;
+int POSIXLuaManager::put_script(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key, const std::string& script)
+{
+  return -ENOENT;
+}
 
-  userDB = new POSIXUserDB(db_full_path.string(), cct); 
+int POSIXLuaManager::del_script(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key)
+{
+  return -ENOENT;
+}
 
-  if ((ret = userDB->Initialize("", -1)) < 0) {
-    ldout(cct, 0) << "User DB initialization failed for tenant("<<tenant<<")" << dendl;
-    delete userDB;
-    return ret;
-  }
+int POSIXLuaManager::add_package(const DoutPrefixProvider* dpp, optional_yield y, const std::string& package_name)
+{
+  return -ENOENT;
+}
+
+int POSIXLuaManager::remove_package(const DoutPrefixProvider* dpp, optional_yield y, const std::string& package_name)
+{
+  return -ENOENT;
+}
+
+int POSIXLuaManager::list_packages(const DoutPrefixProvider* dpp, optional_yield y, rgw::lua::packages_t& packages)
+{
+  return -ENOENT;
+}
+
+int POSIXLuaManager::reload_packages(const DoutPrefixProvider* dpp, optional_yield y)
+{
+  return -ENOENT;
+}
 
+int POSIXDriver::initialize(CephContext *cct, const DoutPrefixProvider *dpp)
+{
+  int ret = -1;
   base_path = g_conf().get_val<std::string>("rgw_posix_base_path");
 
   ldpp_dout(dpp, 20) << "Initializing POSIX driver: " << base_path << dendl;
@@ -1977,6 +2049,21 @@ int POSIXDriver::get_user_by_swift(const DoutPrefixProvider* dpp, const std::str
   return -ENOTSUP;
 }
 
+int POSIXDriver::load_owner_by_email(const DoutPrefixProvider* dpp,
+                                   optional_yield y,
+                                   std::string_view email,
+                                   rgw_owner& owner)
+{
+  RGWUserInfo uinfo;
+  int ret = get_user_db()->get_user(dpp, "email", std::string{email},
+                                  uinfo, nullptr, nullptr);
+  if (ret < 0) {
+    return ret;
+  }
+  owner = std::move(uinfo.user_id);
+  return 0;
+}
+
 std::unique_ptr<Object> POSIXDriver::get_object(const rgw_obj_key& k)
 {
   return std::make_unique<POSIXObject>(this, k);
@@ -2005,6 +2092,34 @@ std::string POSIXDriver::zone_unique_trans_id(const uint64_t unique_num)
 
   return std::string(buf);
 }
+
+int POSIXDriver::get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zg)
+{
+  /* XXX: for now only one zonegroup supported */
+  std::unique_ptr<RGWZoneGroup> rzg =
+      std::make_unique<RGWZoneGroup>("default", "default");
+  rzg->api_name = "default";
+  rzg->is_master = true;
+  ZoneGroup* group = new POSIXZoneGroup(this, std::move(rzg));
+  if (!group)
+    return -ENOMEM;
+
+  zg->reset(group);
+  return 0;
+}
+
+int POSIXDriver::list_all_zones(const DoutPrefixProvider* dpp,
+                           std::list<std::string>& zone_ids)
+{
+  zone_ids.push_back(zone.get_id());
+  return 0;
+}
+
+int POSIXDriver::cluster_stat(RGWClusterStat& stats)
+{
+  return 0;
+}
+
 std::unique_ptr<Writer> POSIXDriver::get_append_writer(const DoutPrefixProvider *dpp,
                                  optional_yield y,
                                  rgw::sal::Object* _head_obj,
@@ -2014,12 +2129,7 @@ std::unique_ptr<Writer> POSIXDriver::get_append_writer(const DoutPrefixProvider
                                  uint64_t position,
                                  uint64_t *cur_accounted_size)
 {
-  std::unique_ptr<Writer> writer = next->get_append_writer(dpp, y, _head_obj,
-                                                          owner, ptail_placement_rule,
-                                                          unique_tag, position,
-                                                          cur_accounted_size);
-
-  return std::make_unique<FilterWriter>(std::move(writer), std::move(_head_obj));
+  return nullptr;
 }
 
 std::unique_ptr<Writer> POSIXDriver::get_atomic_writer(const DoutPrefixProvider *dpp,
@@ -2034,19 +2144,8 @@ std::unique_ptr<Writer> POSIXDriver::get_atomic_writer(const DoutPrefixProvider
   return std::make_unique<POSIXAtomicWriter>(dpp, y, _head_obj, this, owner, ptail_placement_rule, olh_epoch, unique_tag);
 }
 
-void POSIXDriver::finalize(void)
-{
-  next->finalize();
-}
-
-void POSIXDriver::register_admin_apis(RGWRESTMgr* mgr)
-{
-  return next->register_admin_apis(mgr);
-}
-
-bool POSIXDriver::process_expired_objects(const DoutPrefixProvider *dpp,
-                                                                 optional_yield y) {
-  return next->process_expired_objects(dpp, y);
+const std::string& POSIXDriver::get_compression_type(const rgw_placement_rule& rule) {
+  return zone.get_rgw_params().get_compression_type(rule);
 }
 
 std::unique_ptr<Notification> POSIXDriver::get_notification(rgw::sal::Object* obj,
@@ -2054,7 +2153,8 @@ std::unique_ptr<Notification> POSIXDriver::get_notification(rgw::sal::Object* ob
                              rgw::notify::EventType event_type, optional_yield y,
                              const std::string* object_name)
 {
-  return next->get_notification(obj, src_obj, s, event_type, y, object_name);
+  rgw::notify::EventTypeList event_types = {event_type};
+  return std::make_unique<POSIXNotification>(obj, src_obj, event_types);
 }
 
 std::unique_ptr<Notification> POSIXDriver::get_notification(
@@ -2067,8 +2167,7 @@ std::unique_ptr<Notification> POSIXDriver::get_notification(
     std::string& _user_tenant,
     std::string& _req_id,
     optional_yield y) {
-  return next->get_notification(dpp, obj, src_obj, event_types, _bucket,
-                                _user_id, _user_tenant, _req_id, y);
+  return std::make_unique<POSIXNotification>(obj, src_obj, event_types);
 }
 
 // TODO: marker and other params
@@ -2276,25 +2375,56 @@ int POSIXDriver::mint_listing_entry(const std::string &bname,
 
     return ret;
 }
+
+std::unique_ptr<LuaManager> POSIXDriver::get_lua_manager(const std::string& luarocks_path)
+{
+  return std::make_unique<POSIXLuaManager>(this);
+}
+
+std::unique_ptr<RGWRole> POSIXDriver::get_role(std::string name,
+    std::string tenant,
+    rgw_account_id account_id,
+    std::string path,
+    std::string trust_policy,
+    std::string description,
+    std::string max_session_duration_str,
+    std::multimap<std::string,std::string> tags)
+{
+  RGWRole* p = nullptr;
+  return std::unique_ptr<RGWRole>(p);
+}
+
+std::unique_ptr<RGWRole> POSIXDriver::get_role(std::string id)
+{
+  RGWRole* p = nullptr;
+  return std::unique_ptr<RGWRole>(p);
+}
+
+std::unique_ptr<RGWRole> POSIXDriver::get_role(const RGWRoleInfo& info)
+{
+  RGWRole* p = nullptr;
+  return std::unique_ptr<RGWRole>(p);
+}
+
 int POSIXBucket::fill_cache(const DoutPrefixProvider* dpp, optional_yield y,
-                           fill_cache_cb_t& cb)
+                         fill_cache_cb_t& cb)
 {
-  return dir->fill_cache(dpp, y, cb);
+return dir->fill_cache(dpp, y, cb);
 }
 
 int POSIXBucket::list(const DoutPrefixProvider* dpp, ListParams& params,
-                     int max, ListResults& results, optional_yield y)
+                   int max, ListResults& results, optional_yield y)
 {
-  int count{0};
-  bool in_prefix{false};
-  // Names in the cache are in OID format
-  rgw_obj_key marker_key(params.marker);
-  params.marker = marker_key.get_oid();
-  {
-    rgw_obj_key key(params.prefix);
-    params.prefix = key.name;
-  }
-  if (max <= 0) {
+int count{0};
+bool in_prefix{false};
+// Names in the cache are in OID format
+rgw_obj_key marker_key(params.marker);
+params.marker = marker_key.get_oid();
+{
+  rgw_obj_key key(params.prefix);
+  params.prefix = key.name;
+}
+if (max <= 0) {
     return 0;
   }
 
@@ -4205,9 +4335,18 @@ int POSIXAtomicWriter::complete(size_t accounted_size, const std::string& etag,
 
 extern "C" {
 
-rgw::sal::Driver* newPOSIXDriver(rgw::sal::Driver* next)
+rgw::sal::Driver* newPOSIXDriver(CephContext *cct)
 {
-  rgw::sal::POSIXDriver* driver = new rgw::sal::POSIXDriver(next);
+  rgw::sal::POSIXDriver* driver = new rgw::sal::POSIXDriver(cct);
+
+  int ret = -1;
+  const static std::string tenant = "default_ns";
+  if ((ret = driver->get_user_db()->Initialize("", -1)) < 0) {
+    ldout(cct, 0) << "User DB initialization failed for tenant("<<tenant<<")" << dendl;
+    return nullptr;
+  }
+
+  driver->set_context(cct);
 
   return driver;
 }
index 3a75cba1315f49995f48c89d367437514864b4ab..57e900043cd274192b553865f797014f9d667b2d 100644 (file)
@@ -349,19 +349,153 @@ public:
 
 std::string get_key_fname(rgw_obj_key& key, bool use_version);
 
-class POSIXDriver : public FilterDriver {
+class POSIXZoneGroup : public StoreZoneGroup {
+  POSIXDriver* store;
+  std::unique_ptr<RGWZoneGroup> group;
+  std::string empty;
+
+public:
+  POSIXZoneGroup(POSIXDriver* _store, std::unique_ptr<RGWZoneGroup> _group) : store(_store), group(std::move(_group)) {}
+  virtual ~POSIXZoneGroup() = default;
+
+  virtual const std::string& get_id() const override { return group->get_id(); };
+  virtual const std::string& get_name() const override { return group->get_name(); };
+  virtual int equals(const std::string& other_zonegroup) const override {
+    return group->equals(other_zonegroup);
+  };
+  virtual bool placement_target_exists(std::string& target) const override;
+  virtual bool is_master_zonegroup() const override {
+    return group->is_master_zonegroup();
+  };
+  virtual const std::string& get_api_name() const override { return group->api_name; };
+  virtual void get_placement_target_names(std::set<std::string>& names) const override;
+  virtual const std::string& get_default_placement_name() const override {
+    return group->default_placement.name; };
+  virtual int get_hostnames(std::list<std::string>& names) const override {
+    names = group->hostnames;
+    return 0;
+  };
+  virtual int get_s3website_hostnames(std::list<std::string>& names) const override {
+    names = group->hostnames_s3website;
+    return 0;
+  };
+  virtual int get_zone_count() const override {
+    /* currently only 1 zone supported */
+    return 1;
+  }
+  virtual int get_placement_tier(const rgw_placement_rule& rule,
+                                std::unique_ptr<PlacementTier>* tier) {
+    return -1;
+  }
+  virtual int get_zone_by_id(const std::string& id, std::unique_ptr<Zone>* zone) override {
+    return -1;
+  }
+  virtual int get_zone_by_name(const std::string& name, std::unique_ptr<Zone>* zone) override {
+    return -1;
+  }
+  virtual int list_zones(std::list<std::string>& zone_ids) override {
+    zone_ids.clear();
+    return 0;
+  }
+  virtual std::unique_ptr<ZoneGroup> clone() override {
+    std::unique_ptr<RGWZoneGroup>zg = std::make_unique<RGWZoneGroup>(*group.get());
+    return std::make_unique<POSIXZoneGroup>(store, std::move(zg));
+  }
+};
+
+class POSIXZone : public StoreZone {
 protected:
-  rgw::store::POSIXUserDB* userDB;
+  POSIXDriver* store;
+  std::unique_ptr<RGWRealm> realm;
+  std::unique_ptr<POSIXZoneGroup> zonegroup;
+  std::unique_ptr<RGWZone> zone_public_config; /* external zone params, e.g., entrypoints, log flags, etc. */
+  std::unique_ptr<RGWZoneParams> zone_params; /* internal zone params, e.g., rados pools */
+  std::unique_ptr<RGWPeriod> current_period;
+
+public:
+  POSIXZone(POSIXDriver* _store) : store(_store) {
+    realm = std::make_unique<RGWRealm>();
+    std::unique_ptr<RGWZoneGroup> rzg = std::make_unique<RGWZoneGroup>("default", "default");
+    rzg->api_name = "default";
+    rzg->is_master = true;
+    zonegroup = std::make_unique<POSIXZoneGroup>(store, std::move(rzg));
+    zone_public_config = std::make_unique<RGWZone>();
+    zone_params = std::make_unique<RGWZoneParams>();
+    current_period = std::make_unique<RGWPeriod>();
+
+    // XXX: only default and STANDARD supported for now
+    RGWZonePlacementInfo info;
+    RGWZoneStorageClasses sc;
+    sc.set_storage_class("STANDARD", nullptr, nullptr);
+    info.storage_classes = sc;
+    zone_params->placement_pools["default"] = info;
+  }
+  ~POSIXZone() = default;
+
+  virtual std::unique_ptr<Zone> clone() override {
+    return std::make_unique<POSIXZone>(store);
+  }
+  virtual ZoneGroup& get_zonegroup() override;
+  const RGWZoneParams& get_rgw_params();
+  virtual const std::string& get_id() override;
+  virtual const std::string& get_name() const override;
+  virtual bool is_writeable() override;
+  virtual bool get_redirect_endpoint(std::string* endpoint) override;
+  virtual const std::string& get_current_period_id() override;
+  virtual const RGWAccessKey& get_system_key() override;
+  virtual const std::string& get_realm_name() override;
+  virtual const std::string& get_realm_id() override;
+  virtual const std::string_view get_tier_type() override { return "rgw"; }
+  virtual RGWBucketSyncPolicyHandlerRef get_sync_policy_handler() override;
+};
+
+class POSIXLuaManager : public StoreLuaManager {
+  POSIXDriver* store;
+
+public:
+  POSIXLuaManager(POSIXDriver* _s) : store(_s)
+  { }
+  virtual ~POSIXLuaManager() = default;
+
+  virtual int get_script(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key, std::string& script) override;
+  virtual int put_script(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key, const std::string& script) override;
+  virtual int del_script(const DoutPrefixProvider* dpp, optional_yield y, const std::string& key) override;
+  virtual int add_package(const DoutPrefixProvider* dpp, optional_yield y, const std::string& package_name) override;
+  virtual int remove_package(const DoutPrefixProvider* dpp, optional_yield y, const std::string& package_name) override;
+  virtual int list_packages(const DoutPrefixProvider* dpp, optional_yield y, rgw::lua::packages_t& packages) override;
+  virtual int reload_packages(const DoutPrefixProvider* dpp, optional_yield y) override;
+};
+
+class POSIXDriver : public StoreDriver {
+protected:     
+  CephContext *cct;
+  std::unique_ptr<rgw::store::POSIXUserDB> userDB;
+  POSIXZone zone;
   std::unique_ptr<BucketCache> bucket_cache;
   std::string base_path;
   std::unique_ptr<Directory> root_dir;
   int root_fd;
+  RGWSyncModuleInstanceRef sync_module;
 
 public:
-  POSIXDriver(Driver* _next) : FilterDriver(_next)
-  { }
+  POSIXDriver(CephContext *_cct) : StoreDriver(), cct(_cct), zone(this)
+  {
+    const static std::string tenant = "default_ns";
+    const auto& db_path = g_conf().get_val<std::string>("dbstore_db_dir");
+    const auto& db_name = g_conf().get_val<std::string>("dbstore_db_name_prefix") + "-" + tenant;
+    auto db_full_path = std::filesystem::path(db_path) / db_name;
+    
+    userDB = std::make_unique<rgw::store::POSIXUserDB>(db_full_path.string(), cct);
+  }
   virtual ~POSIXDriver() { }
-  virtual int initialize(CephContext *cct, const DoutPrefixProvider *dpp) override;
+
+  void set_context(CephContext *_cct) {
+    cct = _cct;
+  }
+
+  virtual int initialize(CephContext *cct, const DoutPrefixProvider *dpp);
+  virtual const std::string get_name() const override { return "posix"; }
+  virtual std::string get_cluster_id(const DoutPrefixProvider* dpp,  optional_yield y) override { return "PLACEHOLDER"; };
   virtual std::unique_ptr<User> get_user(const rgw_user& u) override;
   virtual int get_user_by_access_key(const DoutPrefixProvider* dpp, const
                                     std::string& key, optional_yield y,
@@ -372,6 +506,129 @@ public:
   virtual int get_user_by_swift(const DoutPrefixProvider* dpp, const
                                std::string& user_str, optional_yield y,
                                std::unique_ptr<User>* user) override;
+
+
+  virtual int load_account_by_id(const DoutPrefixProvider* dpp,
+                                optional_yield y,
+                                std::string_view id,
+                                RGWAccountInfo& info,
+                                Attrs& attrs,
+                                RGWObjVersionTracker& objv) override { return -ENOTSUP; }
+  virtual int load_account_by_name(const DoutPrefixProvider* dpp,
+                                optional_yield y,
+                                std::string_view tenant,
+                                std::string_view name,
+                                RGWAccountInfo& info,
+                                Attrs& attrs,
+                                RGWObjVersionTracker& objv) override { return -ENOTSUP; }
+  virtual int load_account_by_email(const DoutPrefixProvider* dpp,
+                                 optional_yield y,
+                                 std::string_view email,
+                                 RGWAccountInfo& info,
+                                 Attrs& attrs,
+                                 RGWObjVersionTracker& objv) override { return -ENOTSUP; }
+
+  virtual int store_account(const DoutPrefixProvider* dpp,
+                         optional_yield y, bool exclusive,
+                         const RGWAccountInfo& info,
+                         const RGWAccountInfo* old_info,
+                         const Attrs& attrs,
+                         RGWObjVersionTracker& objv) override { return -ENOTSUP; }
+
+  virtual int delete_account(const DoutPrefixProvider* dpp,
+                            optional_yield y,
+                            const RGWAccountInfo& info,
+                            RGWObjVersionTracker& objv) override { return -ENOTSUP; }
+
+  virtual int load_stats(const DoutPrefixProvider* dpp,
+                        optional_yield y,
+                        const rgw_owner& owner,
+                        RGWStorageStats& stats,
+                        ceph::real_time& last_synced,
+                        ceph::real_time& last_updated) override { return 0; }
+  virtual int load_stats_async(const DoutPrefixProvider* dpp,
+                              const rgw_owner& owner,
+                              boost::intrusive_ptr<ReadStatsCB> cb) override { return -ENOTSUP; }
+  virtual int reset_stats(const DoutPrefixProvider *dpp,
+                         optional_yield y,
+                         const rgw_owner& owner) override { return -ENOTSUP; }
+  virtual int complete_flush_stats(const DoutPrefixProvider* dpp,
+                                  optional_yield y,
+                                  const rgw_owner& owner) override { return 0; }
+
+  virtual int load_owner_by_email(const DoutPrefixProvider* dpp,
+                                 optional_yield y,
+                                 std::string_view email,
+                                 rgw_owner& owner) override;
+
+  virtual int count_account_roles(const DoutPrefixProvider* dpp,
+                                 optional_yield y,
+                                 std::string_view account_id,
+                                 uint32_t& count) override { return -ENOTSUP; }
+  virtual int list_account_roles(const DoutPrefixProvider* dpp,
+                                optional_yield y,
+                                std::string_view account_id,
+                                std::string_view path_prefix,
+                                std::string_view marker,
+                                uint32_t max_items,
+                                RoleList& listing) override { return -ENOTSUP; }
+
+  virtual int load_account_user_by_name(const DoutPrefixProvider* dpp,
+                                       optional_yield y,
+                                       std::string_view account_id,
+                                       std::string_view tenant,
+                                       std::string_view username,
+                                       std::unique_ptr<User>* user) override { return -ENOTSUP; }
+  virtual int count_account_users(const DoutPrefixProvider* dpp,
+                                 optional_yield y,
+                                 std::string_view account_id,
+                                 uint32_t& count) override { return -ENOTSUP; }
+  virtual int list_account_users(const DoutPrefixProvider* dpp,
+                                optional_yield y,
+                                std::string_view account_id,
+                                std::string_view tenant,
+                                std::string_view path_prefix,
+                                std::string_view marker,
+                                uint32_t max_items,
+                                UserList& listing) override { return -ENOTSUP; }
+
+  virtual int load_group_by_id(const DoutPrefixProvider* dpp,
+                              optional_yield y,
+                              std::string_view id,
+                              RGWGroupInfo& info, Attrs& attrs,
+                              RGWObjVersionTracker& objv) override { return -ENOTSUP; }
+  virtual int load_group_by_name(const DoutPrefixProvider* dpp,
+                                optional_yield y,
+                                std::string_view account_id,
+                                std::string_view name,
+                                RGWGroupInfo& info, Attrs& attrs,
+                                RGWObjVersionTracker& objv) override { return -ENOTSUP; }
+  virtual int store_group(const DoutPrefixProvider* dpp, optional_yield y,
+                         const RGWGroupInfo& info, const Attrs& attrs,
+                         RGWObjVersionTracker& objv, bool exclusive,
+                         const RGWGroupInfo* old_info) override { return -ENOTSUP; }
+  virtual int remove_group(const DoutPrefixProvider* dpp, optional_yield y,
+                          const RGWGroupInfo& info,
+                          RGWObjVersionTracker& objv) override { return -ENOTSUP; }
+  virtual int list_group_users(const DoutPrefixProvider* dpp,
+                              optional_yield y,
+                              std::string_view tenant,
+                              std::string_view id,
+                              std::string_view marker,
+                              uint32_t max_items,
+                              UserList& listing) override { return -ENOTSUP; }
+  virtual int count_account_groups(const DoutPrefixProvider* dpp,
+                                  optional_yield y,
+                                  std::string_view account_id,
+                                  uint32_t& count) override { return -ENOTSUP; }
+  virtual int list_account_groups(const DoutPrefixProvider* dpp,
+                                 optional_yield y,
+                                 std::string_view account_id,
+                                 std::string_view path_prefix,
+                                 std::string_view marker,
+                                 uint32_t max_items,
+                                 GroupList& listing) override { return -ENOTSUP; }
+
   virtual std::unique_ptr<Object> get_object(const rgw_obj_key& k) override;
   virtual std::unique_ptr<Bucket> get_bucket(const RGWBucketInfo& i)  override;
   virtual int load_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b,
@@ -381,48 +638,139 @@ public:
                           const std::string& marker, const std::string& end_marker,
                           uint64_t max, bool need_stats, BucketList& buckets,
                           optional_yield y) override;
+  virtual bool is_meta_master() override { return true; }
+  virtual Zone* get_zone() override { return &zone; }
+  virtual std::string zone_unique_id(uint64_t unique_num) override { return ""; }
   virtual std::string zone_unique_trans_id(const uint64_t unique_num) override;
-
-  virtual std::unique_ptr<Writer> get_append_writer(const DoutPrefixProvider *dpp,
-                                 optional_yield y,
-                                 rgw::sal::Object* _head_obj,
-                                 const ACLOwner& owner,
-                                 const rgw_placement_rule *ptail_placement_rule,
-                                 const std::string& unique_tag,
-                                 uint64_t position,
-                                 uint64_t *cur_accounted_size) override;
-  virtual std::unique_ptr<Writer> get_atomic_writer(const DoutPrefixProvider *dpp,
-                                 optional_yield y,
-                                 rgw::sal::Object* _head_obj,
-                                 const ACLOwner& owner,
-                                 const rgw_placement_rule *ptail_placement_rule,
-                                 uint64_t olh_epoch,
-                                 const std::string& unique_tag) override;
-
-  virtual void finalize(void) override;
-  virtual void register_admin_apis(RGWRESTMgr* mgr) override;
-
-  virtual bool process_expired_objects(const DoutPrefixProvider *dpp,
-                                       optional_yield y) override;
-  virtual std::unique_ptr<Notification> get_notification(rgw::sal::Object* obj,
-                                rgw::sal::Object* src_obj, struct req_state* s,
-                                rgw::notify::EventType event_type, optional_yield y,
-                                const std::string* object_name=nullptr) override;
-
+  virtual int get_zonegroup(const std::string& id, std::unique_ptr<ZoneGroup>* zonegroup) override;
+  virtual int list_all_zones(const DoutPrefixProvider* dpp, std::list<std::string>& zone_ids) override;
+  virtual int cluster_stat(RGWClusterStat& stats) override;
+  virtual std::unique_ptr<Lifecycle> get_lifecycle(void) override { return nullptr; } // TODO: implement
+  virtual std::unique_ptr<Restore> get_restore(void) { return nullptr; }
+  virtual bool process_expired_objects(const DoutPrefixProvider *dpp, optional_yield y) override { return 0; }
+
+  virtual std::unique_ptr<Notification> get_notification(rgw::sal::Object* obj, rgw::sal::Object* src_obj, req_state* s,
+      rgw::notify::EventType event_type, optional_yield y, const std::string* object_name=nullptr) override;
   virtual std::unique_ptr<Notification> get_notification(
       const DoutPrefixProvider* dpp,
       rgw::sal::Object* obj,
       rgw::sal::Object* src_obj,
-      const rgw::notify::EventTypeList& event_type,
+      const rgw::notify::EventTypeList& event_types,
       rgw::sal::Bucket* _bucket,
       std::string& _user_id,
       std::string& _user_tenant,
       std::string& _req_id,
       optional_yield y) override;
+  virtual int list_account_topics(const DoutPrefixProvider* dpp,
+                                 optional_yield y,
+                                 std::string_view account_id,
+                                 std::string_view marker,
+                                 uint32_t max_items,
+                                 TopicList& listing) override { return -ENOTSUP; }
+
+  virtual int add_persistent_topic(const DoutPrefixProvider* dpp,
+                                  optional_yield y,
+                                  const std::string& topic_queue) override { return -ENOTSUP; }
+  virtual int remove_persistent_topic(const DoutPrefixProvider* dpp,
+                                     optional_yield y,
+                                     const std::string& topic_queue) override { return -ENOTSUP; }
+
+  virtual RGWLC* get_rgwlc(void) override { return NULL; } // TODO: Lifecycle not currently supported
+  virtual rgw::restore::Restore* get_rgwrestore(void) { return nullptr; }
+  virtual RGWCoroutinesManagerRegistry* get_cr_registry() override { return NULL; }
+
+  virtual int log_usage(const DoutPrefixProvider *dpp, std::map<rgw_user_bucket, RGWUsageBatch>& usage_info, optional_yield y) override { return 0; }
+  virtual int log_op(const DoutPrefixProvider *dpp, std::string& oid, bufferlist& bl) override { return 0; }
+  virtual int register_to_service_map(const DoutPrefixProvider *dpp, const std::string& daemon_type,
+                                     const std::map<std::string, std::string>& meta) override { return 0; }
+  virtual void get_quota(RGWQuota& quota) override { return ; }
+  virtual void get_ratelimit(RGWRateLimitInfo& bucket_ratelimit, RGWRateLimitInfo& user_ratelimit, RGWRateLimitInfo& anon_ratelimit) override { return; }
+  virtual int set_buckets_enabled(const DoutPrefixProvider* dpp, std::vector<rgw_bucket>& buckets, bool enabled, optional_yield y) override { return 0; } // TODO: implement
+  virtual int get_sync_policy_handler(const DoutPrefixProvider* dpp,
+                                     std::optional<rgw_zone_id> zone,
+                                     std::optional<rgw_bucket> bucket,
+                                     RGWBucketSyncPolicyHandlerRef* phandler,
+                                     optional_yield y) override { return 0; }
+  virtual RGWDataSyncStatusManager* get_data_sync_manager(const rgw_zone_id& source_zone) override { return 0; }
+  virtual void wakeup_meta_sync_shards(std::set<int>& shard_ids) override { return; }
+  virtual void wakeup_data_sync_shards(const DoutPrefixProvider *dpp, const rgw_zone_id& source_zone, boost::container::flat_map<int, boost::container::flat_set<rgw_data_notify_entry>>& shard_ids) override { return; }
+  virtual int clear_usage(const DoutPrefixProvider *dpp, optional_yield y) override { return 0; }
+  virtual int read_all_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch,
+                            uint32_t max_entries, bool* is_truncated,
+                            RGWUsageIter& usage_iter,
+                            std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) override { return 0; }
+  virtual int trim_all_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, optional_yield y) override { return 0; }
+  virtual int get_config_key_val(std::string name, bufferlist* bl) override { return -ENOTSUP; }
+  virtual int meta_list_keys_init(const DoutPrefixProvider *dpp, const std::string& section, const std::string& marker, void** phandle) override { return 0; }
+  virtual int meta_list_keys_next(const DoutPrefixProvider *dpp, void* handle, int max, std::list<std::string>& keys, bool* truncated) override { return 0; }
+  virtual void meta_list_keys_complete(void* handle) override { return; }
+  virtual std::string meta_get_marker(void* handle) override { return ""; }
+  virtual int meta_remove(const DoutPrefixProvider* dpp, std::string& metadata_key, optional_yield y) override { return 0; }
+  virtual const RGWSyncModuleInstanceRef& get_sync_module() override { return sync_module; }
+  virtual std::string get_host_id() override { return ""; }
+  virtual std::unique_ptr<LuaManager> get_lua_manager(const std::string& luarocks_path) override;
+  virtual std::unique_ptr<RGWRole> get_role(std::string name,
+                                           std::string tenant,
+                                           rgw_account_id account_id,
+                                           std::string path="",
+                                           std::string trust_policy="",
+                                           std::string description="",
+                                           std::string max_session_duration_str="",
+             std::multimap<std::string,std::string> tags={}) override;
+  virtual std::unique_ptr<RGWRole> get_role(std::string id) override;
+  virtual std::unique_ptr<RGWRole> get_role(const RGWRoleInfo& info) override;
+  virtual int list_roles(const DoutPrefixProvider *dpp,
+                        optional_yield y,
+                        const std::string& tenant,
+                        const std::string& path_prefix,
+                        const std::string& marker,
+                        uint32_t max_items,
+                        RoleList& listing) override { return 0; }
+  virtual int store_oidc_provider(const DoutPrefixProvider* dpp,
+                                 optional_yield y,
+                                 const RGWOIDCProviderInfo& info,
+                                 bool exclusive) override { return -ENOTSUP; }
+  virtual int load_oidc_provider(const DoutPrefixProvider* dpp,
+                                optional_yield y,
+                                std::string_view tenant,
+                                std::string_view url,
+                                RGWOIDCProviderInfo& info) override { return -ENOTSUP; }
+  virtual int delete_oidc_provider(const DoutPrefixProvider* dpp,
+                                  optional_yield y,
+                                  std::string_view tenant,
+                                  std::string_view url) override { return -ENOTSUP; }
+  virtual int get_oidc_providers(const DoutPrefixProvider* dpp,
+                                optional_yield y,
+                                std::string_view tenant,
+                                std::vector<RGWOIDCProviderInfo>& providers) override { return 0; }
+  virtual std::unique_ptr<Writer> get_append_writer(const DoutPrefixProvider *dpp,
+                               optional_yield y,
+                               rgw::sal::Object* obj,
+                               const ACLOwner& owner,
+                               const rgw_placement_rule *ptail_placement_rule,
+                               const std::string& unique_tag,
+                               uint64_t position,
+                               uint64_t *cur_accounted_size) override;
+  virtual std::unique_ptr<Writer> get_atomic_writer(const DoutPrefixProvider *dpp,
+                               optional_yield y,
+                               rgw::sal::Object* obj,
+                               const ACLOwner& owner,
+                               const rgw_placement_rule *ptail_placement_rule,
+                               uint64_t olh_epoch,
+                               const std::string& unique_tag) override;
+
+  virtual const std::string& get_compression_type(const rgw_placement_rule& rule) override;
+  virtual bool valid_placement(const rgw_placement_rule& rule) override { return true; } 
+
+  virtual void finalize(void) override {}
+
+  virtual CephContext* ctx(void) override { return userDB->ctx(); }
+
+  virtual void register_admin_apis(RGWRESTMgr* mgr) override {}
 
   /* Internal APIs */
   int get_root_fd() { return root_dir->get_fd(); }
-  rgw::store::POSIXUserDB* get_user_db() { return userDB; }
+  rgw::store::POSIXUserDB* get_user_db() { return userDB.get(); }
   Directory* get_root_dir() { return root_dir.get(); }
   const std::string& get_base_path() const { return base_path; }
   BucketCache* get_bucket_cache() { return bucket_cache.get(); }
@@ -431,7 +779,20 @@ public:
    * by inotify or similar */
   int mint_listing_entry(
     const std::string& bucket, rgw_bucket_dir_entry& bde /* OUT */);
+};
 
+class POSIXNotification : public StoreNotification {
+protected:
+public:
+ POSIXNotification(Object* _obj,
+                  Object* _src_obj,
+                  const rgw::notify::EventTypeList& _types)
+                  : StoreNotification(_obj, _src_obj, _types) {}
+ ~POSIXNotification() = default;
+
+ virtual int publish_reserve(const DoutPrefixProvider *dpp, RGWObjTags* obj_tags = nullptr) override { return 0; }
+ virtual int publish_commit(const DoutPrefixProvider* dpp, uint64_t size,
+                          const ceph::real_time& mtime, const std::string& etag, const std::string& version) override { return 0; }
 };
 
 class POSIXUser : public StoreUser {
index 094c2ccd9916cdf02aa936513edb5857628f08ab..6db84e263b5672193ee4f88f3f22cad27c62dc62 100644 (file)
@@ -3233,6 +3233,7 @@ rgw_global_init(const std::map<std::string,std::string> *defaults,
   const auto& config_store = g_conf().get_val<std::string>("rgw_backend_store");
 
   if ((config_store == "dbstore") ||
+      (config_store == "posix") || 
       (config_store == "motr") || 
       (config_store == "daos")) {
     // These stores don't use the mon
index 786da6987b972bf266ecf364b6c9f1b43a8e936d..b7b848790df394c965af55bece2adcd1172434f6 100644 (file)
 #include "rgw_sal_dbstore.h"
 #include "driver/dbstore/config/store.h"
 #endif
+#ifdef WITH_RADOSGW_POSIX
+#include "driver/posix/rgw_sal_posix.h"
+#include "driver/dbstore/config/store.h"
+#endif
 #ifdef WITH_RADOSGW_D4N
 #include "driver/d4n/rgw_sal_d4n.h" 
 #endif
@@ -54,15 +58,15 @@ extern rgw::sal::Driver* newRadosStore(boost::asio::io_context* io_context);
 #ifdef WITH_RADOSGW_DBSTORE
 extern rgw::sal::Driver* newDBStore(CephContext *cct);
 #endif
+#ifdef WITH_RADOSGW_POSIX
+extern rgw::sal::Driver* newPOSIXDriver(CephContext *cct);
+#endif
 #ifdef WITH_RADOSGW_MOTR
 extern rgw::sal::Driver* newMotrStore(CephContext *cct);
 #endif
 #ifdef WITH_RADOSGW_DAOS
 extern rgw::sal::Driver* newDaosStore(CephContext *cct);
 #endif
-#ifdef WITH_RADOSGW_POSIX
-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);
@@ -172,6 +176,17 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
   }
 #endif
 
+#ifdef WITH_RADOSGW_POSIX
+  else if (cfg.store_name.compare("posix") == 0) {
+    driver = newPOSIXDriver(cct);
+
+    if (driver->initialize(cct, dpp) < 0) {
+      delete driver;
+      return nullptr;
+    }
+  }
+#endif
+
 #ifdef WITH_RADOSGW_MOTR
   else if (cfg.store_name.compare("motr") == 0) {
     driver = newMotrStore(cct);
@@ -224,19 +239,6 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
     }
   }
 #endif
-#ifdef WITH_RADOSGW_POSIX
-  else if (cfg.filter_name.compare("posix") == 0) {
-    rgw::sal::Driver* next = driver;
-    ldpp_dout(dpp, 20) << "Creating POSIX driver" << dendl;
-    driver = newPOSIXDriver(next);
-
-    if (driver->initialize(cct, dpp) < 0) {
-      delete driver;
-      delete next;
-      return nullptr;
-    }
-  }
-#endif
 
   return driver;
 }
@@ -280,6 +282,17 @@ rgw::sal::Driver* DriverManager::init_raw_storage_provider(const DoutPrefixProvi
     }
 #else
     driver = nullptr;
+#endif
+  } else if (cfg.store_name.compare("posix") == 0) {
+#ifdef WITH_RADOSGW_POSIX
+    driver = newPOSIXDriver(cct);
+
+    if (driver->initialize(cct, dpp) < 0) {
+      delete driver;
+      return nullptr;
+    }
+#else
+    driver = nullptr;
 #endif
   } else if (cfg.store_name.compare("motr") == 0) {
 #ifdef WITH_RADOSGW_MOTR
@@ -353,6 +366,11 @@ DriverManager::Config DriverManager::get_config(bool admin, CephContext* cct)
     cfg.store_name = "dbstore";
   }
 #endif
+#ifdef WITH_RADOSGW_POSIX
+  else if (config_store == "posix") {
+    cfg.store_name = "posix";
+  }
+#endif
 #ifdef WITH_RADOSGW_MOTR
   else if (config_store == "motr") {
     cfg.store_name = "motr";
@@ -369,8 +387,6 @@ DriverManager::Config DriverManager::get_config(bool admin, CephContext* cct)
   const auto& config_filter = g_conf().get_val<std::string>("rgw_filter");
   if (config_filter == "base") {
     cfg.filter_name = "base";
-  } else if (config_filter == "posix") {
-    cfg.filter_name = "posix";
   }
 #ifdef WITH_RADOSGW_D4N
   else if (config_filter == "d4n") {
@@ -396,6 +412,12 @@ auto DriverManager::create_config_store(const DoutPrefixProvider* dpp,
       const auto uri = g_conf().get_val<std::string>("dbstore_config_uri");
       return rgw::dbstore::create_config_store(dpp, uri);
     }
+#endif
+#ifdef WITH_RADOSGW_POSIX
+    if (type == "posix") {
+      const auto uri = g_conf().get_val<std::string>("dbstore_config_uri");
+      return rgw::dbstore::create_config_store(dpp, uri);
+    }
 #endif
     if (type == "json") {
       auto filename = g_conf().get_val<std::string>("rgw_json_config");
index 27a898aabe09bfb8a901650112be1906cfbfb7b3..a48d861dc7b6287ef361afba809595d67a7b80fa 100755 (executable)
@@ -975,15 +975,15 @@ $CCLIENTDEBUG
         ; rgw lc debug interval = 10
         $(format_conf "${extra_conf}")
 EOF
-    if [ "$rgw_store" == "dbstore" ] ; then
-        do_rgw_dbstore_conf
-    elif [ "$rgw_store" == "posix" ] ; then
+    #if [ "$rgw_store" == "dbstore" ] ; then
+        #do_rgw_dbstore_conf
+    if [ "$rgw_store" == "posix" ] ; then
         # use dbstore as the backend and posix as the filter
         do_rgw_dbstore_conf
         posix_dir="$CEPH_DEV_DIR/rgw/posix"
         prun mkdir -p $posix_dir/root $posix_dir/lmdb
         wconf <<EOF
-        rgw filter = posix
+        rgw backend store = posix
         rgw posix base path = $posix_dir/root
         rgw posix database root = $posix_dir/lmdb