From d2c7d17d96e5f4e5196f60b4cec368c37d3450be Mon Sep 17 00:00:00 2001 From: Wouter Verhelst Date: Sat, 3 Jan 2009 06:08:52 +0100 Subject: [PATCH] Change meaning of -swap option Change meaning of -swap option: rather than trying to use a kernel patch which has been effectively dead since sometime around 2.1.something, do an mlockall() so that the kernel won't throw us out. The MCL_CURRENT | MCL_FUTURE bit might prove to be problematic, but if so, we'll deal with it when we get there. --- nbd-client.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nbd-client.c b/nbd-client.c index 4df2281..4156915 100644 --- a/nbd-client.c +++ b/nbd-client.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #ifndef __GNUC__ @@ -185,6 +186,9 @@ void finish_sock(int sock, int nbd, int swap) { if (ioctl(nbd, NBD_SET_SOCK, sock) < 0) err("Ioctl NBD_SET_SOCK failed: %m\n"); +/* + * If anyone ever forward-patches this patch, I'll happily re-enable + * this code. Until then... #ifndef SO_SWAPPING if (swap) err("You have to compile me on machine with swapping patch enabled in order to use it later."); @@ -193,6 +197,8 @@ void finish_sock(int sock, int nbd, int swap) { if (setsockopt(sock, SOL_SOCKET, SO_SWAPPING, &one, sizeof(int)) < 0) err("Could not enable swapping: %m"); #endif +*/ + mlockall(MCL_CURRENT | MCL_FUTURE); } int main(int argc, char *argv[]) { @@ -222,7 +228,7 @@ int main(int argc, char *argv[]) { } ++argv; --argc; /* skip programname */ - + if (strcmp(argv[0], "-d")==0) { nbd = open(argv[1], O_RDWR); if (nbd < 0) -- 1.7.10.4