]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
nbd: set sk->sk_sndtimeo for our sockets
authorJosef Bacik <jbacik@fb.com>
Thu, 8 Jun 2017 19:39:30 +0000 (15:39 -0400)
committerJens Axboe <axboe@fb.com>
Fri, 9 Jun 2017 14:33:19 +0000 (08:33 -0600)
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>
drivers/block/nbd.c

index c5e52f66d3d44b2fdf4e3726d51870a7c7c49441..6de9f9943a0e74377be2a0c5552cbfafe3a06ff4 100644 (file)
@@ -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);