]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
blk/kernel: use sleep_for()
authorKefu Chai <kchai@redhat.com>
Tue, 15 Sep 2020 07:01:55 +0000 (15:01 +0800)
committerNathan Cutler <ncutler@suse.com>
Tue, 27 Oct 2020 10:26:17 +0000 (11:26 +0100)
instead of relying on utime_t, use standard library directly.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(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

index 69f7510a081dfcf2c9c0cc83e3ddfce7542cfa44..4aca6dbf3f6ff29e5d6cf10d91cb69d7b8e5ddf4 100644 (file)
@@ -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<double>("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;