From: Casey Bodley Date: Tue, 24 May 2016 14:40:25 +0000 (-0400) Subject: rgw: dont need atomic RGWRados::next_rados_handle X-Git-Tag: v11.0.0~340^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1adff94b720d01240040fdffebdbf53efdd528a5;p=ceph.git rgw: dont need atomic RGWRados::next_rados_handle next_rados_handle is only accessed under an exclusive handle_lock Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 0594c7fd2a93..7d21e2f7c97c 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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]; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index f5f8a7f64ce4..5eca9a612240 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1801,7 +1801,7 @@ protected: CephContext *cct; std::vector rados; - atomic_t next_rados_handle; + uint32_t next_rados_handle; RWLock handle_lock; std::map rados_map;