]> git-server-git.apps.pok.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)
committerCasey Bodley <cbodley@redhat.com>
Tue, 24 May 2016 15:18:38 +0000 (11:18 -0400)
next_rados_handle is only accessed under an exclusive handle_lock

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 0594c7fd2a93bfe243ad5a1cb948b0b36a12bf41..7d21e2f7c97c5679c0535e84fb843f35d4f8b289 100644 (file)
@@ -12094,13 +12094,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;