Simplified distributed block storage with strong consistency, like in Ceph
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

223 lines
7.0 KiB

  1. cmake_minimum_required(VERSION 2.8)
  2. project(vitastor)
  3. include(GNUInstallDirs)
  4. set(QEMU_PLUGINDIR qemu CACHE STRING "QEMU plugin directory suffix (qemu-kvm on RHEL)")
  5. set(WITH_ASAN false CACHE BOOL "Build with AddressSanitizer")
  6. if("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/local/?$")
  7. if(EXISTS "/etc/debian_version")
  8. set(CMAKE_INSTALL_LIBDIR "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
  9. endif()
  10. set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
  11. endif()
  12. add_definitions(-DVERSION="0.6.3")
  13. add_definitions(-Wall -Wno-sign-compare -Wno-comment -Wno-parentheses -Wno-pointer-arith -I ${CMAKE_SOURCE_DIR}/src)
  14. if (${WITH_ASAN})
  15. add_definitions(-fsanitize=address -fno-omit-frame-pointer)
  16. add_link_options(-fsanitize=address -fno-omit-frame-pointer)
  17. endif (${WITH_ASAN})
  18. set(CMAKE_BUILD_TYPE RelWithDebInfo)
  19. string(REGEX REPLACE "([\\/\\-]O)[12]?" "\\13" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
  20. string(REGEX REPLACE "([\\/\\-]O)[12]?" "\\13" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
  21. string(REGEX REPLACE "([\\/\\-]O)[12]?" "\\13" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
  22. string(REGEX REPLACE "([\\/\\-]D) *NDEBUG" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
  23. string(REGEX REPLACE "([\\/\\-]D) *NDEBUG" "" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
  24. string(REGEX REPLACE "([\\/\\-]D) *NDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
  25. string(REGEX REPLACE "([\\/\\-]O)[12]?" "\\13" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
  26. string(REGEX REPLACE "([\\/\\-]O)[12]?" "\\13" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
  27. string(REGEX REPLACE "([\\/\\-]O)[12]?" "\\13" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
  28. string(REGEX REPLACE "([\\/\\-]D) *NDEBUG" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
  29. string(REGEX REPLACE "([\\/\\-]D) *NDEBUG" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
  30. string(REGEX REPLACE "([\\/\\-]D) *NDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
  31. find_package(PkgConfig)
  32. pkg_check_modules(LIBURING REQUIRED liburing)
  33. pkg_check_modules(GLIB REQUIRED glib-2.0)
  34. pkg_check_modules(IBVERBS libibverbs)
  35. if (IBVERBS_LIBRARIES)
  36. add_definitions(-DWITH_RDMA)
  37. endif (IBVERBS_LIBRARIES)
  38. include_directories(
  39. ../
  40. /usr/include/jerasure
  41. ${LIBURING_INCLUDE_DIRS}
  42. ${IBVERBS_INCLUDE_DIRS}
  43. )
  44. # libvitastor_blk.so
  45. add_library(vitastor_blk SHARED
  46. allocator.cpp blockstore.cpp blockstore_impl.cpp blockstore_init.cpp blockstore_open.cpp blockstore_journal.cpp blockstore_read.cpp
  47. blockstore_write.cpp blockstore_sync.cpp blockstore_stable.cpp blockstore_rollback.cpp blockstore_flush.cpp crc32c.c ringloop.cpp
  48. )
  49. target_link_libraries(vitastor_blk
  50. ${LIBURING_LIBRARIES}
  51. tcmalloc_minimal
  52. # for timerfd_manager
  53. vitastor_common
  54. )
  55. set_target_properties(vitastor_blk PROPERTIES VERSION ${VERSION} SOVERSION 0)
  56. # libfio_vitastor_blk.so
  57. add_library(fio_vitastor_blk SHARED
  58. fio_engine.cpp
  59. ../json11/json11.cpp
  60. )
  61. target_link_libraries(fio_vitastor_blk
  62. vitastor_blk
  63. )
  64. # libvitastor_common.a
  65. set(MSGR_RDMA "")
  66. if (IBVERBS_LIBRARIES)
  67. set(MSGR_RDMA "msgr_rdma.cpp")
  68. endif (IBVERBS_LIBRARIES)
  69. add_library(vitastor_common STATIC
  70. epoll_manager.cpp etcd_state_client.cpp
  71. messenger.cpp msgr_stop.cpp msgr_op.cpp msgr_send.cpp msgr_receive.cpp ringloop.cpp ../json11/json11.cpp
  72. http_client.cpp osd_ops.cpp pg_states.cpp timerfd_manager.cpp base64.cpp ${MSGR_RDMA}
  73. )
  74. target_compile_options(vitastor_common PUBLIC -fPIC)
  75. # vitastor-osd
  76. add_executable(vitastor-osd
  77. osd_main.cpp osd.cpp osd_secondary.cpp osd_peering.cpp osd_flush.cpp osd_peering_pg.cpp
  78. osd_primary.cpp osd_primary_chain.cpp osd_primary_sync.cpp osd_primary_write.cpp osd_primary_subops.cpp
  79. osd_cluster.cpp osd_rmw.cpp
  80. )
  81. target_link_libraries(vitastor-osd
  82. vitastor_common
  83. vitastor_blk
  84. Jerasure
  85. ${IBVERBS_LIBRARIES}
  86. )
  87. # libfio_vitastor_sec.so
  88. add_library(fio_vitastor_sec SHARED
  89. fio_sec_osd.cpp
  90. rw_blocking.cpp
  91. )
  92. target_link_libraries(fio_vitastor_sec
  93. tcmalloc_minimal
  94. )
  95. # libvitastor_client.so
  96. add_library(vitastor_client SHARED
  97. cluster_client.cpp
  98. )
  99. target_link_libraries(vitastor_client
  100. vitastor_common
  101. tcmalloc_minimal
  102. ${LIBURING_LIBRARIES}
  103. ${IBVERBS_LIBRARIES}
  104. )
  105. set_target_properties(vitastor_client PROPERTIES VERSION ${VERSION} SOVERSION 0)
  106. # libfio_vitastor.so
  107. add_library(fio_vitastor SHARED
  108. fio_cluster.cpp
  109. )
  110. target_link_libraries(fio_vitastor
  111. vitastor_client
  112. )
  113. # vitastor-nbd
  114. add_executable(vitastor-nbd
  115. nbd_proxy.cpp
  116. )
  117. target_link_libraries(vitastor-nbd
  118. vitastor_client
  119. )
  120. # vitastor-rm
  121. add_executable(vitastor-rm
  122. rm_inode.cpp
  123. )
  124. target_link_libraries(vitastor-rm
  125. vitastor_client
  126. )
  127. # vitastor-dump-journal
  128. add_executable(vitastor-dump-journal
  129. dump_journal.cpp crc32c.c
  130. )
  131. # qemu_driver.so
  132. add_library(qemu_proxy STATIC qemu_proxy.cpp)
  133. target_compile_options(qemu_proxy PUBLIC -fPIC)
  134. target_include_directories(qemu_proxy PUBLIC
  135. ../qemu/b/qemu
  136. ../qemu/include
  137. ${GLIB_INCLUDE_DIRS}
  138. )
  139. target_link_libraries(qemu_proxy
  140. vitastor_client
  141. )
  142. add_library(qemu_vitastor SHARED
  143. qemu_driver.c
  144. )
  145. target_link_libraries(qemu_vitastor
  146. qemu_proxy
  147. )
  148. set_target_properties(qemu_vitastor PROPERTIES
  149. PREFIX ""
  150. OUTPUT_NAME "block-vitastor"
  151. )
  152. ### Test stubs
  153. # stub_osd, stub_bench, osd_test
  154. add_executable(stub_osd stub_osd.cpp rw_blocking.cpp)
  155. target_link_libraries(stub_osd tcmalloc_minimal)
  156. add_executable(stub_bench stub_bench.cpp rw_blocking.cpp)
  157. target_link_libraries(stub_bench tcmalloc_minimal)
  158. add_executable(osd_test osd_test.cpp rw_blocking.cpp)
  159. target_link_libraries(osd_test tcmalloc_minimal)
  160. # osd_rmw_test
  161. add_executable(osd_rmw_test osd_rmw_test.cpp allocator.cpp)
  162. target_link_libraries(osd_rmw_test Jerasure tcmalloc_minimal)
  163. # stub_uring_osd
  164. add_executable(stub_uring_osd
  165. stub_uring_osd.cpp
  166. )
  167. target_link_libraries(stub_uring_osd
  168. vitastor_common
  169. ${LIBURING_LIBRARIES}
  170. ${IBVERBS_LIBRARIES}
  171. tcmalloc_minimal
  172. )
  173. # osd_peering_pg_test
  174. add_executable(osd_peering_pg_test osd_peering_pg_test.cpp osd_peering_pg.cpp)
  175. target_link_libraries(osd_peering_pg_test tcmalloc_minimal)
  176. # test_allocator
  177. add_executable(test_allocator test_allocator.cpp allocator.cpp)
  178. # test_cluster_client
  179. add_executable(test_cluster_client
  180. test_cluster_client.cpp
  181. pg_states.cpp osd_ops.cpp cluster_client.cpp msgr_op.cpp mock/messenger.cpp msgr_stop.cpp
  182. etcd_state_client.cpp timerfd_manager.cpp ../json11/json11.cpp
  183. )
  184. target_compile_definitions(test_cluster_client PUBLIC -D__MOCK__)
  185. target_include_directories(test_cluster_client PUBLIC ${CMAKE_SOURCE_DIR}/src/mock)
  186. ## test_blockstore, test_shit
  187. #add_executable(test_blockstore test_blockstore.cpp)
  188. #target_link_libraries(test_blockstore blockstore)
  189. #add_executable(test_shit test_shit.cpp osd_peering_pg.cpp)
  190. #target_link_libraries(test_shit ${LIBURING_LIBRARIES} m)
  191. ### Install
  192. install(TARGETS vitastor-osd vitastor-dump-journal vitastor-nbd vitastor-rm RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
  193. install(TARGETS fio_vitastor fio_vitastor_blk fio_vitastor_sec vitastor_blk vitastor_client LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
  194. install(TARGETS qemu_vitastor LIBRARY DESTINATION /usr/${CMAKE_INSTALL_LIBDIR}/${QEMU_PLUGINDIR})