summaryrefslogtreecommitdiffstats
path: root/inc/dnbd3/config
diff options
context:
space:
mode:
Diffstat (limited to 'inc/dnbd3/config')
-rw-r--r--inc/dnbd3/config/client.h52
-rw-r--r--inc/dnbd3/config/cow.h21
-rw-r--r--inc/dnbd3/config/server.h62
3 files changed, 135 insertions, 0 deletions
diff --git a/inc/dnbd3/config/client.h b/inc/dnbd3/config/client.h
new file mode 100644
index 0000000..55cf8b3
--- /dev/null
+++ b/inc/dnbd3/config/client.h
@@ -0,0 +1,52 @@
+#ifndef _CLIENTCONFIG_H_
+#define _CLIENTCONFIG_H_
+
+// Which is the minimum protocol version the client expects from the server
+#define MIN_SUPPORTED_SERVER 2
+
+// Send keepalive every X seconds
+#define KEEPALIVE_INTERVAL 10
+
+// in seconds if not stated otherwise
+#define SOCKET_TIMEOUT_SEND 2
+
+// Socker receive timeout. Must be higher than keepalive interval, otherwise
+// the connection might be aborted when idle
+#define SOCKET_TIMEOUT_RECV 13
+
+// During discovery, we use very short minimum timeouts (unless in panic mode)
+#define SOCKET_TIMEOUT_DISCOVERY 1
+
+// IO timeout for block layer
+#define BLOCK_LAYER_TIMEOUT 10
+
+#define RTT_THRESHOLD_FACTOR(us) (((us) * 3) / 4) // 3/4 = current to best must be 25% worse
+#define RTT_ABSOLUTE_THRESHOLD (80000) // Or 80ms worse
+#define RTT_UNREACHABLE 0x7FFFFFFul // Use this value for timeout/unreachable as RTT. Don't set too high or you might get overflows. 0x7FFFFFF = 134 seconds
+// This must be a power of two:
+#define RTT_BLOCK_SIZE 4096
+
+// Interval of several repeating tasks (in seconds)
+#define TIMER_INTERVAL_PROBE_STARTUP 2
+#define TIMER_INTERVAL_PROBE_SWITCH 10
+#define TIMER_INTERVAL_PROBE_PANIC 2
+#define TIMER_INTERVAL_PROBE_MAX 45
+// How many discover runs after setting up a device should be considered the startup phase
+// during that phase, check all servers, before we start doing it selectively
+// and also don't increase the discover interval during this period
+#define DISCOVER_STARTUP_PHASE_COUNT 6
+// How many servers should be tested at maximum after above
+#define DISCOVER_REDUCED_SERVER_COUNT 3
+// Number of RTT probes to keep in history and average the value over
+#define DISCOVER_HISTORY_SIZE 4
+
+// Number of unsuccessful alt_server probes before read errors are reported to the block layer
+// (ALL servers will be probed this many times)
+// Set to 0 to disable
+#define PROBE_COUNT_TIMEOUT 0
+
+// ++ Kernel module ++
+#define DEFAULT_READ_AHEAD_KB 512
+#define NUMBER_DEVICES 8
+
+#endif
diff --git a/inc/dnbd3/config/cow.h b/inc/dnbd3/config/cow.h
new file mode 100644
index 0000000..b266fc8
--- /dev/null
+++ b/inc/dnbd3/config/cow.h
@@ -0,0 +1,21 @@
+#ifndef _COW_CONFIG_H_
+#define _COW_CONFIG_H_
+
+// +++++ COW +++++
+#define COW_BITFIELD_SIZE 40 // NEVER CHANGE THIS OR THE WORLD WILL ALSO END!
+#define COW_FILE_META_MAGIC_VALUE ((uint64_t)0xEBE44D6E72F7825E) // Magic Value to recognize a Cow meta file
+#define COW_FILE_DATA_MAGIC_VALUE ((uint64_t)0xEBE44D6E72F7825F) // Magic Value to recognize a Cow data file
+#define COW_MIN_UPLOAD_DELAY 60 // in seconds
+#define COW_STATS_UPDATE_TIME 5 // time in seconds the cow status files gets updated (while uploading blocks)
+#define COW_MAX_PARALLEL_UPLOADS 10 // maximum number of parallel uploads
+#define COW_MAX_PARALLEL_BACKGROUND_UPLOADS 2 // maximum number of parallel uploads while the image is still mounted
+#define COW_URL_STRING_SIZE 500 // Max string size for an url
+#define COW_SHOW_UL_SPEED 1 // enable display of ul speed in cow status file
+#define COW_MAX_IMAGE_SIZE (1000LL * 1000LL * 1000LL * 1000LL) // Maximum size an image can have(tb*gb*mb*kb)
+// +++++ COW API Endpoints +++++
+#define COW_API_PREFIX "%s/v1/"
+#define COW_API_CREATE COW_API_PREFIX "file/create"
+#define COW_API_UPDATE COW_API_PREFIX "file/update?uuid=%s&clusterindex=%lu"
+#define COW_API_START_MERGE COW_API_PREFIX "file/merge"
+
+#endif
diff --git a/inc/dnbd3/config/server.h b/inc/dnbd3/config/server.h
new file mode 100644
index 0000000..b6eee2c
--- /dev/null
+++ b/inc/dnbd3/config/server.h
@@ -0,0 +1,62 @@
+#ifndef _SERVERCONFIG_H_
+#define _SERVERCONFIG_H_
+
+#include <dnbd3/config.h>
+
+// +++++ Performance/memory related
+#define SERVER_MAX_CLIENTS 4000
+#define SERVER_MAX_IMAGES 5000
+#define SERVER_MAX_ALTS 50
+// +++++ Uplink handling (proxy mode)
+#define SERVER_GLOBAL_DUP_TIME 6 // How many seconds to wait before changing global fail counter again
+#define SERVER_BAD_UPLINK_MIN 10 // Thresold for fails at which we start ignoring the server occasionally
+#define SERVER_BAD_UPLINK_MAX 20 // Hard block server if it failed this many times
+#define SERVER_BAD_UPLINK_LOCAL_BLOCK 10 // If a server didn't supply the requested image this many times, block it for some time
+#define SERVER_BAD_UPLINK_IGNORE 180 // How many seconds is a server ignored
+#define UPLINK_MAX_QUEUE 500 // Maximum number of queued requests per uplink
+#define UPLINK_MAX_CLIENTS_PER_REQUEST 32 // Maximum number of clients that can attach to one uplink request
+#define SERVER_UPLINK_QUEUELEN_THRES 900 // Threshold where we start dropping incoming clients
+#define SERVER_MAX_PENDING_ALT_CHECKS 500 // Length of queue for pending alt checks requested by uplinks
+
+// Wait a maximum of 5 minutes before saving cache map (if data was received at all)
+#define CACHE_MAP_MAX_SAVE_DELAY 300
+// If more than 500MB have been received from uplink without saving cache map, do so
+#define CACHE_MAP_MAX_UNSAVED_BYTES ((uint64_t)500 * 1000 * 1000)
+
+// Time in ms to wait for a read/write call to complete on an uplink connection
+#define SOCKET_TIMEOUT_UPLINK 5000
+// Same for client connections. Be a bit more liberal here
+#define SOCKET_TIMEOUT_CLIENT 15000
+// When waiting for the next request header from client, allow the timeout from above
+// to expire this many times. This allows for greater idle times without also increasing
+// the timeout for cases where we wait for additional data or are actively sending a reply
+#define SOCKET_TIMEOUT_CLIENT_RETRIES 3
+
+#define SERVER_UPLINK_KEEPALIVE_INTERVAL 10 // (Seconds) Send keep-alive if nothing else is happening on the uplink
+#define SERVER_UPLINK_IDLE_TIMEOUT 1800 // (Seconds) Timeout after which we tear down an uplink connection if no blocks needed to be fetched
+
+// +++++ Other magic constants
+#define SERVER_RTT_PROBES 5 // How many probes to average over
+#define SERVER_RTT_INTERVAL_INIT 5 // Initial interval between probes
+#define SERVER_RTT_INTERVAL_MAX 45 // Maximum interval between probes
+#define SERVER_RTT_MAX_UNREACH 10 // If no server was reachable this many times, stop RTT measurements for a while
+#define SERVER_RTT_INTERVAL_FAILED 180 // Interval to use if no uplink server is reachable for above many times
+
+#define SERVER_REMOTE_IMAGE_CHECK_CACHETIME 120 // 2 minutes
+
+// Which is the minimum protocol version the server expects from the client
+#define MIN_SUPPORTED_CLIENT 2
+// Same for when we're a proxy talking to another server
+#define MIN_SUPPORTED_SERVER 2
+
+// Length of comment fields (for alt server etc.)
+#define COMMENT_LENGTH 120
+
+#define RTT_THRESHOLD_FACTOR(us) (((us) * 2) / 3) // 2/3 = current to best must be 33% worse
+#define RTT_UNREACHABLE 0x7FFFFFFu // Use this value for timeout/unreachable as RTT. Don't set too high or you might get overflows. 0x7FFFFFF = 134 seconds
+
+// How many seconds have to pass after the last client disconnected until the imagefd is closed
+#define UNUSED_FD_TIMEOUT 3600
+
+#endif
+