diff options
author | Josef Bacik <jbacik@fb.com> | 2017-07-21 10:48:15 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2017-07-22 13:12:32 -0400 |
commit | a7ee8cf190ecc8f118f0b7839912564117524d85 (patch) | |
tree | 94102d0ba3f4defefedc7914899b12a2acc91d97 | |
parent | b4b2aeccf0f0fa1fd356cc72eeda7a2c66c39904 (diff) |
nbd: only set sndtimeo if we have a timeout set
A user reported that he was getting immediate disconnects with my
sndtimeo patch applied. This is because by default the OSS nbd client
doesn't set a timeout, so we end up setting the sndtimeo to 0, which of
course means we have send errors a lot. Instead only set our sndtimeo
if the user specified a timeout, otherwise we'll just wait forever like
we did previously.
Fixes: dc88e34d69d8 ("nbd: set sk->sk_sndtimeo for our sockets")
Reported-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | drivers/block/nbd.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 6aefe9fca6ce..64b19b10b739 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -908,7 +908,8 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg) | |||
908 | continue; | 908 | continue; |
909 | } | 909 | } |
910 | sk_set_memalloc(sock->sk); | 910 | sk_set_memalloc(sock->sk); |
911 | sock->sk->sk_sndtimeo = nbd->tag_set.timeout; | 911 | if (nbd->tag_set.timeout) |
912 | sock->sk->sk_sndtimeo = nbd->tag_set.timeout; | ||
912 | atomic_inc(&config->recv_threads); | 913 | atomic_inc(&config->recv_threads); |
913 | refcount_inc(&nbd->config_refs); | 914 | refcount_inc(&nbd->config_refs); |
914 | old = nsock->sock; | 915 | old = nsock->sock; |
@@ -1077,7 +1078,9 @@ static int nbd_start_device(struct nbd_device *nbd) | |||
1077 | return -ENOMEM; | 1078 | return -ENOMEM; |
1078 | } | 1079 | } |
1079 | sk_set_memalloc(config->socks[i]->sock->sk); | 1080 | sk_set_memalloc(config->socks[i]->sock->sk); |
1080 | config->socks[i]->sock->sk->sk_sndtimeo = nbd->tag_set.timeout; | 1081 | if (nbd->tag_set.timeout) |
1082 | config->socks[i]->sock->sk->sk_sndtimeo = | ||
1083 | nbd->tag_set.timeout; | ||
1081 | atomic_inc(&config->recv_threads); | 1084 | atomic_inc(&config->recv_threads); |
1082 | refcount_inc(&nbd->config_refs); | 1085 | refcount_inc(&nbd->config_refs); |
1083 | INIT_WORK(&args->work, recv_work); | 1086 | INIT_WORK(&args->work, recv_work); |