]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
common: use signedspan for monotonic ceph clocks
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Mon, 8 May 2023 12:47:42 +0000 (12:47 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Wed, 30 Aug 2023 12:59:00 +0000 (12:59 +0000)
commita17a82c6f425f51cf94f792146463bf5aafcf4c8
treea66218ce292b0f56c6bfd963f3f3d21a134758ad
parent09a8cb0a6afca48501b36c5c9c2fcaf082860a4c
common: use signedspan for monotonic ceph clocks

The monotonic clocks are commonly used for measuring time deltas,
which can be negative.

ceph::mono_clock and ceph::coarse_mono_clock currently use
unsigned duration types [1]. The difference operators are overloaded
in order to ensure that the result is signed [2][3].

However, we still have issues when unsigned timespans are compared.
For example, std::condition::wait_for can hang indefinitely due
to underflows [4][5]. It ends up using our unsigned type for a
negative timespan, which is then compared to
std::chrono::duration<Rep,Period>::zero.

In order to avoid such problems, we'll simply use a signed type
for monotonic clock durations.

With signed timespans, we can no longer assume that time_point::zero()
is equal to time_point::min(), so we're updating it accodingly.

[1] https://github.com/ceph/ceph/blob/4040f12347a5f48520f8ff2f83065b9ee3a36f68/src/common/ceph_time.h#L285
[2] https://github.com/ceph/ceph/blob/4040f12347a5f48520f8ff2f83065b9ee3a36f68/src/common/ceph_time.h#L345-L380
[3] https://github.com/ceph/ceph/blob/4040f12347a5f48520f8ff2f83065b9ee3a36f68/src/common/ceph_time.h#L466-L487
[4] https://github.com/llvm/llvm-project/blob/91cff8a71872cf49f0c5c9e5510f8065bfefa3c3/libcxx/include/__condition_variable/condition_variable.h#L178
[5] https://github.com/llvm/llvm-project/blob/91cff8a71872cf49f0c5c9e5510f8065bfefa3c3/libcxx/include/__condition_variable/condition_variable.h#L193

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
src/SimpleRADOSStriper.h
src/client/Client.cc
src/common/ceph_time.h
src/common/ceph_timer.h
src/librbd/cache/ObjectCacherObjectDispatch.cc
src/mds/MDCache.cc
src/mds/MDCache.h
src/mon/MgrMonitor.cc
src/test/osdc/object_cacher_stress.cc