From 8bcdb77d9ad2714abbb887e4b6331e04658d0a51 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 11 Jan 2016 17:09:29 -0800 Subject: [PATCH] rgw: stop meta sync handler when going down it needed to check internally whether it was going down Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_coroutine.cc | 12 ++++++++---- src/rgw/rgw_sync.cc | 3 ++- src/rgw/rgw_sync.h | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_coroutine.cc b/src/rgw/rgw_coroutine.cc index 40fb83d6280ef..7738832dcf86d 100644 --- a/src/rgw/rgw_coroutine.cc +++ b/src/rgw/rgw_coroutine.cc @@ -410,6 +410,7 @@ void RGWCoroutinesManager::schedule(RGWCoroutinesEnv *env, RGWCoroutinesStack *s int RGWCoroutinesManager::run(list& stacks) { + int ret = 0; int blocked_count = 0; int interval_wait_count = 0; RGWCoroutinesEnv env; @@ -504,7 +505,7 @@ int RGWCoroutinesManager::run(list& stacks) * these aren't really waiting for IOs */ while (blocked_count - interval_wait_count >= ops_window) { - int ret = completion_mgr.get_next((void **)&blocked_stack); + ret = completion_mgr.get_next((void **)&blocked_stack); if (ret < 0) { ldout(cct, 0) << "ERROR: failed to clone shard, completion_mgr.get_next() returned ret=" << ret << dendl; } @@ -516,13 +517,14 @@ int RGWCoroutinesManager::run(list& stacks) while (scheduled_stacks.empty() && blocked_count > 0) { - int ret = completion_mgr.get_next((void **)&blocked_stack); + ret = completion_mgr.get_next((void **)&blocked_stack); if (ret < 0) { ldout(cct, 0) << "ERROR: failed to clone shard, completion_mgr.get_next() returned ret=" << ret << dendl; } if (going_down.read() > 0) { ldout(cct, 5) << __func__ << "(): was stopped, exiting" << dendl; - return -ECANCELED; + ret = -ECANCELED; + break; } handle_unblocked_stack(context_stacks, scheduled_stacks, blocked_stack, &blocked_count); iter = scheduled_stacks.begin(); @@ -531,6 +533,8 @@ int RGWCoroutinesManager::run(list& stacks) if (iter == scheduled_stacks.end()) { iter = scheduled_stacks.begin(); } + + ret = 0; } lock.get_write(); @@ -541,7 +545,7 @@ int RGWCoroutinesManager::run(list& stacks) run_contexts.erase(run_context); lock.unlock(); - return 0; + return ret; } int RGWCoroutinesManager::run(RGWCoroutine *op) diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index f2d87a7f82d17..a3d421857dd67 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -172,6 +172,7 @@ int RGWRemoteMetaLog::init() void RGWRemoteMetaLog::finish() { + going_down.set(1); stop(); if (async_rados) { async_rados->stop(); @@ -1717,7 +1718,7 @@ int RGWRemoteMetaLog::run_sync(int num_shards, rgw_meta_sync_status& sync_status ldout(store->ctx(), 0) << "ERROR: bad sync state!" << dendl; return -EIO; } - } while (true); + } while (!going_down.read()); return 0; } diff --git a/src/rgw/rgw_sync.h b/src/rgw/rgw_sync.h index e386329f4f59a..787217dbcc9db 100644 --- a/src/rgw/rgw_sync.h +++ b/src/rgw/rgw_sync.h @@ -108,6 +108,8 @@ class RGWRemoteMetaLog : public RGWCoroutinesManager { void init_sync_env(RGWMetaSyncEnv *env); + atomic_t going_down; + public: RGWRemoteMetaLog(RGWRados *_store, RGWMetaSyncStatusManager *_sm) : RGWCoroutinesManager(_store->ctx(), _store->get_cr_registry()), store(_store), conn(NULL), async_rados(nullptr), -- 2.39.5