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: v10.2.3~112^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9591e505c1d2c7b66b4c17421f94b6fc7e68913f;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 (cherry picked from commit 1adff94b720d01240040fdffebdbf53efdd528a5) --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index c7d8aa47f5c..81fa6d3df2b 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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]; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index f5f8a7f64ce..5eca9a61224 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;