From patchwork Fri Jul 21 14:48:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9857093 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 F3FC2601C0 for ; Fri, 21 Jul 2017 14:51:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEF6B287EB for ; Fri, 21 Jul 2017 14:51:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D41E8287EF; Fri, 21 Jul 2017 14:51:07 +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 710A1287EB for ; Fri, 21 Jul 2017 14:51:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750849AbdGUOtX (ORCPT ); Fri, 21 Jul 2017 10:49:23 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:34356 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753870AbdGUOsT (ORCPT ); Fri, 21 Jul 2017 10:48:19 -0400 Received: by mail-qt0-f196.google.com with SMTP id o3so2745986qto.1 for ; Fri, 21 Jul 2017 07:48:19 -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:in-reply-to:references; bh=thK9BtyCobvjO6QIQ3OLnjEITiGm4ekGWmJW9i0j73M=; b=kToaRAKmN8MeWuQXoB4VWXperDRLvXyOHAMCTOtaogwVEa2JGmtd0naFR7qR0Ce5l2 ZDRF2Q9/UqPzn2glWCzXDf4B79QEOj1UJkwvWZqLNuX4ALM2bnECRRVkKecE25gZY+f8 VAcrpn1WS9YEx4EaFlNyYxOxs/3cCbrObEU+ZyUclRyMkKi5C37lfoUSYubJQ2eUADUF GnuQavPgTO1DK3f/iP2xDIJpfwi+8gnhnO7jy02zAANKrqZyfrZUFDHfOL7aWuEOoHXY KjHs2PSfW2N1tBU+17fXLutDjpKkxyp3HkJpgV9lmZH6hQg6M0y4lsECNDWXDyoMXcOe W8FQ== 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:in-reply-to :references; bh=thK9BtyCobvjO6QIQ3OLnjEITiGm4ekGWmJW9i0j73M=; b=uVr9YNs0g37VFamSa7vMlZce3uu7VtaDjXgTU4nQHzVr+V4Nls1bttOIaKVwoy0Buo lH76S3OLIfSb29qM7F9l1a6bN2Ao2qdfjOebJdOldRbatTDPHCOmLqmEt+xot4jMMPI9 +72kFFj8cTCEY2HfADP+YZbvXLoRx2Ysyo4TuD7TSFVjYx4wbDNAez5Hlg9dTTkrwrQq r86leXzxCIK7pUVMIjugl5Bb6V/rqlydo9X4b6pCeKpqM6qZpCvpeb0lIrfLOY3kho+x U9P5fg8GlmJsZVOxE1TOwV3aOjx+zn6pDlnjIR/nIscEsoQ5qWjWkxgu5oqXCar0IoyV Hg0w== X-Gm-Message-State: AIVw113Dwka1LDN6gUM9I4VhcDruRb/02s8QtSGvGp9aXQG3dA1aSCKH BJWZOEM7ncrpKJRm X-Received: by 10.200.41.85 with SMTP id z21mr9588875qtz.238.1500648498881; Fri, 21 Jul 2017 07:48:18 -0700 (PDT) Received: from localhost ([2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id h5sm3493709qkc.6.2017.07.21.07.48.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jul 2017 07:48:18 -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 2/3] nbd: take tx_lock before disconnecting Date: Fri, 21 Jul 2017 10:48:14 -0400 Message-Id: <1500648495-13337-2-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500648495-13337-1-git-send-email-jbacik@fb.com> References: <1500648495-13337-1-git-send-email-jbacik@fb.com> 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 We need to take the tx_lock so we don't interleave our disconnect request between real data going down the wire. Signed-off-by: Josef Bacik --- drivers/block/nbd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index f91e7ac..6aefe9f 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -978,11 +978,15 @@ static void send_disconnects(struct nbd_device *nbd) int i, ret; for (i = 0; i < config->num_connections; i++) { + struct nbd_sock *nsock = config->socks[i]; + iov_iter_kvec(&from, WRITE | ITER_KVEC, &iov, 1, sizeof(request)); + mutex_lock(&nsock->tx_lock); ret = sock_xmit(nbd, i, 1, &from, 0, NULL); if (ret <= 0) dev_err(disk_to_dev(nbd->disk), "Send disconnect failed %d\n", ret); + mutex_unlock(&nsock->tx_lock); } }