]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: dont need atomic RGWRados::next_rados_handle
authorCasey Bodley <cbodley@redhat.com>
Tue, 24 May 2016 14:40:25 +0000 (10:40 -0400)
committerAbhishek Lekshmanan <abhishek@suse.com>
Thu, 14 Jul 2016 08:06:28 +0000 (10:06 +0200)
next_rados_handle is only accessed under an exclusive handle_lock

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 1adff94b720d01240040fdffebdbf53efdd528a5)

src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index c7d8aa47f5c7d70b78a3f837dad7d7ec852a79b1..81fa6d3df2b28c0aa5dfc4b648df11795291b638 100644 (file)
@@ -12073,13 +12073,11 @@ librados::Rados* RGWRados::get_rados_handle()
     } else {
       handle_lock.put_read();
       handle_lock.get_write();
-      uint32_t handle = next_rados_handle.read();
-      if (handle == rados.size()) {
-        next_rados_handle.set(0);
-        handle = 0;
-      }
+      const uint32_t handle = next_rados_handle;
       rados_map[id] = handle;
-      next_rados_handle.inc();
+      if (++next_rados_handle == rados.size()) {
+        next_rados_handle = 0;
+      }
       handle_lock.put_write();
       return &rados[handle];
     }
index f5f8a7f64ce47e8274c376dcf68670cbaf8aad33..5eca9a612240c9e64087fba441947d6fbf660a5d 100644 (file)
@@ -1801,7 +1801,7 @@ protected:
   CephContext *cct;
 
   std::vector<librados::Rados> rados;
-  atomic_t next_rados_handle;
+  uint32_t next_rados_handle;
   RWLock handle_lock;
   std::map<pthread_t, int> rados_map;