diff options
author | Josef Bacik <jbacik@fb.com> | 2017-06-08 21:39:30 +0200 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2017-06-09 16:33:19 +0200 |
commit | dc88e34d69d87c370deaa9d613dac8e3a0411f59 (patch) | |
tree | f139323df2a6f193fe0063532299baedb32af1df /drivers/block/nbd.c | |
parent | loop: fix error handling regression (diff) | |
download | linux-dc88e34d69d87c370deaa9d613dac8e3a0411f59.tar.xz linux-dc88e34d69d87c370deaa9d613dac8e3a0411f59.zip |
nbd: set sk->sk_sndtimeo for our sockets
If the nbd server stops receiving packets altogether we will get stuck
waiting for them to receive indefinitely as the tcp buffer will never
empty, which looks like a deadlock. Fix this by setting the sk send
timeout to our configured timeout, that way if the server really
misbehaves we'll disconnect cleanly instead of waiting forever.
Reported-by: Dan Melnic <dmm@fb.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block/nbd.c')
-rw-r--r-- | drivers/block/nbd.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index c5e52f66d3d4..6de9f9943a0e 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -914,6 +914,7 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg) continue; } sk_set_memalloc(sock->sk); + sock->sk->sk_sndtimeo = nbd->tag_set.timeout; atomic_inc(&config->recv_threads); refcount_inc(&nbd->config_refs); old = nsock->sock; @@ -1083,6 +1084,7 @@ static int nbd_start_device(struct nbd_device *nbd) return -ENOMEM; } sk_set_memalloc(config->socks[i]->sock->sk); + config->socks[i]->sock->sk->sk_sndtimeo = nbd->tag_set.timeout; atomic_inc(&config->recv_threads); refcount_inc(&nbd->config_refs); INIT_WORK(&args->work, recv_work); |