summaryrefslogtreecommitdiffstats
path: root/src/kernel/utils.c
diff options
context:
space:
mode:
authorSimon Rettberg2022-02-12 23:56:35 +0100
committerSimon Rettberg2022-02-18 21:34:55 +0100
commiteb2876f6542af2bfa47c7a6905ecc4f81f1d2ad3 (patch)
tree17ebb5fd2d4770a4dd67f857f2488221cd46874c /src/kernel/utils.c
parent[KERNEL] Add missing include to fix compile on 4.14.x (diff)
downloaddnbd3-eb2876f6542af2bfa47c7a6905ecc4f81f1d2ad3.tar.gz
dnbd3-eb2876f6542af2bfa47c7a6905ecc4f81f1d2ad3.tar.xz
dnbd3-eb2876f6542af2bfa47c7a6905ecc4f81f1d2ad3.zip
[KERNEL] Refactor to use workqueues and blk-mq only
Using workqueues frees us from having to manage the lifecycle of three dedicated threads. Discovery (alt server checks) and sending keepalive packets is now done using work on the power efficient system queue. Sending and receiving happens via dedicated work queues with higher priority. blk-mq has also been around for quite a while in the kernel, so switching to it doesn't hurt backwards compatibility. As the code is now refactored to work more as blk-mq is designed, backwards compatibility even improved while at the same time freeing us from an arsenal of macros that were required to make the blk-mq port look and feel like the old implementation. For example, the code now compiles on CentOS 7 with kernel 3.10 without requiring special macros to detect the heavily modified RedHat kernel with all its backported features. A few other design limitations have been rectified along the way, e.g. switching to another server now doesn't internally disconnect from the current one first, which theoretically could lead to a non-working setup, if the new server isn't reachable and then - because of some transient network error - switching back also fails. As the discover-thread was torn down from the disconnect call, the connection would also not repair itself eventually. we now establish the new connection in parallel to the old one, and only if that succeeds do we replace the old one with it, similar to how the automatic alt-server switch already does it.
Diffstat (limited to 'src/kernel/utils.c')
-rw-r--r--src/kernel/utils.c48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/kernel/utils.c b/src/kernel/utils.c
deleted file mode 100644
index f2b7264..0000000
--- a/src/kernel/utils.c
+++ /dev/null
@@ -1,48 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * This file is part of the Distributed Network Block Device 3
- *
- * Copyright(c) 2011-2012 Johann Latocha <johann@latocha.de>
- *
- * This file may be licensed under the terms of the
- * GNU General Public License Version 2 (the ``GPL'').
- *
- * Software distributed under the License is distributed
- * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
- * express or implied. See the GPL for the specific language
- * governing rights and limitations.
- *
- * You should have received a copy of the GPL along with this
- * program. If not, go to http://www.gnu.org/licenses/gpl.html
- * or write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include <linux/kernel.h>
-
-#include "utils.h"
-
-unsigned int inet_addr(char *str)
-{
- int a, b, c, d;
- char arr[4];
- int ret;
-
- ret = sscanf(str, "%d.%d.%d.%d", &a, &b, &c, &d);
- if (ret > 0) {
- arr[0] = a;
- arr[1] = b;
- arr[2] = c;
- arr[3] = d;
- }
-
- return *(unsigned int *)arr;
-}
-
-void inet_ntoa(struct in_addr addr, char *str)
-{
- unsigned char *ptr = (unsigned char *)&addr;
-
- sprintf(str, "%d.%d.%d.%d", ptr[0] & 0xff, ptr[1] & 0xff, ptr[2] & 0xff, ptr[3] & 0xff);
-}