From 4bca2ccf92cd9ea432471fe7a3c2115c08afe5d1 Mon Sep 17 00:00:00 2001 From: Abutalib Aghayev Date: Thu, 2 Jul 2020 22:16:35 -0400 Subject: [PATCH] bluestore: Fix handling the return value of zbc_device_is_zoned() call. 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 --- src/blk/BlockDevice.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/blk/BlockDevice.cc b/src/blk/BlockDevice.cc index 4e1affed6b3..8a6763b448d 100644 --- a/src/blk/BlockDevice.cc +++ b/src/blk/BlockDevice.cc @@ -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; } -- 2.39.5