From patchwork Thu Jun 8 19:39:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9776339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EAE926034B for ; Thu, 8 Jun 2017 19:39:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D972628553 for ; Thu, 8 Jun 2017 19:39:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC7FA285A5; Thu, 8 Jun 2017 19:39:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2098928553 for ; Thu, 8 Jun 2017 19:39:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751515AbdFHTjd (ORCPT ); Thu, 8 Jun 2017 15:39:33 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:36493 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751470AbdFHTjc (ORCPT ); Thu, 8 Jun 2017 15:39:32 -0400 Received: by mail-qt0-f195.google.com with SMTP id s33so10514169qtg.3 for ; Thu, 08 Jun 2017 12:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=v+4uIdw4Vlpnwf54qmwdTPyqh9h0q7htjYdP582PVr8=; b=XBGXFnqkEL1NnZynHMCaXs+xFvUEwpJBXRO1cW4F0zmsMH7I8mo0StG/blwbPoKEU6 UXXACakg3fPoFgsei9631jCB6pEpwAbmh0BQTgoRCWKe6QDv2OIz2oYMOD5CnDPjGNmN ALMvcqH8IL0uzZwolC8c6w8BkBxciOUA15hobjtcr3luV8MUAwnm/SM5x3M2+ZiMa5wf jwaK9mwkZXxl5vHHH8ITJuIeqUz0+FHKQZOEFIAe6jI+ZUZc2ESpjpZyLYEfRx61B80o 7642H7TjIHIhM2CwcE/ZrnXnRMXzux/RYd97WmMk0/e/6syyOM1Rmp+4TdcVEFjRNJ8H QAmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=v+4uIdw4Vlpnwf54qmwdTPyqh9h0q7htjYdP582PVr8=; b=d1S4NKZt2XTS6Itn4HMXvStOQ7EQJ2uLAzuJrERWTu+ZA4fiUAUmgokGxyYiinhLuN EFZmz8c4sPYP5LuEoyYMJkZMIFpUq9/ZBeKjaK14VV06pnSKkHRG0H+FbNxFHjSm0lse E2i8Z6rvrilhXSEc+UoM0dj9GcMhLc8UE4+hhMOlleqqMJObwYsWyOJTl1GoYKOv2DSL 5s8IfQ96ANK0fkO132kdQHe2VU3CWfKHxS1asSc8Br49bCYNXjsGRPu5NeMZWp0IXXx2 0drMIP16mvuTYxZeFyHZtqL1OQZ4LlHWyb6uyYbCrlOgwpHLo8nBLm7fVFXLmi8UZVAB 1yTg== X-Gm-Message-State: AODbwcBaENiGkBTsUTrly5c+5de21cC8/tqxljS42rdKRbCucJq4t0AB 6+yDTVcZOTJPF/l5 X-Received: by 10.237.60.218 with SMTP id e26mr39482372qtf.106.1496950771737; Thu, 08 Jun 2017 12:39:31 -0700 (PDT) Received: from localhost ([2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id m47sm3828925qtc.36.2017.06.08.12.39.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 12:39:31 -0700 (PDT) From: josef@toxicpanda.com X-Google-Original-From: jbacik@fb.com To: axboe@kernel.dk, nbd-general@lists.sourceforge.net, linux-block@vger.kernel.org, kernel-team@fb.com Cc: Josef Bacik Subject: [PATCH] nbd: set sk->sk_sndtimeo for our sockets Date: Thu, 8 Jun 2017 15:39:30 -0400 Message-Id: <1496950770-5642-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.7.4 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Bacik 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 Signed-off-by: Josef Bacik --- 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);