]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: detect linux/blk/zoned support 44410/head
authorKefu Chai <tchaikov@gmail.com>
Sat, 25 Dec 2021 07:47:22 +0000 (15:47 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sat, 25 Dec 2021 08:13:47 +0000 (16:13 +0800)
* add find_package() support for detecting the existence of
  linux/blkzoned.h before using it.
* link against Linux::ZNS for adding the compilation definition of
  HAVE_ZNS instead of including it in the global config.h
* move the CMake option closer to where it is used for
  better readability. as this option takes effect only if
  crimson is compiled.
* make WITH_ZNS an option which depends on the value of
  CMAKE_SYSTEM_NAME. it is hidden and off if CMAKE_SYSTEM_NAME
  is not "Linux".

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
CMakeLists.txt
cmake/modules/FindLinuxZNS.cmake [new file with mode: 0644]
src/crimson/os/seastore/CMakeLists.txt
src/include/config-h.in.cmake

index 73547fe1ec916ffd4b593ae15f2b9a51970a3bbe..9bbcb5c7767521d8cdc56bc0c0c4d65c450b3a91 100644 (file)
@@ -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 (file)
index 0000000..e0c3bba
--- /dev/null
@@ -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()
index e28a1a8a7c573c9a1f00a1c4cba73bd9592d06c9..55cfd425d84967c1f8405cca4644edc918090ca7 100644 (file)
@@ -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)
index c0f240492ea8c3b2253b79ea9e84d6eef51c8169..6834c8a1a71dd891b26b42e5d87d205ef3e5703b 100644 (file)
 /* 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