qemu-nbd: set timeout to qemu-nbd socket
PATCH 1/1 qemu-nbd: set timeout to qemu-nbd socket
From: lu zhipeng <[email protected]>
Prevent the NBD socket stuck all the time, So
set timeout.
--- nbd/client.c | 8 ++++++++ 1 file changed, 8 insertions(+)
nbd/client.c +8 -0
@@ -24,6 +24,8 @@#include "nbd-internal.h" #include "qemu/cutils.h" +#define NBD_DEFAULT_TIMEOUT 30 +/* Definitions for opaque data types */ static QTAILQ_HEAD(, NBDExport) exports = QTAILQ_HEAD_INITIALIZER(exports);
@@ -1301,6 +1303,12 @@ int nbd_init(int fd, QIOChannelSocket *sioc, NBDExportInfo *info, } } +if (ioctl (fd,NBD_SET_TIMEOUT ,NBD_DEFAULT_TIMEOUT ) <0 ) { +int serrno = errno; +error_setg (errp,"Failed setting timeout" ); +return -serrno; + } +trace_nbd_init_finish ();return 0 ;
Signature · 1 line
2.31.1
[+ Den]
Quoted 26 lines · luzhipeng
From: lu zhipeng <[email protected]>
Prevent the NBD socket stuck all the time, So
set timeout.Signed-off-by lu zhipeng <[email protected]>--- nbd/client.c | 8 ++++++++ 1 file changed, 8 insertions(+)nbd/client.c +2
-0@@ -24,6 +24,8 @@#include "nbd-internal.h" #include "qemu/cutils.h" +#define NBD_DEFAULT_TIMEOUT 30 +/* Definitions for opaque data types */ static QTAILQ_HEAD(, NBDExport) exports = QTAILQ_HEAD_INITIALIZER(exports);@@ -1301,6 +1303,12 @@ int nbd_init(int fd, QIOChannelSocket *sioc, NBDExportInfo *info, } }
nbd/client.c int nbd_init(int fd, QIOChannelSocket *sioc, NBDExportInfo *info, · line 1314
Quoted 10 lines
nbd/client.c +6
-0+if (ioctl (fd,NBD_SET_TIMEOUT ,NBD_DEFAULT_TIMEOUT ) <0 ) { +int serrno = errno; +error_setg (errp,"Failed setting timeout" ); +return -serrno; + } +trace_nbd_init_finish ();return 0 ;
Personally, I don't see a problem in enabling timeout by default.. But probably we need a new option instead?
Signature · 2 lines
Best regards, Vladimir
Quoted 31 lines · Vladimir Sementsov-Ogievskiy
[+ Den]
Quoted 28 lines · luzhipeng
From: lu zhipeng <[email protected]>
Prevent the NBD socket stuck all the time, So
set timeout.Signed-off-by lu zhipeng <[email protected]>---
nbd/client.c| 8 ++++++++1 file changed, 8 insertions(+)nbd/client.c +0
-0@@ -24,6 +24,8 @@ #include "nbd-internal.h" #include "qemu/cutils.h"+#define
NBD_DEFAULT_TIMEOUT30
+
/* Definitions for opaque data types */
staticQTAILQ_HEAD(, NBDExport)exports =QTAILQ_HEAD_INITIALIZER(exports);nbd/client.c +2
-0@@ -1301,6 +1303,12 @@ int nbd_init(int fd, QIOChannelSocket *sioc,NBDExportInfo *info, } } + if (ioctl(fd, NBD_SET_TIMEOUT, NBD_DEFAULT_TIMEOUT) < 0) { + int serrno = errno; + error_setg(errp, "Failed setting timeout");
Quoted 10 lines
nbd/client.c int nbd_init(int fd, QIOChannelSocket *sioc, NBDExportInfo *info, · line 1314
Quoted 5 lines
nbd/client.c +3
-0+ return -serrno; + } + trace_nbd_init_finish(); return 0;Personally, I don't see a problem in enabling timeout by default.. But probably we need a new option instead?
I believe that this should be the same story as we have had with KEEPALIVE. This should be set as an option and downstream will change its default when necessary.
Den
Quoted 41 lines · Denis V. Lunev
Quoted 30 lines · Vladimir Sementsov-Ogievskiy
[+ Den]
Quoted 27 lines · luzhipeng
From: lu zhipeng <[email protected]>
Prevent the NBD socket stuck all the time, So
set timeout.Signed-off-by lu zhipeng <[email protected]>---
nbd/client.c| 8 ++++++++1 file changed, 8 insertions(+)nbd/client.c +0
-0@@ -24,6 +24,8 @@ #include "nbd-internal.h" #include "qemu/cutils.h"+#define
NBD_DEFAULT_TIMEOUT30
+
/* Definitions for opaque data types */
staticQTAILQ_HEAD(, NBDExport)exports =QTAILQ_HEAD_INITIALIZER(exports);nbd/client.c +2
-0@@ -1301,6 +1303,12 @@ int nbd_init(int fd, QIOChannelSocket *sioc, NBDExportInfo *info, } } + if (ioctl(fd, NBD_SET_TIMEOUT, NBD_DEFAULT_TIMEOUT) < 0) { + int serrno = errno; + error_setg(errp, "Failed setting timeout");Quoted 10 lines
nbd/client.c int nbd_init(int fd, QIOChannelSocket *sioc, NBDExportInfo *info, · line 1314
Quoted 5 lines
nbd/client.c +3
-0+ return -serrno; + } + trace_nbd_init_finish(); return 0;Personally, I don't see a problem in enabling timeout by default.. But probably we need a new option instead?
Quoted 4 lines
I believe that this should be the same story as we have had with KEEPALIVE. This should be set as an option and downstream will change its default when necessary.
It's also interesting, how NBD_SET_TIMEOUT would interfere with keep-alive options set on the socket. Isn't existing keep-alive option already enough, do we need both timeouts?
(and yes, if we need both ways for different cases, we definitely should keep a possibility for the user to enable only one timeout, so now I agree, that we need an option for this new feature)
Signature · 2 lines
Best regards, Vladimir
Quoted 43 lines · Vladimir Sementsov-Ogievskiy
Quoted 42 lines · Denis V. Lunev
Quoted 41 lines · Vladimir Sementsov-Ogievskiy
[+ Den]
Quoted 23 lines · luzhipeng
From: lu zhipeng <[email protected]>
Prevent the NBD socket stuck all the time, So
set timeout.Signed-off-by lu zhipeng <[email protected]>---
nbd/client.c| 8 ++++++++1 file changed, 8 insertions(+)nbd/client.c +0
-0@@ -24,6 +24,8 @@ #include "nbd-internal.h" #include "qemu/cutils.h"+#define
NBD_DEFAULT_TIMEOUT30
+
/* Definitions for opaque data types */
staticQTAILQ_HEAD(, NBDExport)exports =QTAILQ_HEAD_INITIALIZER(exports);nbd/client.c +0
-0@@ -1301,6 +1303,12 @@ int nbd_init(int fd, QIOChannelSocket *sioc, NBDExportInfo *info,nbd/client.c int nbd_init(int fd, QIOChannelSocket *sioc, · line 1313
Quoted 10 lines
nbd/client.c +5
-0} } + if (ioctl(fd, NBD_SET_TIMEOUT, NBD_DEFAULT_TIMEOUT) < 0) { + int serrno = errno; + error_setg(errp, "Failed setting timeout"); + return -serrno; + } + trace_nbd_init_finish(); return 0;Personally, I don't see a problem in enabling timeout by default.. But probably we need a new option instead?
Quoted 10 lines
Quoted 4 lines
I believe that this should be the same story as we have had with KEEPALIVE. This should be set as an option and downstream will change its default when necessary.
It's also interesting, how
NBD_SET_TIMEOUTwould interfere with keep-alive options set on the socket. Isn't existing keep-alive option already enough, do we need both timeouts?(and yes, if we need both ways for different cases, we definitely should keep a possibility for the user to enable only one timeout, so now I agree, that we need an option for this new feature)
keep-alive is only valid for tcp mode, unix domain is not valid
Quoted 43 lines · Vladimir Sementsov-Ogievskiy
Quoted 42 lines · Denis V. Lunev
Quoted 41 lines · Vladimir Sementsov-Ogievskiy
[+ Den]
Quoted 23 lines · luzhipeng
From: lu zhipeng <[email protected]>
Prevent the NBD socket stuck all the time, So
set timeout.Signed-off-by lu zhipeng <[email protected]>---
nbd/client.c| 8 ++++++++1 file changed, 8 insertions(+)nbd/client.c +0
-0@@ -24,6 +24,8 @@ #include "nbd-internal.h" #include "qemu/cutils.h"+#define
NBD_DEFAULT_TIMEOUT30
+
/* Definitions for opaque data types */
staticQTAILQ_HEAD(, NBDExport)exports =QTAILQ_HEAD_INITIALIZER(exports);nbd/client.c +0
-0@@ -1301,6 +1303,12 @@ int nbd_init(int fd, QIOChannelSocket *sioc, NBDExportInfo *info,nbd/client.c int nbd_init(int fd, QIOChannelSocket *sioc, · line 1313
Quoted 10 lines
nbd/client.c +5
-0} } + if (ioctl(fd, NBD_SET_TIMEOUT, NBD_DEFAULT_TIMEOUT) < 0) { + int serrno = errno; + error_setg(errp, "Failed setting timeout"); + return -serrno; + } + trace_nbd_init_finish(); return 0;Personally, I don't see a problem in enabling timeout by default.. But probably we need a new option instead?
Quoted 8 lines
Quoted 4 lines
I believe that this should be the same story as we have had with KEEPALIVE. This should be set as an option and downstream will change its default when necessary.
It's also interesting, how
NBD_SET_TIMEOUTwould interfere with keep-alive options set on the socket. Isn't existing keep-alive option already enough, do we need both timeouts?(and yes, if we need both ways for different cases, we definitely should keep a possibility for the user to enable only one timeout, so now I agree, that we need an option for this new feature)
Keep alive is only valid for tcp, but not for unix sockets