From 739304f8512193b1a27b1c1441932ddd0437d620 Mon Sep 17 00:00:00 2001 From: Nithya Balachandran Date: Thu, 16 Apr 2026 10:01:50 +0000 Subject: [PATCH] rgw/posix: remove path from table names Removes the DB directory path from the table names. Signed-off-by: Nithya Balachandran --- src/rgw/driver/dbstore/common/dbstore.h | 25 ++++++++++++++--------- src/rgw/driver/dbstore/sqlite/sqliteDB.cc | 3 +++ src/rgw/driver/posix/posixDB.cc | 11 +++++----- src/rgw/driver/posix/posixDB.h | 7 ------- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/rgw/driver/dbstore/common/dbstore.h b/src/rgw/driver/dbstore/common/dbstore.h index d141770d46a..2d25ee797b7 100644 --- a/src/rgw/driver/dbstore/common/dbstore.h +++ b/src/rgw/driver/dbstore/common/dbstore.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "fmt/format.h" #include @@ -1627,6 +1628,7 @@ WRITE_CLASS_ENCODER(DBOLHInfo) class DB { private: const std::string db_name; + const std::string table_name_prefix; rgw::sal::Driver* driver; const std::string account_table; const std::string user_table; @@ -1650,18 +1652,21 @@ class DB { public: DB(std::string db_name, CephContext *_cct) : db_name(db_name), - account_table(db_name+"_account_table"), - user_table(db_name+"_user_table"), - bucket_table(db_name+"_bucket_table"), - quota_table(db_name+"_quota_table"), - lc_head_table(db_name+"_lc_head_table"), - lc_entry_table(db_name+"_lc_entry_table"), + table_name_prefix(std::filesystem::path(db_name).filename()), + account_table(table_name_prefix + "_account_table"), + user_table(table_name_prefix + "_user_table"), + bucket_table(table_name_prefix + "_bucket_table"), + quota_table(table_name_prefix + "_quota_table"), + lc_head_table(table_name_prefix + "_lc_head_table"), + lc_entry_table(table_name_prefix + "_lc_entry_table"), cct(_cct), dp(_cct, ceph_subsys_rgw, "rgw DBStore backend: ") {} /* DB() {}*/ DB(CephContext *_cct) : db_name("default_db"), + + table_name_prefix(db_name), account_table(db_name+"_account_table"), user_table(db_name+"_user_table"), bucket_table(db_name+"_bucket_table"), @@ -1682,13 +1687,13 @@ class DB { const std::string getLCHeadTable() { return lc_head_table; } const std::string getLCEntryTable() { return lc_entry_table; } const std::string getObjectTable(std::string bucket) { - return db_name+"_"+bucket+"_object_table"; } + return table_name_prefix+"_"+bucket+"_object_table"; } const std::string getObjectDataTable(std::string bucket) { - return db_name+"_"+bucket+"_objectdata_table"; } + return table_name_prefix+"_"+bucket+"_objectdata_table"; } const std::string getObjectView(std::string bucket) { - return db_name+"_"+bucket+"_object_view"; } + return table_name_prefix+"_"+bucket+"_object_view"; } const std::string getObjectTrigger(std::string bucket) { - return db_name+"_"+bucket+"_object_trigger"; } + return table_name_prefix+"_"+bucket+"_object_trigger"; } std::map getObjectMap(); diff --git a/src/rgw/driver/dbstore/sqlite/sqliteDB.cc b/src/rgw/driver/dbstore/sqlite/sqliteDB.cc index c9791b87b48..a7288666a23 100644 --- a/src/rgw/driver/dbstore/sqlite/sqliteDB.cc +++ b/src/rgw/driver/dbstore/sqlite/sqliteDB.cc @@ -763,6 +763,7 @@ int SQLiteDB::createTables(const DoutPrefixProvider *dpp) params.account_table = getAccountTable(); params.user_table = getUserTable(); params.bucket_table = getBucketTable(); + params.quota_table = getQuotaTable(); if ((ca = createAccountTable(dpp, ¶ms))) goto out; @@ -785,6 +786,8 @@ out: DeleteUserTable(dpp, ¶ms); if (cb) DeleteBucketTable(dpp, ¶ms); + if (cq) + DeleteQuotaTable(dpp, ¶ms); ldpp_dout(dpp, 0)<<"Creation of tables failed" << dendl; } diff --git a/src/rgw/driver/posix/posixDB.cc b/src/rgw/driver/posix/posixDB.cc index bbbe69917d6..0f71df42cc3 100644 --- a/src/rgw/driver/posix/posixDB.cc +++ b/src/rgw/driver/posix/posixDB.cc @@ -71,11 +71,12 @@ int POSIXUserDB::Initialize(string logfile, int loglevel) DBOpParams params = {}; RGWAccessKey key("0555b35654ad1656d804", "h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=="); - params.user_table = user_table; - params.bucket_table = bucket_table; - params.quota_table = quota_table; - params.lc_entry_table = lc_entry_table; - params.lc_head_table = lc_head_table; + params.user_table = getUserTable(); + params.bucket_table = getBucketTable(); + params.quota_table = getQuotaTable(); + params.lc_entry_table = getLCEntryTable(); + params.lc_head_table = getLCHeadTable(); + params.op.user.uinfo.display_name = "tester"; params.op.user.uinfo.user_id.id = "test"; params.op.user.uinfo.access_keys["default"] = key; diff --git a/src/rgw/driver/posix/posixDB.h b/src/rgw/driver/posix/posixDB.h index 31ebc96715f..7aae32ce360 100644 --- a/src/rgw/driver/posix/posixDB.h +++ b/src/rgw/driver/posix/posixDB.h @@ -151,12 +151,6 @@ class RemovePOSIXUserOp: public SQLRemoveUser {}; class POSIXUserDB : public SQLiteDB { private: const std::string db_name; - const std::string user_table; - const std::string bucket_table; - const std::string quota_table; - const std::string lc_head_table; - const std::string lc_entry_table; - rgw::sal::Driver* driver; protected: @@ -172,7 +166,6 @@ class POSIXUserDB : public SQLiteDB { 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::set_context(cct); } -- 2.47.3