]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: migrate atomic_t to std::atomic<> 14839/head
authorJesse Williamson <jwilliamson@suse.de>
Wed, 26 Apr 2017 12:26:38 +0000 (05:26 -0700)
committerJesse Williamson <jwilliamson@suse.de>
Fri, 28 Apr 2017 07:10:55 +0000 (00:10 -0700)
Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
31 files changed:
src/common/RefCountedObj.h
src/rgw/rgw_bucket.cc
src/rgw/rgw_bucket.h
src/rgw/rgw_coroutine.cc
src/rgw/rgw_coroutine.h
src/rgw/rgw_cr_rados.cc
src/rgw/rgw_cr_rados.h
src/rgw/rgw_file.cc
src/rgw/rgw_file.h
src/rgw/rgw_gc.cc
src/rgw/rgw_gc.h
src/rgw/rgw_http_client.cc
src/rgw/rgw_http_client.h
src/rgw/rgw_keystone.cc
src/rgw/rgw_keystone.h
src/rgw/rgw_lc.cc
src/rgw/rgw_lc.h
src/rgw/rgw_loadgen_process.cc
src/rgw/rgw_main.cc
src/rgw/rgw_object_expirer_core.cc
src/rgw/rgw_object_expirer_core.h
src/rgw/rgw_process.h
src/rgw/rgw_quota.cc
src/rgw/rgw_quota.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_request.h
src/rgw/rgw_rest_conn.cc
src/rgw/rgw_rest_conn.h
src/rgw/rgw_sync.cc
src/rgw/rgw_sync.h

index 2da83d1a760afeb4a2f778cd6156873f70459531..6099bfff7170299728f0f000e572c183f1a612fa 100644 (file)
 #include "common/ceph_context.h"
 #include "common/valgrind.h"
 
+#include <atomic>
+
+// re-include our assert to clobber the system one; fix dout:
+#include "include/assert.h"
+
 struct RefCountedObject {
 private:
   mutable atomic_t nref;
index 5e0548afb796b03b395c9be9588253466b7cf1f6..015aab1d69a01cd0a513511124909988dc6c6281 100644 (file)
@@ -1950,11 +1950,11 @@ int RGWDataChangesLog::trim_entries(const real_time& start_time, const real_time
 
 bool RGWDataChangesLog::going_down()
 {
-  return (down_flag.read() != 0);
+  return down_flag;
 }
 
 RGWDataChangesLog::~RGWDataChangesLog() {
-  down_flag.set(1);
+  down_flag = true;
   renew_thread->stop();
   renew_thread->join();
   delete renew_thread;
index 3c6b399bdf751e621cc6c0bbcb306beaae8039f4..09a5ae2e825b3e54b7488b2b0e23a3c9302ee0f5 100644 (file)
@@ -404,7 +404,7 @@ class RGWDataChangesLog {
   RWLock modified_lock;
   map<int, set<string> > modified_shards;
 
-  atomic_t down_flag;
+  std::atomic<bool> down_flag = { false };
 
   struct ChangeStatus {
     real_time cur_expiration;
index 85ad290d02018f7f67293243fde36f46b3771bfb..4bb48da49dc144f161ac74372a08307dee2944d0 100644 (file)
@@ -1,10 +1,11 @@
 
-
 #include "common/ceph_json.h"
 
 #include "rgw_coroutine.h"
 #include "rgw_boost_asio_yield.h"
 
+// re-include our assert to clobber the system one; fix dout:
+#include "include/assert.h"
 
 #define dout_subsys ceph_subsys_rgw
 
@@ -68,7 +69,7 @@ int RGWCompletionManager::get_next(void **user_info)
   Mutex::Locker l(lock);
   while (complete_reqs.empty()) {
     cond.Wait(lock);
-    if (going_down.read() != 0) {
+    if (going_down) {
       return -ECANCELED;
     }
   }
@@ -94,7 +95,7 @@ void RGWCompletionManager::go_down()
   for (auto cn : cns) {
     cn->unregister();
   }
-  going_down.set(1);
+  going_down = true;
   cond.Signal();
 }
 
@@ -460,7 +461,7 @@ int RGWCoroutinesManager::run(list<RGWCoroutinesStack *>& stacks)
   bool canceled = false; // set on going_down
   RGWCoroutinesEnv env;
 
-  uint64_t run_context = run_context_count.inc();
+  uint64_t run_context = ++run_context_count;
 
   lock.get_write();
   set<RGWCoroutinesStack *>& context_stacks = run_contexts[run_context];
@@ -475,7 +476,7 @@ int RGWCoroutinesManager::run(list<RGWCoroutinesStack *>& stacks)
   env.manager = this;
   env.scheduled_stacks = &scheduled_stacks;
 
-  for (list<RGWCoroutinesStack *>::iterator iter = scheduled_stacks.begin(); iter != scheduled_stacks.end() && !going_down.read();) {
+  for (list<RGWCoroutinesStack *>::iterator iter = scheduled_stacks.begin(); iter != scheduled_stacks.end() && !going_down;) {
     lock.get_write();
 
     RGWCoroutinesStack *stack = *iter;
@@ -566,7 +567,7 @@ int RGWCoroutinesManager::run(list<RGWCoroutinesStack *>& stacks)
       if (ret < 0) {
        ldout(cct, 0) << "ERROR: failed to clone shard, completion_mgr.get_next() returned ret=" << ret << dendl;
       }
-      if (going_down.read() > 0) {
+      if (going_down) {
        ldout(cct, 5) << __func__ << "(): was stopped, exiting" << dendl;
        ret = -ECANCELED;
         canceled = true;
@@ -585,7 +586,7 @@ int RGWCoroutinesManager::run(list<RGWCoroutinesStack *>& stacks)
   }
 
   lock.get_write();
-  if (!context_stacks.empty() && !going_down.read()) {
+  if (!context_stacks.empty() && !going_down) {
     JSONFormatter formatter(true);
     formatter.open_array_section("context_stacks");
     for (auto& s : context_stacks) {
@@ -595,7 +596,7 @@ int RGWCoroutinesManager::run(list<RGWCoroutinesStack *>& stacks)
     lderr(cct) << __func__ << "(): ERROR: deadlock detected, dumping remaining coroutines:\n";
     formatter.flush(*_dout);
     *_dout << dendl;
-    assert(context_stacks.empty() || going_down.read()); // assert on deadlock
+    assert(context_stacks.empty() || going_down); // assert on deadlock
   }
 
   for (auto stack : context_stacks) {
index 821ff55889ace5f9414fbc4c7509da1e8e125dbf..66afa74b375f86b8a6fca65c89f2a858dad8ae8d 100644 (file)
@@ -22,6 +22,8 @@
 #include "rgw_common.h"
 #include "rgw_boost_asio_coroutine.h"
 
+#include <atomic>
+
 #define RGW_ASYNC_OPS_MGR_WINDOW 100
 
 class RGWCoroutinesStack;
@@ -39,7 +41,7 @@ class RGWCompletionManager : public RefCountedObject {
 
   SafeTimer timer;
 
-  atomic_t going_down;
+  std::atomic<bool> going_down = { false };
 
   map<void *, void *> waiters;
 
@@ -506,9 +508,9 @@ public:
 
 class RGWCoroutinesManager {
   CephContext *cct;
-  atomic_t going_down;
+  std::atomic<bool> going_down = { false };
 
-  atomic64_t run_context_count;
+  std::atomic<int64_t> run_context_count = { 0 };
   map<uint64_t, set<RGWCoroutinesStack *> > run_contexts;
 
   RWLock lock;
@@ -542,7 +544,8 @@ public:
   int run(list<RGWCoroutinesStack *>& ops);
   int run(RGWCoroutine *op);
   void stop() {
-    if (going_down.inc() == 1) {
+    bool expected = false;
+    if (going_down.compare_exchange_strong(expected, true)) {
       completion_mgr->go_down();
     }
   }
index 489ef589172593136a4b4f334f0e3db94544d13d..9316d62039890eafd7cec9f79453a5f06f957c28 100644 (file)
@@ -65,7 +65,7 @@ void RGWAsyncRadosProcessor::start() {
 }
 
 void RGWAsyncRadosProcessor::stop() {
-  going_down.set(1);
+  going_down = true;
   m_tp.drain(&req_wq);
   m_tp.stop();
   for (auto iter = m_req_queue.begin(); iter != m_req_queue.end(); ++iter) {
@@ -627,7 +627,7 @@ int RGWContinuousLeaseCR::operate()
     return set_cr_done();
   }
   reenter(this) {
-    while (!going_down.read()) {
+    while (!going_down) {
       yield call(new RGWSimpleRadosLockCR(async_rados, store, obj, lock_name, cookie, interval));
 
       caller->set_sleeping(false); /* will only be relevant when we return, that's why we can do it early */
index 8496201e0cdf4933ea1d5789c52cc4dcae0aa1f3..ddc9524c8cd34452ca850b0c2fefb77bdbf0b7b1 100644 (file)
@@ -6,6 +6,8 @@
 #include "common/WorkQueue.h"
 #include "common/Throttle.h"
 
+#include <atomic>
+
 class RGWAsyncRadosRequest : public RefCountedObject {
   RGWCoroutine *caller;
   RGWAioCompletionNotifier *notifier;
@@ -57,7 +59,7 @@ public:
 
 class RGWAsyncRadosProcessor {
   deque<RGWAsyncRadosRequest *> m_req_queue;
-  atomic_t going_down;
+  std::atomic<bool> going_down = { false };
 protected:
   RGWRados *store;
   ThreadPool m_tp;
@@ -91,7 +93,7 @@ public:
   void queue(RGWAsyncRadosRequest *req);
 
   bool is_going_down() {
-    return (going_down.read() != 0);
+    return going_down;
   }
 };
 
@@ -1014,7 +1016,7 @@ class RGWContinuousLeaseCR : public RGWCoroutine {
   int interval;
 
   Mutex lock;
-  atomic_t going_down;
+  std::atomic<bool> going_down = { false };
   bool locked{false};
 
   RGWCoroutine *caller;
@@ -1044,7 +1046,7 @@ public:
   }
 
   void go_down() {
-    going_down.set(1);
+    going_down = true;
     wakeup();
   }
 
index be3d356ec41a6461df098c28d68186bde3b0796d..3fe8ba055916fc03dc994cef99a583b601357ad0 100644 (file)
@@ -27,6 +27,8 @@
 #include "rgw_file.h"
 #include "rgw_lib_frontend.h"
 
+#include <atomic>
+
 #define dout_subsys ceph_subsys_rgw
 
 using namespace rgw;
@@ -37,7 +39,7 @@ namespace rgw {
 
   const string RGWFileHandle::root_name = "/";
 
-  atomic<uint32_t> RGWLibFS::fs_inst_counter;
+  std::atomic<uint32_t> RGWLibFS::fs_inst_counter;
 
   uint32_t RGWLibFS::write_completion_interval_s = 10;
 
index 5d964f9c2aa1e8d125c8b8fdb960ac796f7d2836..cdb72b92f3e68d9d5a03c1c1ccd91d03d506d71b 100644 (file)
@@ -745,7 +745,7 @@ namespace rgw {
     RGWUserInfo user;
     RGWAccessKey key; // XXXX acc_key
 
-    static atomic<uint32_t> fs_inst_counter;
+    static std::atomic<uint32_t> fs_inst_counter;
 
     static uint32_t write_completion_interval_s;
     std::string fsid;
index c46f693daea67fe16cfc729aa8d40e7ada6cabf2..8fb461292dc6b07490629dc51306158d03101256 100644 (file)
@@ -253,7 +253,7 @@ int RGWGC::process()
 
 bool RGWGC::going_down()
 {
-  return (down_flag.read() != 0);
+  return down_flag;
 }
 
 void RGWGC::start_processor()
@@ -264,7 +264,7 @@ void RGWGC::start_processor()
 
 void RGWGC::stop_processor()
 {
-  down_flag.set(1);
+  down_flag = true;
   if (worker) {
     worker->stop();
     worker->join();
index ca48a6e75e55ccb992814654a2d384ca99732a4f..491796b50e86d6dc1d876a3c173873f3274854dd 100644 (file)
@@ -6,7 +6,6 @@
 
 
 #include "include/types.h"
-#include "include/atomic.h"
 #include "include/rados/librados.hpp"
 #include "common/Mutex.h"
 #include "common/Cond.h"
 #include "rgw_rados.h"
 #include "cls/rgw/cls_rgw_types.h"
 
+#include <atomic>
+
 class RGWGC {
   CephContext *cct;
   RGWRados *store;
   int max_objs;
   string *obj_names;
-  atomic_t down_flag;
+  std::atomic<bool> down_flag = { false };
 
   int tag_index(const string& tag);
 
index 070110e509987bd7f5cac8ddcccf97dbefc0705e..81c4c6ef6bca3480135f600bf65b4c43a612825f 100644 (file)
@@ -16,6 +16,8 @@
 
 #include "rgw_coroutine.h"
 
+#include <atomic>
+
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_rgw
 
@@ -24,7 +26,7 @@ struct rgw_http_req_data : public RefCountedObject {
   curl_slist *h;
   uint64_t id;
   int ret;
-  atomic_t done;
+  std::atomic<bool> done = { false };
   RGWHTTPClient *client;
   void *user_info;
   bool registered;
@@ -58,12 +60,12 @@ struct rgw_http_req_data : public RefCountedObject {
 
     easy_handle = NULL;
     h = NULL;
-    done.set(1);
+    done = true;
     cond.Signal();
   }
 
   bool is_done() {
-    return done.read() != 0;
+    return done;
   }
 
   int get_retcode() {
@@ -900,14 +902,14 @@ int RGWHTTPManager::set_threaded()
 
 void RGWHTTPManager::stop()
 {
-  if (is_stopped.read()) {
+  if (is_stopped) {
     return;
   }
 
-  is_stopped.set(1);
+  is_stopped = true;
 
   if (is_threaded) {
-    going_down.set(1);
+    going_down = true;
     signal_thread();
     reqs_thread->join();
     delete reqs_thread;
@@ -935,7 +937,7 @@ void *RGWHTTPManager::reqs_thread_entry()
 
   ldout(cct, 20) << __func__ << ": start" << dendl;
 
-  while (!going_down.read()) {
+  while (!going_down) {
     int ret = do_curl_wait(cct, (CURLM *)multi_handle, thread_pipe[0]);
     if (ret < 0) {
       dout(0) << "ERROR: do_curl_wait() returned: " << ret << dendl;
index 4266b7b50ba3a7f6f7d166f880f66f9703855f6c..cbe4f3d031210ec86639e1d04c68f4daa8f52ca4 100644 (file)
@@ -6,10 +6,11 @@
 
 #include "common/RWLock.h"
 #include "common/Cond.h"
-#include "include/atomic.h"
 #include "rgw_common.h"
 #include "rgw_string.h"
 
+#include <atomic>
+
 using param_pair_t = pair<string, string>;
 using param_vec_t = vector<param_pair_t>;
 
@@ -33,7 +34,7 @@ class RGWHTTPClient
   string last_url;
   bool verify_ssl; // Do not validate self signed certificates, default to false
 
-  atomic_t stopped;
+  std::atomic<unsigned> stopped { 0 };
 
 protected:
   CephContext *cct;
@@ -219,8 +220,8 @@ class RGWHTTPManager {
   RGWCompletionManager *completion_mgr;
   void *multi_handle;
   bool is_threaded;
-  atomic_t going_down;
-  atomic_t is_stopped;
+  std::atomic<unsigned> going_down { 0 };
+  std::atomic<unsigned> is_stopped { 0 };
 
   RWLock reqs_lock;
   map<uint64_t, rgw_http_req_data *> reqs;
index 933308240e2ca08a616c69f3511ae2df04887254..3294380ba100c5b580d6689f6dda8ea078098383 100644 (file)
@@ -613,7 +613,7 @@ int TokenCache::RevokeThread::check_revoked()
 
 bool TokenCache::going_down() const
 {
-  return (down_flag.read() != 0);
+  return down_flag;
 }
 
 void* TokenCache::RevokeThread::entry()
index 5bacfb0da5eae43c2c952cc58832a49da701d732..df5650c59274e81865f105e99bc415e7f7bd7cb8 100644 (file)
@@ -13,6 +13,8 @@
 #include "rgw_http_client.h"
 #include "common/Cond.h"
 
+#include <atomic>
+
 int rgw_open_cms_envelope(CephContext *cct,
                           const std::string& src,
                           std::string& dst);            /* out */
@@ -216,7 +218,7 @@ class TokenCache {
     list<string>::iterator lru_iter;
   };
 
-  atomic_t down_flag;
+  std::atomic<bool> down_flag = { false };
 
   class RevokeThread : public Thread {
     friend class TokenCache;
@@ -271,7 +273,7 @@ class TokenCache {
   }
 
   ~TokenCache() {
-    down_flag.set(1);
+    down_flag = true;
 
     revocator.stop();
     revocator.join();
index 61d4cc944278269220d2165d7b01c7ede11323e7..38a66a35573bdb7cfbd5d0d6d86ede5cce0dfae2 100644 (file)
@@ -655,7 +655,7 @@ void RGWLC::start_processor()
 
 void RGWLC::stop_processor()
 {
-  down_flag.set(1);
+  down_flag = true;
   if (worker) {
     worker->stop();
     worker->join();
@@ -672,7 +672,7 @@ void RGWLC::LCWorker::stop()
 
 bool RGWLC::going_down()
 {
-  return (down_flag.read() != 0);
+  return down_flag;
 }
 
 bool RGWLC::LCWorker::should_work(utime_t& now)
index 61edd78aac720818efc8b44adfabcf2c359161c7..e66735e3a2ce589ce3b112571ab19645522d5ea2 100644 (file)
@@ -9,7 +9,6 @@
 #include "common/debug.h"
 
 #include "include/types.h"
-#include "include/atomic.h"
 #include "include/rados/librados.hpp"
 #include "common/Mutex.h"
 #include "common/Cond.h"
@@ -19,6 +18,8 @@
 #include "rgw_multi.h"
 #include "cls/rgw/cls_rgw_types.h"
 
+#include <atomic>
+
 using namespace std;
 #define HASH_PRIME 7877
 #define MAX_ID_LEN 255
@@ -227,7 +228,7 @@ class RGWLC {
   RGWRados *store;
   int max_objs;
   string *obj_names;
-  atomic_t down_flag;
+  std::atomic<bool> down_flag = { false };
   string cookie;
 
   class LCWorker : public Thread {
index 7f003facbb7043d4eb411307995d6b44f5266845..23e6fefca73e7d4ea1749f4034ee797792e75605 100644 (file)
@@ -13,6 +13,8 @@
 #include "rgw_loadgen.h"
 #include "rgw_client_io.h"
 
+#include <atomic>
+
 #define dout_subsys ceph_subsys_rgw
 
 extern void signal_shutdown();
@@ -37,7 +39,7 @@ void RGWLoadGenProcess::run()
 
   vector<string> buckets(num_buckets);
 
-  atomic_t failed;
+  std::atomic<long int> failed = { 0 };
 
   for (i = 0; i < num_buckets; i++) {
     buckets[i] = "/loadgen";
@@ -51,7 +53,7 @@ void RGWLoadGenProcess::run()
 
   string *objs = new string[num_objs];
 
-  if (failed.read()) {
+  if (failed) {
     derr << "ERROR: bucket creation failed" << dendl;
     goto done;
   }
@@ -69,7 +71,7 @@ void RGWLoadGenProcess::run()
 
   checkpoint();
 
-  if (failed.read()) {
+  if (failed) {
     derr << "ERROR: bucket creation failed" << dendl;
     goto done;
   }
@@ -102,7 +104,7 @@ done:
 
 void RGWLoadGenProcess::gen_request(const string& method,
                                    const string& resource,
-                                   int content_length, atomic_t* fail_flag)
+                                   int content_length, std::atomic<long int>* fail_flag)
 {
   RGWLoadGenRequest* req =
     new RGWLoadGenRequest(store->get_new_req_id(), method, resource,
@@ -138,7 +140,7 @@ void RGWLoadGenProcess::handle_request(RGWRequest* r)
     dout(20) << "process_request() returned " << ret << dendl;
 
     if (req->fail_flag) {
-      req->fail_flag->inc();
+      req->fail_flag++;
     }
   }
 
index 1bec56553a656a9fd73b3b3ef7e7c74762460d29..6ce71d78893af96398ab3280b2073fac24a82f7c 100644 (file)
@@ -60,6 +60,7 @@
 #include <map>
 #include <string>
 #include <vector>
+#include <atomic>
 
 #include "include/types.h"
 #include "common/BackTrace.h"
@@ -77,11 +78,11 @@ static sig_t sighandler_alrm;
 class RGWProcess;
 
 static int signal_fd[2] = {0, 0};
-static atomic_t disable_signal_fd;
+static std::atomic<int64_t> disable_signal_fd = { 0 };
 
 void signal_shutdown()
 {
-  if (!disable_signal_fd.read()) {
+  if (!disable_signal_fd) {
     int val = 0;
     int ret = write(signal_fd[0], (char *)&val, sizeof(val));
     if (ret < 0) {
index 3bc033f0a6889ff5afcc0b863f1e4626d901fed2..fb0444186c9795c37479580ccaf93b796cc893b2 100644 (file)
@@ -230,7 +230,7 @@ bool RGWObjectExpirer::inspect_all_shards(const utime_t& last_run,
 
 bool RGWObjectExpirer::going_down()
 {
-  return (down_flag.read() != 0);
+  return down_flag;
 }
 
 void RGWObjectExpirer::start_processor()
@@ -241,7 +241,7 @@ void RGWObjectExpirer::start_processor()
 
 void RGWObjectExpirer::stop_processor()
 {
-  down_flag.set(1);
+  down_flag = true;
   if (worker) {
     worker->stop();
     worker->join();
index 83f0dd30754335ae7e725f7a26d3a0a8d4728bb4..6fe8d1410bff0f172038ffb60e2a5fdd9862e56f 100644 (file)
@@ -8,6 +8,7 @@
 #include <iostream>
 #include <sstream>
 #include <string>
+#include <atomic>
 
 #include "auth/Crypto.h"
 
@@ -37,6 +38,8 @@
 #include "rgw_usage.h"
 #include "rgw_replica_log.h"
 
+#include <atomic>
+
 class RGWObjectExpirer {
 protected:
   RGWRados *store;
@@ -65,7 +68,7 @@ protected:
   };
 
   OEWorker *worker;
-  atomic_t down_flag;
+  std::atomic<bool> down_flag = { false };
 
 public:
   explicit RGWObjectExpirer(RGWRados *_store)
index 83c59a4cc379887fc82af1af3eec492b5e57eb17..005f2db6fef742a2562d45e4a881bfbd51805367 100644 (file)
@@ -17,6 +17,8 @@
 #include "common/WorkQueue.h"
 #include "common/Throttle.h"
 
+#include <atomic>
+
 #if !defined(dout_subsys)
 #define dout_subsys ceph_subsys_rgw
 #define def_dout_subsys
@@ -182,7 +184,7 @@ public:
   void checkpoint();
   void handle_request(RGWRequest* req) override;
   void gen_request(const string& method, const string& resource,
-                 int content_length, atomic_t* fail_flag);
+                 int content_length, std::atomic<int64_t>* fail_flag);
 
   void set_access_key(RGWAccessKey& key) { access_key = key; }
 };
index 02347ff743dc2b8c6e13aa04d56d73237e29daba..6a61400a1101a8798b42845b20c5e56a70346ba8 100644 (file)
@@ -26,6 +26,8 @@
 #include "rgw_bucket.h"
 #include "rgw_user.h"
 
+#include <atomic>
+
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_rgw
 
@@ -410,7 +412,7 @@ void UserAsyncRefreshHandler::handle_response(int r)
 }
 
 class RGWUserStatsCache : public RGWQuotaCache<rgw_user> {
-  atomic_t down_flag;
+  std::atomic<bool> down_flag = { false };
   RWLock rwlock;
   map<rgw_bucket, rgw_user> modified_buckets;
 
@@ -569,11 +571,11 @@ public:
   }
 
   bool going_down() {
-    return (down_flag.read() != 0);
+    return down_flag;
   }
 
   void stop() {
-    down_flag.set(1);
+    down_flag = true;
     rwlock.get_write();
     stop_thread(&buckets_sync_thread);
     rwlock.unlock();
index d55dcaff952e898bd5d5f0a9c7733ed584188c93..9291434634cc8480f9bb86b864101225101d2ce1 100644 (file)
 #ifndef CEPH_RGW_QUOTA_H
 #define CEPH_RGW_QUOTA_H
 
-
 #include "include/utime.h"
-#include "include/atomic.h"
 #include "common/lru_map.h"
 
+#include <atomic>
+
 static inline int64_t rgw_rounded_kb(int64_t bytes)
 {
   return (bytes + 1023) / 1024;
index 329e09589acc645cc6f5c4658b83598c935bbaa3..d6e9287a9c97078717561db22f01c5b3500fe63a 100644 (file)
@@ -55,6 +55,7 @@ using namespace librados;
 #include <string>
 #include <iostream>
 #include <vector>
+#include <atomic>
 #include <list>
 #include <map>
 #include "auth/Crypto.h" // get_random_bytes()
@@ -71,6 +72,8 @@ using namespace librados;
 
 #include "compressor/Compressor.h"
 
+#include <atomic>
+
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_rgw
 
@@ -2956,7 +2959,7 @@ protected:
   CephContext *cct;
   RGWRados *store;
 
-  atomic_t down_flag;
+  std::atomic<bool> down_flag = { false };
 
   string thread_name;
 
@@ -2972,7 +2975,8 @@ public:
   virtual int init() { return 0; }
   virtual int process() = 0;
 
-  bool going_down() { return down_flag.read() != 0; }
+  bool going_down() { return down_flag; }
+
   void start();
   void stop();
 };
@@ -2985,7 +2989,7 @@ void RGWRadosThread::start()
 
 void RGWRadosThread::stop()
 {
-  down_flag.set(1);
+  down_flag = true;
   stop_process();
   if (worker) {
     worker->stop();
@@ -5211,14 +5215,14 @@ int RGWRados::Bucket::List::list_objects(int max, vector<rgw_bucket_dir_entry> *
     if (delim_pos >= 0) {
       string s = cur_marker.name.substr(0, delim_pos);
       s.append(bigger_than_delim);
-      cur_marker.set(s);
+      cur_marker = s;
     }
   }
   
   string skip_after_delim;
   while (truncated && count <= max) {
     if (skip_after_delim > cur_marker.name) {
-      cur_marker.set(skip_after_delim);
+      cur_marker = skip_after_delim;
       ldout(cct, 20) << "setting cur_marker=" << cur_marker.name << "[" << cur_marker.instance << "]" << dendl;
     }
     std::map<string, rgw_bucket_dir_entry> ent_map;
@@ -9789,8 +9793,8 @@ struct get_obj_data : public RefCountedObject {
   Mutex data_lock;
   list<get_obj_aio_data> aio_data;
   RGWGetDataCB *client_cb;
-  atomic_t cancelled;
-  atomic_t err_code;
+  std::atomic<bool> cancelled = { false };
+  std::atomic<int64_t> err_code = { 0 };
   Throttle throttle;
   list<bufferlist> read_list;
 
@@ -9802,16 +9806,16 @@ struct get_obj_data : public RefCountedObject {
       throttle(cct, "get_obj_data", cct->_conf->rgw_get_obj_window_size, false) {}
   ~get_obj_data() override { } 
   void set_cancelled(int r) {
-    cancelled.set(1);
-    err_code.set(r);
+    cancelled = true;
+    err_code = r;
   }
 
   bool is_cancelled() {
-    return cancelled.read() == 1;
+    return cancelled;
   }
 
   int get_err_code() {
-    return err_code.read();
+    return err_code;
   }
 
   int wait_next_io(bool *done) {
@@ -11655,7 +11659,7 @@ int RGWRados::pool_iterate(RGWPoolIterCtx& ctx, uint32_t num, vector<rgw_bucket_
     if (filter && !filter->filter(oid, oid))
       continue;
 
-    e.key.set(oid);
+    e.key = oid;
     objs.push_back(e);
   }
 
index c42256639d72973e1e6f45550aa6911c8f741181..84abd068816694a076290f7f11b3a4eb1e3b275f 100644 (file)
@@ -2199,7 +2199,7 @@ class RGWRados
 
   void get_bucket_instance_ids(const RGWBucketInfo& bucket_info, int shard_id, map<int, string> *result);
 
-  atomic64_t max_req_id;
+  std::atomic<int64_t> max_req_id = { 0 };
   Mutex lock;
   Mutex watchers_lock;
   SafeTimer *timer;
@@ -2298,7 +2298,7 @@ protected:
 
   RGWPeriod current_period;
 public:
-  RGWRados() : max_req_id(0), lock("rados_timer_lock"), watchers_lock("watchers_lock"), timer(NULL),
+  RGWRados() : lock("rados_timer_lock"), watchers_lock("watchers_lock"), timer(NULL),
                gc(NULL), lc(NULL), obj_expirer(NULL), use_gc_thread(false), use_lc_thread(false), quota_threads(false),
                run_sync_thread(false), async_rados(nullptr), meta_notifier(NULL),
                data_notifier(NULL), meta_sync_processor_thread(NULL),
@@ -2320,7 +2320,7 @@ public:
                meta_mgr(NULL), data_log(NULL) {}
 
   uint64_t get_new_req_id() {
-    return max_req_id.inc();
+    return ++max_req_id;
   }
 
   librados::IoCtx* get_lc_pool_ctx() {
index d9fc69bee1c38fced97ef0fe7d5f6e8254ace085..3c835f7b1c94b6c4000639e19598457e4bf1a37b 100644 (file)
 #if defined(WITH_RADOSGW_FCGI_FRONTEND)
 #include "rgw_fcgi.h"
 #endif
+
 #include "common/QueueRing.h"
 
+#include <atomic>
+
 struct RGWRequest
 {
   uint64_t id;
@@ -56,10 +59,10 @@ struct RGWLoadGenRequest : public RGWRequest {
        string method;
        string resource;
        int content_length;
-       atomic_t* fail_flag;
+       std::atomic<int64_t>* fail_flag = nullptr;
 
 RGWLoadGenRequest(uint64_t req_id, const string& _m, const  string& _r, int _cl,
-               atomic_t *ff)
+               std::atomic<int64_t> *ff)
        : RGWRequest(req_id), method(_m), resource(_r), content_length(_cl),
                fail_flag(ff) {}
 };
index 8699624002b5518e95d321ef39eb33657251fe64..3cda4d305d6f9f0ad7449a7e1685af7ffe318046 100644 (file)
@@ -26,7 +26,7 @@ int RGWRESTConn::get_url(string& endpoint)
     return -EIO;
   }
 
-  int i = counter.inc();
+  int i = ++counter;
   endpoint = endpoints[i % endpoints.size()];
 
   return 0;
@@ -40,7 +40,7 @@ string RGWRESTConn::get_url()
     return endpoint;
   }
 
-  int i = counter.inc();
+  int i = ++counter;
   endpoint = endpoints[i % endpoints.size()];
 
   return endpoint;
index 674387ffa05e12d4bd4ab0d6aa9456d0dde2f1c8..2b2cf700ac480e531bec2e57d9c9cd43982b0da9 100644 (file)
@@ -9,6 +9,7 @@
 #include "common/ceph_json.h"
 #include "common/RefCountedObj.h"
 
+#include <atomic>
 
 class CephContext;
 class RGWRados;
@@ -55,7 +56,7 @@ class RGWRESTConn
   RGWAccessKey key;
   string self_zone_group;
   string remote_id;
-  atomic_t counter;
+  std::atomic<int64_t> counter = { 0 };
 
 public:
 
index 83c63bd1f82a31e1f32f1d83dae6c33d1852cd8d..94ead4aea29069421cc8f8529e9cdcd26d1455a2 100644 (file)
@@ -52,7 +52,7 @@ RGWCoroutine *RGWSyncErrorLogger::log_error_cr(const string& source_zone, const
   ::encode(info, bl);
   store->time_log_prepare_entry(entry, real_clock::now(), section, name, bl);
 
-  uint32_t shard_id = counter.inc() % num_shards;
+  uint32_t shard_id = ++counter % num_shards;
 
 
   return new RGWRadosTimelogAddCR(store, oids[shard_id], entry);
@@ -290,7 +290,7 @@ int RGWRemoteMetaLog::init()
 
 void RGWRemoteMetaLog::finish()
 {
-  going_down.set(1);
+  going_down = true;
   stop();
 }
 
@@ -1992,7 +1992,7 @@ int RGWRemoteMetaLog::run_sync()
   // get shard count and oldest log period from master
   rgw_mdlog_info mdlog_info;
   for (;;) {
-    if (going_down.read()) {
+    if (going_down) {
       ldout(store->ctx(), 1) << __func__ << "(): going down" << dendl;
       return 0;
     }
@@ -2013,7 +2013,7 @@ int RGWRemoteMetaLog::run_sync()
 
   rgw_meta_sync_status sync_status;
   do {
-    if (going_down.read()) {
+    if (going_down) {
       ldout(store->ctx(), 1) << __func__ << "(): going down" << dendl;
       return 0;
     }
@@ -2112,7 +2112,7 @@ int RGWRemoteMetaLog::run_sync()
         ldout(store->ctx(), 0) << "ERROR: bad sync state!" << dendl;
         return -EIO;
     }
-  } while (!going_down.read());
+  } while (!going_down);
 
   return 0;
 }
index bb245aedceb817694a07898f1de09b01f2ff7fd2..40f15e10f64cbe854b4879068e929c8e32b97856 100644 (file)
@@ -8,6 +8,8 @@
 #include "include/stringify.h"
 #include "common/RWLock.h"
 
+#include <atomic>
+
 #define ERROR_LOGGER_SHARDS 32
 #define RGW_SYNC_ERROR_LOG_SHARD_PREFIX "sync.error-log"
 
@@ -65,7 +67,7 @@ class RGWSyncErrorLogger {
   vector<string> oids;
   int num_shards;
 
-  atomic_t counter;
+  std::atomic<int64_t> counter = { 0 };
 public:
   RGWSyncErrorLogger(RGWRados *_store, const string &oid_prefix, int _num_shards);
   RGWCoroutine *log_error_cr(const string& source_zone, const string& section, const string& name, uint32_t error_code, const string& message);
@@ -195,7 +197,7 @@ class RGWRemoteMetaLog : public RGWCoroutinesManager {
   void init_sync_env(RGWMetaSyncEnv *env);
   int store_sync_info(const rgw_meta_sync_info& sync_info);
 
-  atomic_t going_down;
+  std::atomic<bool> going_down = { false };
 
 public:
   RGWRemoteMetaLog(RGWRados *_store, RGWAsyncRadosProcessor *async_rados,