From: Casey Bodley Date: Mon, 30 Nov 2015 21:18:29 +0000 (-0500) Subject: rgw: move sync_status into RGWRemoteMetaLog X-Git-Tag: v10.1.0~354^2~22 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=25771efa942ba5da1512f2d5d4fc385d6bcc0c92;p=ceph.git rgw: move sync_status into RGWRemoteMetaLog Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 0a3398a6029..9c2857b9b7d 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -4490,7 +4490,7 @@ next: return -ret; } - rgw_meta_sync_status& sync_status = sync.get_sync_status(); + const rgw_meta_sync_status& sync_status = sync.get_sync_status(); formatter->open_object_section("summary"); encode_json("sync_status", sync_status, formatter); diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index 4c7e9961869..dcaaa177d5f 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -240,7 +240,7 @@ int RGWMetaSyncStatusManager::init() return r; } - num_shards = sync_status.sync_info.num_shards; + int num_shards = master_log.get_sync_status().sync_info.num_shards; for (int i = 0; i < num_shards; i++) { shard_objs[i] = rgw_obj(store->get_zone_params().log_pool, sync_env.shard_obj_name(i)); @@ -1524,22 +1524,23 @@ void RGWRemoteMetaLog::init_sync_env(RGWMetaSyncEnv *env) { env->error_logger = error_logger; } -int RGWRemoteMetaLog::read_sync_status(rgw_meta_sync_status *sync_status) +int RGWRemoteMetaLog::read_sync_status() { if (store->is_meta_master()) { return 0; } RGWObjectCtx obj_ctx(store, NULL); - return run(new RGWReadSyncStatusCoroutine(&sync_env, obj_ctx, sync_status)); + return run(new RGWReadSyncStatusCoroutine(&sync_env, obj_ctx, &sync_status)); } -int RGWRemoteMetaLog::init_sync_status(int num_shards) +int RGWRemoteMetaLog::init_sync_status() { if (store->is_meta_master()) { return 0; } + auto num_shards = sync_status.sync_info.num_shards; if (!num_shards) { rgw_mdlog_info mdlog_info; int r = read_log_info(&mdlog_info); @@ -1551,16 +1552,17 @@ int RGWRemoteMetaLog::init_sync_status(int num_shards) } RGWObjectCtx obj_ctx(store, NULL); - return run(new RGWInitSyncStatusCoroutine(&sync_env, obj_ctx, num_shards)); + return run(new RGWInitSyncStatusCoroutine(&sync_env, obj_ctx, + sync_status.sync_info.num_shards)); } -int RGWRemoteMetaLog::set_sync_info(const rgw_meta_sync_info& sync_info) +int RGWRemoteMetaLog::store_sync_info() { return run(new RGWSimpleRadosWriteCR(async_rados, store, store->get_zone_params().log_pool, - sync_env.status_oid(), sync_info)); + sync_env.status_oid(), sync_status.sync_info)); } -int RGWRemoteMetaLog::run_sync(int num_shards, rgw_meta_sync_status& sync_status) +int RGWRemoteMetaLog::run_sync() { if (store->is_meta_master()) { return 0; @@ -1575,13 +1577,6 @@ int RGWRemoteMetaLog::run_sync(int num_shards, rgw_meta_sync_status& sync_status return r; } - if (!num_shards) { - num_shards = mdlog_info.num_shards; - } else if ((uint32_t)num_shards != mdlog_info.num_shards) { - lderr(store->ctx()) << "ERROR: can't sync, mismatch between num shards, master num_shards=" << mdlog_info.num_shards << " local num_shards=" << num_shards << dendl; - return r; - } - do { r = run(new RGWReadSyncStatusCoroutine(&sync_env, obj_ctx, &sync_status)); if (r < 0 && r != -ENOENT) { @@ -1591,7 +1586,8 @@ int RGWRemoteMetaLog::run_sync(int num_shards, rgw_meta_sync_status& sync_status if (sync_status.sync_info.state == rgw_meta_sync_info::StateInit) { ldout(store->ctx(), 20) << __func__ << "(): init" << dendl; - r = run(new RGWInitSyncStatusCoroutine(&sync_env, obj_ctx, num_shards)); + r = run(new RGWInitSyncStatusCoroutine(&sync_env, obj_ctx, + sync_status.sync_info.num_shards)); if (r == -EBUSY) { backoff.backoff_sleep(); continue; @@ -1604,6 +1600,12 @@ int RGWRemoteMetaLog::run_sync(int num_shards, rgw_meta_sync_status& sync_status } } while (sync_status.sync_info.state == rgw_meta_sync_info::StateInit); + auto num_shards = sync_status.sync_info.num_shards; + if (num_shards != mdlog_info.num_shards) { + lderr(store->ctx()) << "ERROR: can't sync, mismatch between num shards, master num_shards=" << mdlog_info.num_shards << " local num_shards=" << num_shards << dendl; + return r; + } + do { r = run(new RGWReadSyncStatusCoroutine(&sync_env, obj_ctx, &sync_status)); if (r < 0 && r != -ENOENT) { @@ -1626,7 +1628,7 @@ int RGWRemoteMetaLog::run_sync(int num_shards, rgw_meta_sync_status& sync_status } sync_status.sync_info.state = rgw_meta_sync_info::StateSync; - r = set_sync_info(sync_status.sync_info); + r = store_sync_info(); if (r < 0) { ldout(store->ctx(), 0) << "ERROR: failed to update sync status" << dendl; return r; diff --git a/src/rgw/rgw_sync.h b/src/rgw/rgw_sync.h index e7e6292da75..0a6799dbc04 100644 --- a/src/rgw/rgw_sync.h +++ b/src/rgw/rgw_sync.h @@ -153,8 +153,10 @@ class RGWRemoteMetaLog : public RGWCoroutinesManager { RGWSyncBackoff backoff; RGWMetaSyncEnv sync_env; + rgw_meta_sync_status sync_status; void init_sync_env(RGWMetaSyncEnv *env); + int store_sync_info(); atomic_t going_down; @@ -172,16 +174,16 @@ public: void finish(); int read_log_info(rgw_mdlog_info *log_info); - int read_sync_status(rgw_meta_sync_status *sync_status); - int init_sync_status(int num_shards); - int set_sync_info(const rgw_meta_sync_info& sync_info); - int run_sync(int num_shards, rgw_meta_sync_status& sync_status); + int read_sync_status(); + int init_sync_status(); + int run_sync(); void wakeup(int shard_id); RGWMetaSyncEnv& get_sync_env() { return sync_env; } + const rgw_meta_sync_status& get_sync_status() const { return sync_status; } }; class RGWMetaSyncStatusManager { @@ -190,11 +192,8 @@ class RGWMetaSyncStatusManager { RGWRemoteMetaLog master_log; - rgw_meta_sync_status sync_status; map shard_objs; - int num_shards; - struct utime_shard { utime_t ts; int shard_id; @@ -216,16 +215,18 @@ class RGWMetaSyncStatusManager { public: RGWMetaSyncStatusManager(RGWRados *_store, RGWAsyncRadosProcessor *async_rados) : store(_store), master_log(store, async_rados, this), - num_shards(0), ts_to_shard_lock("ts_to_shard_lock") {} + ts_to_shard_lock("ts_to_shard_lock") {} int init(); void finish(); - rgw_meta_sync_status& get_sync_status() { return sync_status; } + const rgw_meta_sync_status& get_sync_status() const { + return master_log.get_sync_status(); + } - int read_sync_status() { return master_log.read_sync_status(&sync_status); } - int init_sync_status() { return master_log.init_sync_status(num_shards); } + int read_sync_status() { return master_log.read_sync_status(); } + int init_sync_status() { return master_log.init_sync_status(); } - int run() { return master_log.run_sync(num_shards, sync_status); } + int run() { return master_log.run_sync(); } void wakeup(int shard_id) { return master_log.wakeup(shard_id); } void stop() {