linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nbd: set sk->sk_sndtimeo for our sockets
@ 2017-06-08 19:39 josef
  2017-06-09 14:33 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: josef @ 2017-06-08 19:39 UTC (permalink / raw)
  To: axboe, nbd-general, linux-block, kernel-team; +Cc: Josef Bacik

From: Josef Bacik <jbacik@fb.com>

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>
---
 drivers/block/nbd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index f3f191b..ac0f7a8 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -910,6 +910,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;
@@ -1071,6 +1072,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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nbd: set sk->sk_sndtimeo for our sockets
  2017-06-08 19:39 [PATCH] nbd: set sk->sk_sndtimeo for our sockets josef
@ 2017-06-09 14:33 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2017-06-09 14:33 UTC (permalink / raw)
  To: josef, nbd-general, linux-block, kernel-team; +Cc: Josef Bacik

On 06/08/2017 01:39 PM, josef@toxicpanda.com wrote:
> From: Josef Bacik <jbacik@fb.com>
> 
> 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.

Queued up for 4.13, thanks.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-09 14:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-08 19:39 [PATCH] nbd: set sk->sk_sndtimeo for our sockets josef
2017-06-09 14:33 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).