]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
bluestore: Fix handling the return value of zbc_device_is_zoned() call.
authorAbutalib Aghayev <agayev@cs.cmu.edu>
Fri, 3 Jul 2020 02:16:35 +0000 (22:16 -0400)
committerAbutalib Aghayev <agayev@cs.cmu.edu>
Fri, 3 Jul 2020 02:16:35 +0000 (22:16 -0400)
zbc_device_is_zoned() returns 1 when the device is zoned and 0 when the device
is not zoned.  It may return a negative value in case of error, for example,
if the user does not have access to the device.

Signed-off-by: Abutalib Aghayev <agayev@cs.cmu.edu>
src/blk/BlockDevice.cc

index 4e1affed6b3dc44b6def55966517ffc3dd6beee3..8a6763b448d1186c10b4711acfe0798c67d006fc 100644 (file)
@@ -131,9 +131,15 @@ BlockDevice *BlockDevice::create(CephContext* cct, const string& path,
 #endif
 #if defined(HAVE_LIBAIO) || defined(HAVE_POSIXAIO)
 #if defined(HAVE_LIBZBC)
-  if (zbc_device_is_zoned(path.c_str(), false, nullptr)) {
+  r = zbc_device_is_zoned(path.c_str(), false, nullptr);
+  if (r == 1) {
     return new HMSMRDevice(cct, cb, cbpriv, d_cb, d_cbpriv);
   }
+  if (r < 0) {
+    derr << __func__ << " zbc_device_is_zoned(" << path << ") failed: "
+        << cpp_strerror(r) << dendl;
+    goto out_fail;
+  }
 #endif
   if (type == "kernel") {
     return new KernelDevice(cct, cb, cbpriv, d_cb, d_cbpriv);
@@ -148,6 +154,8 @@ BlockDevice *BlockDevice::create(CephContext* cct, const string& path,
 #endif
 
   derr << __func__ << " unknown backend " << type << dendl;
+
+out_fail:
   ceph_abort();
   return NULL;
 }