]> git-server-git.apps.pok.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)
committerKefu Chai <kchai@redhat.com>
Mon, 21 Sep 2020 12:17:36 +0000 (20:17 +0800)
instead of relying on utime_t, use standard library directly.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/blk/kernel/KernelDevice.cc

index 0aa4dd01d306d14d66d9dd98c20dfaf139f4acfb..a0a2e8a06f9c772f266ff4a7ef999d7d6c44dab9 100644 (file)
@@ -85,8 +85,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.
@@ -94,8 +93,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;