timespan(-z.count());
}
inline timespan to_timespan(signedspan z) {
- ceph_assert(z >= signedspan::zero());
+ if (z < signedspan::zero()) {
+ //ceph_assert(z >= signedspan::zero());
+ // There is a kernel bug that seems to be triggering this assert. We've
+ // seen it in:
+ // centos 8.1: 4.18.0-147.el8.x86_64
+ // debian 10.3: 4.19.0-8-amd64
+ // debian 10.1: 4.19.67-2+deb10u1
+ // ubuntu 18.04
+ // see bugs:
+ // https://tracker.ceph.com/issues/43365
+ // https://tracker.ceph.com/issues/44078
+ z = signedspan::zero();
+ }
return std::chrono::duration_cast<timespan>(z);
}
template <typename Clock>
constexpr bool converts_to_timespec_v = converts_to_timespec<Clock>::value;
+template<typename Rep, typename T>
+static Rep to_seconds(T t) {
+ return std::chrono::duration_cast<
+ std::chrono::duration<Rep>>(t).count();
+}
+
+template<typename Rep, typename T>
+static Rep to_microseconds(T t) {
+ return std::chrono::duration_cast<
+ std::chrono::duration<
+ Rep,
+ std::micro>>(t).count();
+}
+
} // namespace ceph
#endif // COMMON_CEPH_TIME_H