diff --git a/CMakeLists.txt b/CMakeLists.txt index 73547fe1ec9..9bbcb5c7767 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,12 +193,6 @@ if(WITH_ZFS) set(HAVE_LIBZFS ${ZFS_FOUND}) endif() -option(WITH_ZNS "enable zns support" OFF) -if (WITH_ZNS) - # TODO: add detection, need kernel header >= 5.5 - set(HAVE_ZNS ON) -endif() - option(WITH_BLUESTORE "Bluestore OSD backend" ON) if(WITH_BLUESTORE) if(LINUX) diff --git a/cmake/modules/FindLinuxZNS.cmake b/cmake/modules/FindLinuxZNS.cmake new file mode 100644 index 00000000000..e0c3bba0316 --- /dev/null +++ b/cmake/modules/FindLinuxZNS.cmake @@ -0,0 +1,18 @@ +# Try to find linux/blkzoned.h + +find_path(LinuxZNS_INCLUDE_DIR NAMES + "linux/blkzoned.h") + +find_package_handle_standard_args(LinuxZNS + REQUIRED_VARS + LinuxZNS_INCLUDE_DIR) + +mark_as_advanced( + LinuxZNS_INCLUDE_DIR) + +if(LinuxZNS_FOUND AND NOT (TARGET Linux::ZNS)) + add_library(Linux::ZNS INTERFACE IMPORTED) + set_target_properties(Linux::ZNS PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${LinuxZNS_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS HAVE_ZNS=1) +endif() diff --git a/src/crimson/os/seastore/CMakeLists.txt b/src/crimson/os/seastore/CMakeLists.txt index e28a1a8a7c5..55cfd425d84 100644 --- a/src/crimson/os/seastore/CMakeLists.txt +++ b/src/crimson/os/seastore/CMakeLists.txt @@ -43,7 +43,10 @@ set(crimson_seastore_srcs ${PROJECT_SOURCE_DIR}/src/os/Transaction.cc ) -if(HAVE_ZNS) +CMAKE_DEPENDENT_OPTION(WITH_ZNS "enable Linux ZNS support" OFF + "CMAKE_SYSTEM_NAME STREQUAL Linux" OFF) +if(WITH_ZNS) + find_package(LinuxZNS REQUIRED) list(APPEND crimson_seastore_srcs segment_manager/zns.cc) endif() @@ -53,5 +56,10 @@ add_library(crimson-seastore STATIC target_link_libraries(crimson-seastore crimson) +if(WITH_ZNS) + target_link_libraries(crimson-seastore + Linux::ZNS) +endif() + set_target_properties(crimson-seastore PROPERTIES JOB_POOL_COMPILE heavy_compile_job_pool) diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake index c0f240492ea..6834c8a1a71 100644 --- a/src/include/config-h.in.cmake +++ b/src/include/config-h.in.cmake @@ -108,9 +108,6 @@ /* Define to 1 if you have libxfs */ #cmakedefine HAVE_LIBXFS 1 -/* Define to 1 if zns support enabled */ -#cmakedefine HAVE_ZNS - /* SPDK conditional compilation */ #cmakedefine HAVE_SPDK