From 21fe507e70dc4b7caa8ea36f53b246ae36dc71e0 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 15 Sep 2020 15:01:55 +0800 Subject: [PATCH] blk/kernel: use sleep_for() instead of relying on utime_t, use standard library directly. Signed-off-by: Kefu Chai (cherry picked from commit bcb197d5d8cab33c3598d3a3043dfae8235a13bc) Conflicts: src/blk/kernel/KernelDevice.cc - file does not exist in nautilus; changes applied without conflicts to os/bluestore/KernelDevice.cc --- src/os/bluestore/KernelDevice.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index 69f7510a081df..4aca6dbf3f6ff 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -59,8 +59,7 @@ KernelDevice::KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv, ai int KernelDevice::_lock() { dout(10) << __func__ << " " << fd_directs[WRITE_LIFE_NOT_SET] << dendl; - utime_t sleeptime; - sleeptime.set_from_double(cct->_conf->bdev_flock_retry_interval); + double retry_interval = cct->_conf.get_val("bdev_flock_retry_interval"); // When the block changes, systemd-udevd will open the block, // read some information and close it. Then a failure occurs here. @@ -68,8 +67,8 @@ int KernelDevice::_lock() for (int i = 0; i < cct->_conf->bdev_flock_retry + 1; i++) { int r = ::flock(fd_directs[WRITE_LIFE_NOT_SET], LOCK_EX | LOCK_NB); if (r < 0 && errno == EAGAIN) { - dout(1) << __func__ << " flock busy on " << path << dendl; - sleeptime.sleep(); + dout(1) << __func__ << " flock busy on " << path << dendl; + std::this_thread::sleep_for(ceph::make_timespan(retry_interval)); } else if (r < 0) { derr << __func__ << " flock failed on " << path << dendl; break; -- 2.39.5