From 4f40213d8e8f654e84626ff27fefd73395a8b99b Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Thu, 19 Aug 2021 11:55:21 +0530 Subject: [PATCH] rbd: fix rbd-nbd io-timeout to never abort With the tests at CI, it kind of looks like that the IO is timing out after 30 seconds (default with rbd-nbd). Since we have tweaked reattach-timeout to 300 seconds at ceph-csi, we need to explicitly set io-timeout on the device too, as it doesn't make any sense to keep io-timeout < reattach-timeout Hence we set io-timeout for rbd nbd to 0. Specifying io-timeout 0 tells the nbd driver to not abort the request and instead see if it can be restarted on another socket. Signed-off-by: Prasanna Kumar Kalever Suggested-by: Ilya Dryomov --- internal/rbd/rbd_attach.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/rbd/rbd_attach.go b/internal/rbd/rbd_attach.go index b855fa806..42dcc0201 100644 --- a/internal/rbd/rbd_attach.go +++ b/internal/rbd/rbd_attach.go @@ -49,6 +49,7 @@ const ( rbdMapConnectionTimeout = "Connection timed out" defaultNbdReAttachTimeout = 300 /* in seconds */ + defaultNbdIOTimeout = 0 /* do not abort the requests */ // The default way of creating nbd devices via rbd-nbd is through the // legacy ioctl interface, to take advantage of netlink features we @@ -59,6 +60,10 @@ const ( // It specifies how long the device should be held waiting for the // userspace process to come back to life. setNbdReattach = "reattach-timeout" + + // `io-timeout` of rbd-nbd is to tweak NBD_ATTR_TIMEOUT. It specifies + // how long the IO should wait to get handled before bailing out. + setNbdIOTimeout = "io-timeout" ) var hasNBD = false @@ -256,6 +261,9 @@ func appendDeviceTypeAndOptions(cmdArgs []string, isNbd, isThick bool, userOptio if !strings.Contains(userOptions, setNbdReattach) { cmdArgs = append(cmdArgs, "--options", fmt.Sprintf("%s=%d", setNbdReattach, defaultNbdReAttachTimeout)) } + if !strings.Contains(userOptions, setNbdIOTimeout) { + cmdArgs = append(cmdArgs, "--options", fmt.Sprintf("%s=%d", setNbdIOTimeout, defaultNbdIOTimeout)) + } } if isThick { // When an image is thick-provisioned, any discard/unmap/trim @@ -280,6 +288,9 @@ func appendRbdNbdCliOptions(cmdArgs []string, userOptions string) []string { if !strings.Contains(userOptions, setNbdReattach) { cmdArgs = append(cmdArgs, fmt.Sprintf("--%s=%d", setNbdReattach, defaultNbdReAttachTimeout)) } + if !strings.Contains(userOptions, setNbdIOTimeout) { + cmdArgs = append(cmdArgs, fmt.Sprintf("--%s=%d", setNbdIOTimeout, defaultNbdIOTimeout)) + } if userOptions != "" { options := strings.Split(userOptions, ",") for _, opt := range options {