mirror of
https://github.com/ceph/ceph
synced 2024-12-28 06:23:08 +00:00
Merge pull request #36955 from agayev/zbc-to-zbd
os/bluestore: Switch from libzbc library to libzbd library Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
commit
23e3358e3d
@ -183,8 +183,6 @@ if(WITH_BLUESTORE)
|
||||
if(LINUX)
|
||||
find_package(aio)
|
||||
set(HAVE_LIBAIO ${AIO_FOUND})
|
||||
find_package(zbc)
|
||||
set(HAVE_LIBZBC ${ZBC_FOUND})
|
||||
elseif(FREEBSD)
|
||||
# POSIX AIO is integrated into FreeBSD kernel, and exposed by libc.
|
||||
set(HAVE_POSIXAIO ON)
|
||||
@ -192,6 +190,10 @@ if(WITH_BLUESTORE)
|
||||
endif()
|
||||
|
||||
include(CMakeDependentOption)
|
||||
|
||||
CMAKE_DEPENDENT_OPTION(WITH_ZBD "Enable libzbd bluestore backend" OFF
|
||||
"WITH_BLUESTORE" OFF)
|
||||
|
||||
CMAKE_DEPENDENT_OPTION(WITH_LIBURING "Enable io_uring bluestore backend" OFF
|
||||
"WITH_BLUESTORE;HAVE_LIBAIO" OFF)
|
||||
set(HAVE_LIBURING ${WITH_LIBURING})
|
||||
|
@ -1,19 +0,0 @@
|
||||
# - Find ZBC
|
||||
#
|
||||
# ZBC_INCLUDE - Where to find zbc.h
|
||||
# ZBC_LIBRARIES - List of libraries when using zbc.
|
||||
# ZBC_FOUND - True if zbc found.
|
||||
|
||||
find_path(ZBC_INCLUDE_DIR
|
||||
zbc.h
|
||||
HINTS $ENV{ZBC_ROOT}/libzbc
|
||||
PATH_SUFFIXES libzbc)
|
||||
|
||||
find_library(ZBC_LIBRARIES
|
||||
zbc
|
||||
HINTS $ENV{ZBC_ROOT}/lib)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(zbc DEFAULT_MSG ZBC_LIBRARIES ZBC_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(ZBC_INCLUDE_DIR ZBC_LIBRARIES)
|
19
cmake/modules/Findzbd.cmake
Normal file
19
cmake/modules/Findzbd.cmake
Normal file
@ -0,0 +1,19 @@
|
||||
# - Find ZBD
|
||||
#
|
||||
# ZBD_INCLUDE - Where to find zbd.h
|
||||
# ZBD_LIBRARIES - List of libraries when using zbd.
|
||||
# ZBD_FOUND - True if zbd found.
|
||||
|
||||
find_path(ZBD_INCLUDE_DIR
|
||||
zbd.h
|
||||
HINTS $ENV{ZBD_ROOT}/libzbd
|
||||
PATH_SUFFIXES libzbd)
|
||||
|
||||
find_library(ZBD_LIBRARIES
|
||||
zbd
|
||||
HINTS $ENV{ZBD_ROOT}/lib)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(zbd DEFAULT_MSG ZBD_LIBRARIES ZBD_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(ZBD_INCLUDE_DIR ZBD_LIBRARIES)
|
@ -31,7 +31,7 @@
|
||||
#include "pmem/PMEMDevice.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LIBZBC)
|
||||
#if defined(HAVE_LIBZBD)
|
||||
#include "zoned/HMSMRDevice.h"
|
||||
#endif
|
||||
|
||||
@ -99,7 +99,7 @@ BlockDevice::detect_device_type(const std::string& path)
|
||||
return block_device_t::pmem;
|
||||
}
|
||||
#endif
|
||||
#if (defined(HAVE_LIBAIO) || defined(HAVE_POSIXAIO)) && defined(HAVE_LIBZBC)
|
||||
#if (defined(HAVE_LIBAIO) || defined(HAVE_POSIXAIO)) && defined(HAVE_LIBZBD)
|
||||
if (HMSMRDevice::support(path)) {
|
||||
return block_device_t::hm_smr;
|
||||
}
|
||||
@ -126,7 +126,7 @@ BlockDevice::device_type_from_name(const std::string& blk_dev_name)
|
||||
return block_device_t::pmem;
|
||||
}
|
||||
#endif
|
||||
#if (defined(HAVE_LIBAIO) || defined(HAVE_POSIXAIO)) && defined(HAVE_LIBZBC)
|
||||
#if (defined(HAVE_LIBAIO) || defined(HAVE_POSIXAIO)) && defined(HAVE_LIBZBD)
|
||||
if (blk_dev_name == "hm_smr") {
|
||||
return block_device_t::hm_smr;
|
||||
}
|
||||
@ -152,7 +152,7 @@ BlockDevice* BlockDevice::create_with_type(block_device_t device_type,
|
||||
case block_device_t::pmem:
|
||||
return new PMEMDevice(cct, cb, cbpriv);
|
||||
#endif
|
||||
#if (defined(HAVE_LIBAIO) || defined(HAVE_POSIXAIO)) && defined(HAVE_LIBZBC)
|
||||
#if (defined(HAVE_LIBAIO) || defined(HAVE_POSIXAIO)) && defined(HAVE_LIBZBD)
|
||||
case block_device_t::hm_smr:
|
||||
return new HMSMRDevice(cct, cb, cbpriv, d_cb, d_cbpriv);
|
||||
#endif
|
||||
|
@ -140,7 +140,7 @@ private:
|
||||
unknown,
|
||||
#if defined(HAVE_LIBAIO) || defined(HAVE_POSIXAIO)
|
||||
aio,
|
||||
#if defined(HAVE_LIBZBC)
|
||||
#if defined(HAVE_LIBZBD)
|
||||
hm_smr,
|
||||
#endif
|
||||
#endif
|
||||
|
@ -20,7 +20,9 @@ if(WITH_SPDK)
|
||||
spdk/NVMEDevice.cc)
|
||||
endif()
|
||||
|
||||
if(HAVE_LIBZBC)
|
||||
if(WITH_LIBZBD)
|
||||
find_package(zbd REQUIRED)
|
||||
set(HAVE_LIBZBD ${ZBD_FOUND})
|
||||
list(APPEND libblk_srcs
|
||||
zoned/HMSMRDevice.cc)
|
||||
endif()
|
||||
@ -36,8 +38,8 @@ if(WITH_SPDK)
|
||||
target_link_libraries(blk PRIVATE ${SPDK_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(HAVE_LIBZBC)
|
||||
target_link_libraries(blk PRIVATE ${ZBC_LIBRARIES})
|
||||
if(WITH_LIBZBD)
|
||||
target_link_libraries(blk PRIVATE ${ZBD_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WITH_BLUESTORE_PMEM OR WITH_RBD_RWL)
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "kernel/io_uring.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libzbc/zbc.h>
|
||||
#include <libzbd/zbd.h>
|
||||
}
|
||||
|
||||
#define dout_context cct
|
||||
@ -78,7 +78,7 @@ HMSMRDevice::HMSMRDevice(CephContext* cct, aio_callback_t cb, void *cbpriv, aio_
|
||||
|
||||
bool HMSMRDevice::support(const std::string& path)
|
||||
{
|
||||
return zbc_device_is_zoned(path.c_str(), false, nullptr) == 1;
|
||||
return zbd_device_is_zoned(path.c_str()) == 1;
|
||||
}
|
||||
|
||||
int HMSMRDevice::_lock()
|
||||
@ -95,23 +95,23 @@ int HMSMRDevice::_lock()
|
||||
bool HMSMRDevice::set_smr_params(const std::string& path) {
|
||||
dout(10) << __func__ << " opening " << path << dendl;
|
||||
|
||||
zbc_device *dev;
|
||||
if (zbc_open(path.c_str(), O_RDWR | O_DIRECT, &dev) != 0) {
|
||||
int dev = zbd_open(path.c_str(), O_RDWR | O_DIRECT | O_LARGEFILE, nullptr);
|
||||
if (dev < 0) {
|
||||
return false;
|
||||
}
|
||||
auto close_dev = make_scope_guard([dev] { zbc_close(dev); });
|
||||
auto close_dev = make_scope_guard([dev] { zbd_close(dev); });
|
||||
|
||||
unsigned int nr_zones = 0;
|
||||
if (zbc_report_nr_zones(dev, 0, ZBC_RO_NOT_WP, &nr_zones) != 0) {
|
||||
if (zbd_report_nr_zones(dev, 0, 0, ZBD_RO_NOT_WP, &nr_zones) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<zbc_zone> zones(nr_zones);
|
||||
if (zbc_report_zones(dev, 0, ZBC_RO_NOT_WP, zones.data(), &nr_zones) != 0) {
|
||||
std::vector<zbd_zone> zones(nr_zones);
|
||||
if (zbd_report_zones(dev, 0, 0, ZBD_RO_NOT_WP, zones.data(), &nr_zones) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
zone_size = 512 * zbc_zone_length(&zones[0]); // on HM-SMR zones are equisized
|
||||
zone_size = zbd_zone_len(&zones[0]);
|
||||
conventional_region_size = nr_zones * zone_size;
|
||||
|
||||
dout(10) << __func__ << " setting zone size to " << zone_size
|
||||
|
@ -75,8 +75,8 @@
|
||||
/* Defined if you have libaio */
|
||||
#cmakedefine HAVE_LIBAIO
|
||||
|
||||
/* Defined if you have libzbc */
|
||||
#cmakedefine HAVE_LIBZBC
|
||||
/* Defined if you have libzbd */
|
||||
#cmakedefine HAVE_LIBZBD
|
||||
|
||||
/* Defined if you have liburing */
|
||||
#cmakedefine HAVE_LIBURING
|
||||
|
@ -37,7 +37,7 @@ if(WITH_BLUESTORE)
|
||||
)
|
||||
endif(WITH_BLUESTORE)
|
||||
|
||||
if(HAVE_LIBZBC)
|
||||
if(WITH_LIBZBD)
|
||||
list(APPEND libos_srcs
|
||||
bluestore/zoned_types.cc
|
||||
bluestore/ZonedFreelistManager.cc
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "BitmapAllocator.h"
|
||||
#include "AvlAllocator.h"
|
||||
#include "HybridAllocator.h"
|
||||
#ifdef HAVE_LIBZBC
|
||||
#ifdef HAVE_LIBZBD
|
||||
#include "ZonedAllocator.h"
|
||||
#endif
|
||||
#include "common/debug.h"
|
||||
@ -128,7 +128,7 @@ Allocator *Allocator::create(CephContext* cct, string type,
|
||||
return new HybridAllocator(cct, size, block_size,
|
||||
cct->_conf.get_val<uint64_t>("bluestore_hybrid_alloc_mem_cap"),
|
||||
name);
|
||||
#ifdef HAVE_LIBZBC
|
||||
#ifdef HAVE_LIBZBD
|
||||
} else if (type == "zoned") {
|
||||
return new ZonedAllocator(cct, size, block_size, name);
|
||||
#endif
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "FreelistManager.h"
|
||||
#include "BitmapFreelistManager.h"
|
||||
#ifdef HAVE_LIBZBC
|
||||
#ifdef HAVE_LIBZBD
|
||||
#include "ZonedFreelistManager.h"
|
||||
#endif
|
||||
|
||||
@ -20,7 +20,7 @@ FreelistManager *FreelistManager::create(
|
||||
if (type == "bitmap")
|
||||
return new BitmapFreelistManager(cct, "B", "b");
|
||||
|
||||
#ifdef HAVE_LIBZBC
|
||||
#ifdef HAVE_LIBZBD
|
||||
// With zoned drives there is only one FreelistManager implementation that we
|
||||
// can use, and we also know if a drive is zoned right after opening it
|
||||
// (BlueStore::_open_bdev). Hence, we set freelist_type to "zoned" whenever
|
||||
@ -37,7 +37,7 @@ FreelistManager *FreelistManager::create(
|
||||
void FreelistManager::setup_merge_operators(KeyValueDB *db,
|
||||
const std::string& type)
|
||||
{
|
||||
#ifdef HAVE_LIBZBC
|
||||
#ifdef HAVE_LIBZBD
|
||||
if (type == "zoned")
|
||||
ZonedFreelistManager::setup_merge_operator(db, "z");
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user