summaryrefslogtreecommitdiffstats
path: root/src/kernel/dnbd3.h
diff options
context:
space:
mode:
authorFrederic Robra2019-07-23 17:13:48 +0200
committerFrederic Robra2019-07-23 17:13:48 +0200
commit457721b76423156fcb79e613003ac99e749636ca (patch)
treee60790017e23ed104023e12643cc4a3e0c4c7a6b /src/kernel/dnbd3.h
parentremoved blocking code (diff)
downloaddnbd3-ng-457721b76423156fcb79e613003ac99e749636ca.tar.gz
dnbd3-ng-457721b76423156fcb79e613003ac99e749636ca.tar.xz
dnbd3-ng-457721b76423156fcb79e613003ac99e749636ca.zip
added some documentation
Diffstat (limited to 'src/kernel/dnbd3.h')
-rw-r--r--src/kernel/dnbd3.h86
1 files changed, 61 insertions, 25 deletions
diff --git a/src/kernel/dnbd3.h b/src/kernel/dnbd3.h
index ccd3bf1..3ae42fd 100644
--- a/src/kernel/dnbd3.h
+++ b/src/kernel/dnbd3.h
@@ -33,15 +33,22 @@
/**
* the number of parallel connections
*/
-#define NUMBER_CONNECTIONS 4 // power of 2
+#define NUMBER_CONNECTIONS 4
/**
- * limit to which the other connected servers are only allowed to be that worser then the best rtt
+ * limit to which the other connected servers are only allowed to be that worser
+ * then the best rtt
*/
#define RTT_THRESOULD_LIMIT(best_rtt) ((best_rtt) * 10)
-#define DEBUG
-#define DEBUG_FILE
+/**
+ * turn on/off debug information (1/0)
+ */
+#define DEBUG 1
+/**
+ * turn on/off file and line information (1/0)
+ */
+#define DEBUG_FILE 1
extern struct workqueue_struct *dnbd3_wq;
@@ -86,7 +93,8 @@ struct dnbd3_server {
* @tx_lock: mutex to lock when sending
* @sock: the socket, 'NULL' if not connected
* @panic: 'true' if it is not possible to send or receive
- * @cookie: is incremented for every send, used to find the mq request in the receiver
+ * @cookie: is incremented for every send, used to find the mq request in the
+ * receiver
* @keepalive_worker: worker to send a keepalive package
* @receive_worker: worker to handle the incoming packages
* @pending: the pending request which is going to be send
@@ -118,16 +126,21 @@ struct dnbd3_sock {
* @device_lock: mutex to lock when device changes
* @socks: array of dnbd3_sock to connect to
* @imgname: the connected image name
- * @initial_server: the server which was configured with ioctl, will not be overriden
+ * @initial_server: the server which was configured with ioctl, will not be
+ * overriden
* @alt_servers: array of alternative servers
- * @new_servers_num: number of new alternative servers that are waiting to be copied to above array
+ * @new_servers_num: number of new alternative servers that are waiting to be
+ * copied to above array
* @new_servers: pending new alternative servers
* @update_available: 'true' if the rid has changes
- * @use_server_provided_alts: 'true' if the alt_servers array is upated by the alternatives provided by the server
+ * @use_server_provided_alts: 'true' if the alt_servers array is upated by the
+ * alternatives provided by the server
* @rid: the revision ID? TODO
* @reported_size: the size of the image
- * @panic_worker: worker to handle panics and to connect if all connections are down
- * @discovery_worker: worker to update the alt_servers, make rtt meassurement and reconnect to better servers
+ * @panic_worker: worker to handle panics and to connect if all connections are
+ * down
+ * @discovery_worker: worker to update the alt_servers, make rtt meassurement
+ * and reconnect to better servers
* @discovery_count: counter for the discovery worker
* @timer: timer to start the appropriate workers
* @timer_count: counter for the timer
@@ -137,21 +150,18 @@ struct dnbd3_device {
struct blk_mq_tag_set tag_set;
struct list_head list;
- // block
struct gendisk *disk;
- // sysfs
struct kobject kobj;
struct mutex device_lock;
- // network
struct dnbd3_sock socks[NUMBER_CONNECTIONS];
char *imgname;
struct dnbd3_server initial_server;
- struct dnbd3_server alt_servers[NUMBER_SERVERS]; // array of alt servers
- int new_servers_num; // number of new alt servers that are waiting to be copied to above array
- dnbd3_server_entry_t new_servers[NUMBER_SERVERS]; // pending new alt servers
+ struct dnbd3_server alt_servers[NUMBER_SERVERS];
+ int new_servers_num;
+ dnbd3_server_entry_t new_servers[NUMBER_SERVERS];
bool update_available;
bool use_server_provided_alts;
uint16_t rid;
@@ -198,12 +208,12 @@ struct dnbd3_cmd {
* print fmt, adds sock and device information to log
* <level>_server(dev, server, fmt,...)
* print fmt, adds device and appends server information to the log
- * DEBUG - if not defined switch of all debug messages
- * DEBUG_FILE - if not defined switch of file and line number information
+ * DEBUG - 1/0 switch all debug messages on
+ * DEBUG_FILE - 1/0 switch on file and line number information
*/
-#ifdef DEBUG_FILE
+#if IS_ENABLED(DEBUG_FILE)
#define __print(level, fmt,...) \
printk(level "%s:%d " fmt "\n", __FILE__, __LINE__, ## __VA_ARGS__)
@@ -211,30 +221,56 @@ struct dnbd3_cmd {
#else
#define __print(level, fmt,...) \
- printk(fmt, ## __VA_ARGS__)
+ printk(level fmt "\n", ## __VA_ARGS__)
#endif
#define __print_sock(level, sock, fmt, ...) \
do { \
if ((sock)->server->host.type == HOST_IP4) { \
- __print(level, "dnbd%d/%d %pI4:%d: " fmt, (sock)->device->minor, (sock)->sock_nr, (sock)->server->host.addr, (sock)->server->host.port, ## __VA_ARGS__); \
+ __print( \
+ level, \
+ "dnbd%d/%d %pI4:%d: " fmt, \
+ (sock)->device->minor, \
+ (sock)->sock_nr, \
+ (sock)->server->host.addr, \
+ (sock)->server->host.port, \
+ ## __VA_ARGS__); \
} else { \
- __print(level, "dnbd%d/%d %pI6:%d: " fmt, (sock)->device->minor, (sock)->sock_nr, (sock)->server->host.addr, (sock)->server->host.port, ## __VA_ARGS__); \
+ __print( \
+ level, \
+ "dnbd%d/%d %pI6:%d: " fmt, \
+ (sock)->device->minor, \
+ (sock)->sock_nr, \
+ (sock)->server->host.addr, \
+ (sock)->server->host.port, \
+ ## __VA_ARGS__); \
} \
} while (0)
#define __print_server(level, dev, server, fmt, ...) \
do { \
if ((server)->host.type == HOST_IP4) { \
- __print(level, "dnbd%d: " fmt " %pI4:%d", (dev)->minor, ## __VA_ARGS__, (server)->host.addr, (server)->host.port); \
+ __print( \
+ level, \
+ "dnbd%d: " fmt " %pI4:%d", \
+ (dev)->minor, \
+ ## __VA_ARGS__, \
+ (server)->host.addr, \
+ (server)->host.port); \
} else { \
- __print(level, "dnbd%d: " fmt " %pI6:%d", (dev)->minor, ## __VA_ARGS__, (server)->host.addr, (server)->host.port); \
+ __print( \
+ level, \
+ "dnbd%d: " fmt " %pI6:%d", \
+ (dev)->minor, \
+ ## __VA_ARGS__, \
+ (server)->host.addr, \
+ (server)->host.port); \
} \
} while (0)
-#ifdef DEBUG
+#if IS_ENABLED(DEBUG)
#define debug(fmt, ...) \
__print(KERN_DEBUG, "dnbd: " fmt, ## __VA_ARGS__)