Skip to content

Commit b229903

Browse files
committed
RGW/standalone: refactoring issues for ConfigStore and rgw_zone
Signed-off-by: Ali Masarwa <[email protected]>
1 parent 055048b commit b229903

File tree

10 files changed

+17
-26
lines changed

10 files changed

+17
-26
lines changed

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ class RGWSyncProcessorThread : public RGWRadosThread {
483483
class RGWMetaSyncProcessorThread : public RGWSyncProcessorThread
484484
{
485485
RGWMetaSyncStatusManager sync;
486-
rgw::sal::ConfigStore* cfgstore;
486+
rgw::sal::ConfigStore *cfgstore{nullptr};
487487

488488
uint64_t interval_msec() override {
489489
return 0; /* no interval associated, it'll run once until stopped */
@@ -492,8 +492,9 @@ class RGWMetaSyncProcessorThread : public RGWSyncProcessorThread
492492
sync.stop();
493493
}
494494
public:
495-
RGWMetaSyncProcessorThread(rgw::sal::RadosStore* _driver, RGWAsyncRadosProcessor *async_rados)
496-
: RGWSyncProcessorThread(_driver->getRados(), "meta-sync"), sync(_driver, async_rados) {}
495+
RGWMetaSyncProcessorThread(rgw::sal::RadosStore* _driver, RGWAsyncRadosProcessor *async_rados,
496+
rgw::sal::ConfigStore *_cfgstore)
497+
: RGWSyncProcessorThread(_driver->getRados(), "meta-sync"), sync(_driver, async_rados), cfgstore(_cfgstore) {}
497498

498499
void wakeup_sync_shards(set<int>& shard_ids) {
499500
for (set<int>::iterator iter = shard_ids.begin(); iter != shard_ids.end(); ++iter) {
@@ -537,11 +538,11 @@ class RGWDataSyncProcessorThread : public RGWSyncProcessorThread
537538
}
538539
public:
539540
RGWDataSyncProcessorThread(rgw::sal::RadosStore* _driver, RGWAsyncRadosProcessor *async_rados,
540-
const RGWZone* source_zone)
541+
const RGWZone* source_zone, rgw::sal::ConfigStore *_cfgstore)
541542
: RGWSyncProcessorThread(_driver->getRados(), "data-sync"),
542543
counters(sync_counters::build(store->ctx(), std::string("data-sync-from-") + source_zone->name)),
543544
sync(_driver, async_rados, source_zone->id, counters.get()),
544-
initialized(false) {}
545+
initialized(false), cfgstore(_cfgstore) {}
545546

546547
void wakeup_sync_shards(bc::flat_map<int, bc::flat_set<rgw_data_notify_entry> >& entries) {
547548
for (bc::flat_map<int, bc::flat_set<rgw_data_notify_entry> >::iterator iter = entries.begin(); iter != entries.end(); ++iter) {
@@ -1222,7 +1223,7 @@ int RGWRados::update_service_map(const DoutPrefixProvider *dpp, std::map<std::st
12221223
* Initialize the RADOS instance and prepare to do other ops
12231224
* Returns 0 on success, -ERR# on failure.
12241225
*/
1225-
int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y)
1226+
int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y, rgw::sal::ConfigStore* cfgstore)
12261227
{
12271228
int ret;
12281229

@@ -1306,7 +1307,7 @@ int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y)
13061307
}
13071308
auto async_processor = svc.async_processor;
13081309
std::lock_guard l{meta_sync_thread_lock};
1309-
meta_sync_processor_thread = new RGWMetaSyncProcessorThread(this->driver, async_processor);
1310+
meta_sync_processor_thread = new RGWMetaSyncProcessorThread(this->driver, async_processor, cfgstore);
13101311
ret = meta_sync_processor_thread->init(dpp);
13111312
if (ret < 0) {
13121313
ldpp_dout(dpp, 0) << "ERROR: failed to initialize meta sync thread" << dendl;
@@ -1329,7 +1330,7 @@ int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y)
13291330
std::lock_guard dl{data_sync_thread_lock};
13301331
for (auto source_zone : svc.zone->get_data_sync_source_zones()) {
13311332
ldpp_dout(dpp, 5) << "starting data sync thread for zone " << source_zone->name << dendl;
1332-
auto *thread = new RGWDataSyncProcessorThread(this->driver, svc.async_processor, source_zone);
1333+
auto *thread = new RGWDataSyncProcessorThread(this->driver, svc.async_processor, source_zone, cfgstore);
13331334
ret = thread->init(dpp);
13341335
if (ret < 0) {
13351336
ldpp_dout(dpp, 0) << "ERROR: failed to initialize data sync thread" << dendl;

src/rgw/driver/rados/rgw_rados.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ class RGWRados
599599
/** Initialize the RADOS instance and prepare to do other ops */
600600
int init_svc(bool raw, const DoutPrefixProvider *dpp, bool background_tasks, const rgw::SiteConfig& site, rgw::sal::ConfigStore* cfgstore);
601601
virtual int init_rados();
602-
int init_complete(const DoutPrefixProvider *dpp, optional_yield y);
602+
int init_complete(const DoutPrefixProvider *dpp, optional_yield y, rgw::sal::ConfigStore* cfgstore);
603603
void finalize();
604604

605605
int register_to_service_map(const DoutPrefixProvider *dpp, const std::string& daemon_type, const std::map<std::string, std::string>& meta);

src/rgw/driver/rados/rgw_rest_realm.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ void RGWOp_Period_Post::execute(optional_yield y)
100100
{
101101
auto cct = driver->ctx();
102102

103-
// initialize the period without reading from rados
104-
s->penv.cfgstore->read_period(this, y, driver->get_zone()->get_current_period_id(), std::nullopt, period);
105-
106103
// decode the period from input
107104
const auto max_size = cct->_conf->rgw_max_put_param_size;
108105
bool empty;
@@ -144,10 +141,6 @@ void RGWOp_Period_Post::execute(optional_yield y)
144141

145142
// if period id is empty, handle as 'period commit'
146143
if (period.get_id().empty()) {
147-
if (op_ret < 0) {
148-
cerr << "Error initializing realm: " << cpp_strerror(-op_ret) << std::endl;
149-
return;
150-
}
151144
op_ret = rgw::commit_period(this, y, s->penv.cfgstore, driver, realm, *realm_writer, current_period, period, error_stream, false);
152145
if (op_ret == -EEXIST) {
153146
op_ret = 0; // succeed on retries so the op is idempotent
@@ -309,7 +302,6 @@ void RGWOp_Realm_Get::execute(optional_yield y)
309302

310303
// read realm
311304
realm.reset(new RGWRealm(id, name));
312-
auto config_store_type = g_conf().get_val<std::string>("rgw_config_store");
313305
op_ret = rgw::read_realm(this, y, s->penv.cfgstore, realm->get_id(), realm->get_name(), *realm);
314306
if (op_ret < 0)
315307
ldpp_dout(this, -1) << "failed to read realm id=" << id

src/rgw/radosgw-admin/radosgw-admin.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4601,7 +4601,7 @@ int main(int argc, const char **argv)
46014601
false,
46024602
false, // No background tasks!
46034603
null_yield,
4604-
cfgstore.get(),
4604+
cfgstore.get(),
46054605
need_cache && g_conf()->rgw_cache_enabled,
46064606
need_gc);
46074607
}

src/rgw/rgw_rest_ratelimit.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ void RGWOp_Ratelimit_Info::execute(optional_yield y)
105105
if (global) {
106106
std::string realm_id = driver->get_zone()->get_realm_id();
107107
RGWPeriodConfig period_config;
108-
auto config_store_type = g_conf().get_val<std::string>("rgw_config_store");
109108
auto cfgstore = s->penv.cfgstore;
110109
op_ret = cfgstore->read_period_config(this, y, realm_id, period_config);
111110
if (op_ret && op_ret != -ENOENT) {
@@ -309,7 +308,6 @@ void RGWOp_Ratelimit_Set::execute(optional_yield y)
309308
return;
310309
}
311310

312-
auto config_store_type = g_conf().get_val<std::string>("rgw_config_store");
313311
auto cfgstore = s->penv.cfgstore;
314312
if (global) {
315313
std::string realm_id = driver->get_zone()->get_realm_id();

src/rgw/rgw_sal.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
106106
delete driver;
107107
return nullptr;
108108
}
109-
if (rados->init_complete(dpp, y) < 0) {
109+
if (rados->init_complete(dpp, y, cfgstore) < 0) {
110110
delete driver;
111111
return nullptr;
112112
}
@@ -133,7 +133,7 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
133133
delete driver;
134134
return nullptr;
135135
}
136-
if (rados->init_complete(dpp, y) < 0) {
136+
if (rados->init_complete(dpp, y, cfgstore) < 0) {
137137
delete driver;
138138
return nullptr;
139139
}

src/rgw/services/svc_cls.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class RGWSI_Cls : public RGWServiceInstance
2828
{
2929
RGWSI_Zone *zone_svc{nullptr};
3030
librados::Rados* rados{nullptr};
31-
rgw::sal::ConfigStore* cfgstore{nullptr};
3231

3332
class ClsSubService : public RGWServiceInstance {
3433
friend class RGWSI_Cls;

src/rgw/services/svc_notify.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class RGWSI_Notify : public RGWServiceInstance
3030
RGWSI_Zone *zone_svc{nullptr};
3131
librados::Rados *rados{nullptr};
3232
RGWSI_Finisher *finisher_svc{nullptr};
33-
rgw::sal::ConfigStore *cfgstore{nullptr};
3433

3534
ceph::shared_mutex watchers_lock = ceph::make_shared_mutex("watchers_lock");
3635
rgw_pool control_pool;

src/rgw/services/svc_sys_obj_cache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class RGWSI_SysObj_Cache : public RGWSI_SysObj_Core
2626
ObjectCache cache;
2727

2828
std::shared_ptr<RGWSI_SysObj_Cache_CB> cb;
29-
rgw::sal::ConfigStore *cfgstore{nullptr};
3029

3130
void normalize_pool_and_obj(const rgw_pool& src_pool, const std::string& src_obj, rgw_pool& dst_pool, std::string& dst_obj);
3231
protected:

src/test/rgw/test_d4n_filter.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "rgw_aio_throttle.h"
1313
#include "rgw_sal.h"
1414
#include "rgw_sal_store.h"
15+
#include "rgw_sal_config.h"
1516
#include "driver/dbstore/common/dbstore.h"
1617
#include "rgw_sal_d4n.h"
1718
#include "rgw_sal_filter.h"
@@ -115,9 +116,11 @@ class D4NFilterFixture: public ::testing::Test {
115116
DriverManager::Config cfg = DriverManager::get_config(true, g_ceph_context);
116117
cfg.store_name = "dbstore";
117118
cfg.filter_name = "d4n";
119+
auto config_store_type = g_conf().get_val<std::string>("rgw_config_store");
120+
auto cfgstore = DriverManager::create_config_store(env->dpp, config_store_type);
118121

119122
auto filterDriver = DriverManager::get_raw_storage(env->dpp, g_ceph_context,
120-
cfg, io, site_config);
123+
cfg, io, site_config, cfgstore.get());
121124

122125
rgw::sal::Driver* next = filterDriver;
123126
driver = newD4NFilter(next, io);

0 commit comments

Comments
 (0)