From patchwork Tue Jul 25 17:31:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9862581 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 CC55B602B1 for ; Tue, 25 Jul 2017 17:31:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF962285DE for ; Tue, 25 Jul 2017 17:31:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4B5328653; Tue, 25 Jul 2017 17:31:23 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 37D72286CF for ; Tue, 25 Jul 2017 17:31:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751427AbdGYRbW (ORCPT ); Tue, 25 Jul 2017 13:31:22 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:35765 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750972AbdGYRbW (ORCPT ); Tue, 25 Jul 2017 13:31:22 -0400 Received: by mail-qt0-f193.google.com with SMTP id t37so1931144qtg.2 for ; Tue, 25 Jul 2017 10:31:21 -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=kqz+O0GUyuJKGOzRj1XQHLpJ9q7HlPMW5pa93NlmgXg=; b=Yu7/6lkvcNM5jtwnyrBTqxO2dsuFZSRgJOv6vZCA1bp9HEgXGJ6NeVFilUbyjQ8RMf FlpLV0N2IqdkV1piCDQZWC+OZumu5hBUygrBm3wjsHQPIooJ0yENyNPeLOqEzcK+U9pv 6Gn+tvKg/S14cCReTrSdpYHSeIZTSTT4S1ZfxagaR5FrCP3zAwdWEfMisrr5g5dWpL79 JTwv6UYbdjYQXaxPVHmgB2L+kBFLR2quUL4qbDiWL0uB0xTlSvQYu5E7eH1c0HaQ53zQ SOslrD7WM/1Xq1/ZLqW14YaBokbVRhcIbuSrhh8RRQ/ogy7jSPcUqe9aoAydCAfpQPVi w4Nw== 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=kqz+O0GUyuJKGOzRj1XQHLpJ9q7HlPMW5pa93NlmgXg=; b=S2NyHFiPu13z8rnZxfVcgx8lFsdiKSvqCS+rekiVhJlnyKJlkfS+ezkeh1JhfkYb/2 4HidVbuPed/e1rpc7mTh9BsBpv2Rz1V9tHk9xsStMbv+UgUz5zEcTtYX+MHw1iEber6n qycw7jMzISyKOnK8BW2BglZv4Df4+uLJuE8+zdiVxbXeJ5o1HiSOLP3F0vAhggvAsS0D BVaAxncHhVW4wzKTGfJ0y2DCbWhILCMw+Fz3k8AcMStlOOmBTXH+cNq8c6nQM+7ObxUx SXnBVMfWe7k0tBbO1DekfdpU2EX/ZQarY6AZbNJ0kUID40QjOme3W3rnzjuffIlONLqL 76GA== X-Gm-Message-State: AIVw110P7GHixQTxQmZQq91o8syX42Zu0thA47/MCDAsyfUtdtXP/PZW z5B+OKFejE5IrDPq X-Received: by 10.237.57.71 with SMTP id l65mr25731141qte.82.1501003881235; Tue, 25 Jul 2017 10:31:21 -0700 (PDT) Received: from localhost ([2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id r65sm7073293qkb.20.2017.07.25.10.31.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Jul 2017 10:31:20 -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: clear disconnected on reconnect Date: Tue, 25 Jul 2017 13:31:19 -0400 Message-Id: <1501003879-18014-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 our device loses its connection for longer than the dead timeout we will set NBD_DISCONNECTED in order to quickly fail any pending IO's that flood in after the IO's that were waiting during the dead timer. However if we re-connect at some point in the future we'll still see this DISCONNECTED flag set if we then lose our connection again after that, which means we won't get notifications for our newly lost connections. Fix this by just clearing the DISCONNECTED flag on reconnect in order to make sure everything works as it's supposed to. 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 64b19b1..5bdf923 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -923,6 +923,8 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg) mutex_unlock(&nsock->tx_lock); sockfd_put(old); + clear_bit(NBD_DISCONNECTED, &config->runtime_flags); + /* We take the tx_mutex in an error path in the recv_work, so we * need to queue_work outside of the tx_mutex. */