From e53fbe31c80c342f5df57fe60821124fe12568a8 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 7 Jan 2016 16:32:28 -0500 Subject: [PATCH] rgw: split RGWPeriod::reflect out of set_latest_epoch Signed-off-by: Casey Bodley --- src/rgw/rgw_admin.cc | 5 +++++ src/rgw/rgw_rados.cc | 17 ++++++----------- src/rgw/rgw_rest_realm.cc | 7 +++++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index da0cf14638ed5..0638b10ce63b1 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1430,6 +1430,11 @@ static int commit_period(RGWRealm& realm, RGWPeriod& period, cerr << "Error updating period epoch: " << cpp_strerror(ret) << std::endl; return ret; } + ret = period.reflect(); + if (ret < 0) { + cerr << "Error updating local objects: " << cpp_strerror(ret) << std::endl; + return ret; + } realm.notify_new_period(period); return ret; } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 3418418e6ff91..11a1554998b29 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1008,17 +1008,7 @@ int RGWPeriod::set_latest_epoch(epoch_t epoch) ::encode(info, bl); - int ret = rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), false, NULL, 0, NULL); - if (ret < 0) - return ret; - - ret = reflect(); - if (ret < 0) { - ldout(cct, 0) << "ERROR: period.reflect(): " << cpp_strerror(-ret) << dendl; - return ret; - } - - return 0; + return rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), false, NULL, 0, NULL); } int RGWPeriod::delete_obj() @@ -1344,6 +1334,11 @@ int RGWPeriod::commit(RGWRealm& realm, const RGWPeriod& current_period) lderr(cct) << "failed to set latest epoch: " << cpp_strerror(-r) << dendl; return r; } + r = reflect(); + if (r < 0) { + lderr(cct) << "failed to update local objects: " << cpp_strerror(-r) << dendl; + return r; + } ldout(cct, 4) << "Committed new epoch " << epoch << " for period " << id << dendl; realm.notify_new_period(*this); diff --git a/src/rgw/rgw_rest_realm.cc b/src/rgw/rgw_rest_realm.cc index 8db20bd90b787..9e466d6960db1 100644 --- a/src/rgw/rgw_rest_realm.cc +++ b/src/rgw/rgw_rest_realm.cc @@ -171,6 +171,13 @@ void RGWOp_Period_Post::execute() lderr(cct) << "failed to set latest epoch" << dendl; return; } + // reflect the period into our local objects + http_ret = period.reflect(); + if (http_ret < 0) { + lderr(cct) << "failed to update local objects: " + << cpp_strerror(-http_ret) << dendl; + return; + } ldout(cct, 4) << "period epoch " << period.get_epoch() << " is newer than current epoch " << current_period.get_epoch() << ", updating latest epoch and notifying zone" << dendl; -- 2.39.5