From 5d74f48e9a89699367d37a3378a4773abc7ee7c8 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 11 Feb 2016 10:11:33 +0100 Subject: Cmake tuning; move cfg folder --- CMakeLists.txt | 81 ++++++++++++++++++++++----------------- conf/README.server | 30 +++++++++++++++ conf/alt-servers.sample | 4 ++ conf/server.conf.sample | 37 ++++++++++++++++++ server.config.example/README | 30 --------------- server.config.example/alt-servers | 4 -- server.config.example/server.conf | 37 ------------------ 7 files changed, 117 insertions(+), 106 deletions(-) create mode 100644 conf/README.server create mode 100644 conf/alt-servers.sample create mode 100644 conf/server.conf.sample delete mode 100644 server.config.example/README delete mode 100644 server.config.example/alt-servers delete mode 100644 server.config.example/server.conf diff --git a/CMakeLists.txt b/CMakeLists.txt index 13f5e80..940909e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,13 @@ ENDIF() message( "Build Type selected: ${CMAKE_BUILD_TYPE}" ) +SET(MAKE_KERNEL_MODULE True) +IF(CMAKE_SYSTEM_NAME MATCHES "BSD") + message("Detected *BSD System: disable build of Kernel Module.") + SET(CMAKE_INSTALL_PREFIX "/usr/local") + SET(MAKE_KERNEL_MODULE False) +ENDIF() + if(CMAKE_C_COMPILER MATCHES "clang") message( "Using clang flags." ) SET(CMAKE_C_FLAGS_DEBUG "-std=c99 -fsanitize=address -O1 -fno-omit-frame-pointer -g -Wall -Wno-unused-result -D_GNU_SOURCE -D_DEBUG -Wno-multichar -fno-strict-aliasing") @@ -83,12 +90,13 @@ ADD_CUSTOM_TARGET( # CLIENT # ################################################################################ -FILE(GLOB_RECURSE CLIENT_SRCS src/client/*.c) -ADD_EXECUTABLE(dnbd3-client ${CLIENT_SRCS}) -TARGET_LINK_LIBRARIES(dnbd3-client) -ADD_DEPENDENCIES(dnbd3-client version) -INSTALL(TARGETS dnbd3-client RUNTIME DESTINATION sbin) - +if(MAKE_KERNEL_MODULE) + FILE(GLOB_RECURSE CLIENT_SRCS src/client/*.c) + ADD_EXECUTABLE(dnbd3-client ${CLIENT_SRCS}) + TARGET_LINK_LIBRARIES(dnbd3-client) + ADD_DEPENDENCIES(dnbd3-client version) + INSTALL(TARGETS dnbd3-client RUNTIME DESTINATION sbin) +ENDIF() ################################################################################ @@ -126,48 +134,51 @@ endif() # MODULE # ################################################################################ -SET(MODULE_NAME dnbd3) -SET(MODULE_FILE ${MODULE_NAME}.ko) -FILE(GLOB MODULE_SOURCE_FILES src/kernel/*.c src/serialize.c) -FILE(GLOB MODULE_HEADER_FILES src/kernel/*.h src/*.h) +IF(MAKE_KERNEL_MODULE) + SET(MODULE_NAME dnbd3) + SET(MODULE_FILE ${MODULE_NAME}.ko) + FILE(GLOB MODULE_SOURCE_FILES src/kernel/*.c src/serialize.c) + FILE(GLOB MODULE_HEADER_FILES src/kernel/*.h src/*.h) -SET(KERNEL_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build") + SET(KERNEL_DIR "/lib/modules/${CMAKE_SYSTEM_VERSION}/build") -SET(KBUILD_COMMAND ${CMAKE_MAKE_PROGRAM} -C ${KERNEL_DIR} - M=${CMAKE_BINARY_DIR} modules -) + SET(KBUILD_COMMAND ${CMAKE_MAKE_PROGRAM} -C ${KERNEL_DIR} + M=${CMAKE_BINARY_DIR} modules + ) -CONFIGURE_FILE(Kbuild.in ${CMAKE_BINARY_DIR}/Kbuild) + CONFIGURE_FILE(Kbuild.in ${CMAKE_BINARY_DIR}/Kbuild) -FOREACH(MODULE_SOURCE_FILE ${MODULE_SOURCE_FILES}) - CONFIGURE_FILE(${MODULE_SOURCE_FILE} ${CMAKE_BINARY_DIR} COPYONLY) -ENDFOREACH( MODULE_SOURCE_FILE ) + FOREACH(MODULE_SOURCE_FILE ${MODULE_SOURCE_FILES}) + CONFIGURE_FILE(${MODULE_SOURCE_FILE} ${CMAKE_BINARY_DIR} COPYONLY) + ENDFOREACH( MODULE_SOURCE_FILE ) -FOREACH(MODULE_HEADER_FILE ${MODULE_HEADER_FILES}) - CONFIGURE_FILE(${MODULE_HEADER_FILE} ${CMAKE_BINARY_DIR} COPYONLY) -ENDFOREACH( MODULE_HEADER_FILE ) + FOREACH(MODULE_HEADER_FILE ${MODULE_HEADER_FILES}) + CONFIGURE_FILE(${MODULE_HEADER_FILE} ${CMAKE_BINARY_DIR} COPYONLY) + ENDFOREACH( MODULE_HEADER_FILE ) -ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_BINARY_DIR}/${MODULE_FILE} - COMMAND ${KBUILD_COMMAND} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - DEPENDS ${MODULE_SOURCE_FILES} Kbuild.in - VERBATIM -) + ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_BINARY_DIR}/${MODULE_FILE} + COMMAND ${KBUILD_COMMAND} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + DEPENDS ${MODULE_SOURCE_FILES} Kbuild.in + VERBATIM + ) -ADD_CUSTOM_TARGET(${MODULE_NAME} ALL DEPENDS ${CMAKE_BINARY_DIR}/${MODULE_FILE}) + ADD_CUSTOM_TARGET(${MODULE_NAME} ALL DEPENDS ${CMAKE_BINARY_DIR}/${MODULE_FILE}) -INSTALL(FILES ${CMAKE_BINARY_DIR}/${MODULE_NAME}.ko - DESTINATION /lib/modules/${CMAKE_SYSTEM_VERSION}/kernel/drivers/block - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ -) + INSTALL(FILES ${CMAKE_BINARY_DIR}/${MODULE_NAME}.ko + DESTINATION /lib/modules/${CMAKE_SYSTEM_VERSION}/kernel/drivers/block + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + ) -INSTALL(CODE "EXECUTE_PROCESS(COMMAND depmod -a)") + INSTALL(CODE "EXECUTE_PROCESS(COMMAND depmod -a)") +ENDIF() # # Other install files # -INSTALL(FILES server.conf.example client.conf.example DESTINATION /etc/dnbd3/) +FILE(GLOB conf_files "${CMAKE_CURRENT_SOURCE_DIR}/conf/*.sample" "${CMAKE_CURRENT_SOURCE_DIR}/conf/README.*") +INSTALL(FILES ${conf_files} DESTINATION etc/dnbd3/) diff --git a/conf/README.server b/conf/README.server new file mode 100644 index 0000000..285758b --- /dev/null +++ b/conf/README.server @@ -0,0 +1,30 @@ +Configuration for dnbd3-server + +The server requires a config directory. +Start it like so: ./dnbd3-server -c ./my-config/ + +There are two files in that dir + +== alt-servers == +List of known alt-servers for this server. +Format: +[PREFIX] [Comment] + +Prefix can be: ++ - Only report server to clients as alt-server, but don't use for replication +- - Only use server for replication, but don't advertise to clients +No prefix means server will be advertised to clients and is used for replication + +If you're not running in proxy mode, this file won't do much for you + +== server.conf == + +Main configuration file. Ini format. + +[dnbd3] +basePath=/srv/openslx/dnbd3 # virtual root of image files +serverPenalty=1234 # artificial acceptance delay for incoming server connections (µs) +clientPenalty=2345 # artificial acceptance delay for incoming client connection (µs) +isProxy=true # enable proxy mode - will try to replicate from alt-servers if a client requests unknown image +uplinkTimeout=1250 # r/w timeout for connections to uplink servers + diff --git a/conf/alt-servers.sample b/conf/alt-servers.sample new file mode 100644 index 0000000..fd2f2ec --- /dev/null +++ b/conf/alt-servers.sample @@ -0,0 +1,4 @@ +192.168.100.10 Some alt server ++192.168.100.100 My first alt server that will not be used for replication +-192.168.100.50 Super sectret alt server that will be used for replication, but clients don't know about it + diff --git a/conf/server.conf.sample b/conf/server.conf.sample new file mode 100644 index 0000000..7ef10a3 --- /dev/null +++ b/conf/server.conf.sample @@ -0,0 +1,37 @@ +[dnbd3] +; port to listen on (default: 5003) +listenPort=5003 +; relative root directory for images, ending in .r[1-9][0-9]* +basePath=/mnt/storage/dnbd3 +; artificial connection delay for connecting servers +serverPenalty=100000 +; artificial connection delay for connecting clients +clientPenalty=0 +; is this server a proxy? if true, requests for non-existing images will be relayed to known alt-servers +isProxy=true +; if proxy is true and an image is incomplete, should idle bandwidth be used to replicate missing blocks? +backgroundReplication=true +; if true (which is the default), images will automatically be removed from the list if they can't be accessed +removeMissingImages=true +; timeout in ms for send/recv on connections to uplink servers (used for replication) +uplinkTimeout=1250 +; timeout in ms for send/recv on connections to clients (using an image on this server) +clientTimeout=15000 + +; Log related config +[logging] +; log file path and name +; protip: use SIGUSR2 to reopen log file +file=./dnbd3.log +; which type of messages to log to file +fileMask=ERROR WARNING MINOR INFO DEBUG1 +; which to log to console (stdout) +consoleMask=ERROR WARNING MINOR INFO +; Valid types (warning: specifying invalid types will not yield an error!) +; ERROR Fatal error, server will terminate +; WARNING Major issue, something is broken but keep running +; MINOR Minor issue, more of a hickup than serious problem +; INFO Informational message +; DEBUG1 Debug information, used for medium verbosity +; DEBUG2 Used for debug messages that would show up a lot + diff --git a/server.config.example/README b/server.config.example/README deleted file mode 100644 index 285758b..0000000 --- a/server.config.example/README +++ /dev/null @@ -1,30 +0,0 @@ -Configuration for dnbd3-server - -The server requires a config directory. -Start it like so: ./dnbd3-server -c ./my-config/ - -There are two files in that dir - -== alt-servers == -List of known alt-servers for this server. -Format: -[PREFIX] [Comment] - -Prefix can be: -+ - Only report server to clients as alt-server, but don't use for replication -- - Only use server for replication, but don't advertise to clients -No prefix means server will be advertised to clients and is used for replication - -If you're not running in proxy mode, this file won't do much for you - -== server.conf == - -Main configuration file. Ini format. - -[dnbd3] -basePath=/srv/openslx/dnbd3 # virtual root of image files -serverPenalty=1234 # artificial acceptance delay for incoming server connections (µs) -clientPenalty=2345 # artificial acceptance delay for incoming client connection (µs) -isProxy=true # enable proxy mode - will try to replicate from alt-servers if a client requests unknown image -uplinkTimeout=1250 # r/w timeout for connections to uplink servers - diff --git a/server.config.example/alt-servers b/server.config.example/alt-servers deleted file mode 100644 index fd2f2ec..0000000 --- a/server.config.example/alt-servers +++ /dev/null @@ -1,4 +0,0 @@ -192.168.100.10 Some alt server -+192.168.100.100 My first alt server that will not be used for replication --192.168.100.50 Super sectret alt server that will be used for replication, but clients don't know about it - diff --git a/server.config.example/server.conf b/server.config.example/server.conf deleted file mode 100644 index 7ef10a3..0000000 --- a/server.config.example/server.conf +++ /dev/null @@ -1,37 +0,0 @@ -[dnbd3] -; port to listen on (default: 5003) -listenPort=5003 -; relative root directory for images, ending in .r[1-9][0-9]* -basePath=/mnt/storage/dnbd3 -; artificial connection delay for connecting servers -serverPenalty=100000 -; artificial connection delay for connecting clients -clientPenalty=0 -; is this server a proxy? if true, requests for non-existing images will be relayed to known alt-servers -isProxy=true -; if proxy is true and an image is incomplete, should idle bandwidth be used to replicate missing blocks? -backgroundReplication=true -; if true (which is the default), images will automatically be removed from the list if they can't be accessed -removeMissingImages=true -; timeout in ms for send/recv on connections to uplink servers (used for replication) -uplinkTimeout=1250 -; timeout in ms for send/recv on connections to clients (using an image on this server) -clientTimeout=15000 - -; Log related config -[logging] -; log file path and name -; protip: use SIGUSR2 to reopen log file -file=./dnbd3.log -; which type of messages to log to file -fileMask=ERROR WARNING MINOR INFO DEBUG1 -; which to log to console (stdout) -consoleMask=ERROR WARNING MINOR INFO -; Valid types (warning: specifying invalid types will not yield an error!) -; ERROR Fatal error, server will terminate -; WARNING Major issue, something is broken but keep running -; MINOR Minor issue, more of a hickup than serious problem -; INFO Informational message -; DEBUG1 Debug information, used for medium verbosity -; DEBUG2 Used for debug messages that would show up a lot - -- cgit v1.2.3-55-g7522