From patchwork Wed May 16 18:51:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10404669 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 9DF88602C2 for ; Wed, 16 May 2018 18:51:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DB2628384 for ; Wed, 16 May 2018 18:51:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 824B2285E8; Wed, 16 May 2018 18:51: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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, 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 2E12928384 for ; Wed, 16 May 2018 18:51:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750935AbeEPSvd (ORCPT ); Wed, 16 May 2018 14:51:33 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:33230 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751227AbeEPSvc (ORCPT ); Wed, 16 May 2018 14:51:32 -0400 Received: by mail-qt0-f193.google.com with SMTP id e8-v6so2493793qth.0 for ; Wed, 16 May 2018 11:51: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:in-reply-to:references; bh=R1ygcoshcXSnIYXfr1+VWy0YJPA7rW44OTzQpbj8zdQ=; b=Vw3h4Na8CyKNLxaiEBrFneov/D7smAKg9a4H2SDmjGKm6r7sddhTLDLZEDK1P23DcD Cw+Y6v9UiMcP65p9lVfbgmt5qYqNFfDAw5cyZOUOBOVNC2Od7NtnKk10HkG0ME519MPW Zg7ubPnw9f0oklBdJSkJMjxYVapu9Uwxzw3bEI9s1JESURtLCX+LFWhVRh0YnlZISgm+ WKjz25Lm+ViC1pc0qQSiBHGzElL3WyG8xG1bCIu4+a+Bz3fOcLcgMXjatWCmdi/lEraC VWCRjBTL1Tpu+l68ibEXrhwX79pH/Zbm/pQyQR/oUaUNlkUeUee/aFkRD/gOmtTPpkmt Qyow== 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=R1ygcoshcXSnIYXfr1+VWy0YJPA7rW44OTzQpbj8zdQ=; b=cFqm8A5/lssB31GAliWadeOlvr7cOfa4s03Ru8H9Yw7W4n1o4+rBwH3TygfUr0TtvB uZEqduq9XxHuja1pKs3cXwUQCzUDvDqOQpAEzFEkevHTQT9raNudWGIpuoymBGKp60KC nr/8sLJeQahZvT2VPDY2Poc/XbcHKVE0h4BJbpDcB+SeodHgbSNzRs7372Ny0vwXe0FD cOsVPPzlj+8T3vHZeAur6o+NsTej40vKRuBwFfE2fqwv57iQ57kUQPobZZx1zrOwRFJn pbsv/Jj0NzJZW/rkzS0uHHchK+4a0WAuNMp0NiF1wbbzXbKNtLvnvkO9WhLcku2M1b3O S4kg== X-Gm-Message-State: ALKqPweDsxIPAo6QGDBVcafHrknyJGBoQzGGv/IF9k2tQFVXTAtD1GIm D1NvFZGyz51NopoSGJ/opL6TfW+u X-Google-Smtp-Source: AB8JxZpLwhZIBkcVryvPxhnDw/6O61sVRiX2pIzBYWEMlk/9KW8hZPtMdUQ4e7kxniRQ/8vzgWvqCQ== X-Received: by 2002:ac8:396f:: with SMTP id t44-v6mr2274477qtb.22.1526496691733; Wed, 16 May 2018 11:51:31 -0700 (PDT) Received: from localhost (cpe-2606-A000-4381-1201-225-22FF-FEB3-E51A.dyn6.twc.com. [2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id s11-v6sm2519677qtk.39.2018.05.16.11.51.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 11:51:31 -0700 (PDT) From: Josef Bacik To: axboe@kernel.dk, nbd@other.debian.org, linux-block@vger.kernel.org, kernel-team@fb.com Cc: Josef Bacik Subject: [PATCH 6/7] nbd: fix how we set bd_invalidated Date: Wed, 16 May 2018 14:51:21 -0400 Message-Id: <20180516185122.18590-6-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180516185122.18590-1-josef@toxicpanda.com> References: <20180516185122.18590-1-josef@toxicpanda.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 bd_invalidated is kind of a pain wrt partitions as it really only triggers the partition rescan if it is set after bd_ops->open() runs, so setting it when we reset the device isn't useful. We also sporadically would still have partitions left over in some disconnect cases, so fix this by always setting bd_invalidated on open if there's no configuration or if we've had a disconnect action happen, that way the partition table gets invalidated and rescanned properly. Signed-off-by: Josef Bacik --- drivers/block/nbd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 06725ce97593..24788bd10c8b 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -964,10 +964,6 @@ static void nbd_bdev_reset(struct block_device *bdev) if (bdev->bd_openers > 1) return; bd_set_size(bdev, 0); - if (max_part > 0) { - blkdev_reread_part(bdev); - bdev->bd_invalidated = 1; - } } static void nbd_parse_flags(struct nbd_device *nbd) @@ -1282,6 +1278,9 @@ static int nbd_open(struct block_device *bdev, fmode_t mode) refcount_set(&nbd->config_refs, 1); refcount_inc(&nbd->refs); mutex_unlock(&nbd->config_lock); + bdev->bd_invalidated = 1; + } else if (nbd_disconnected(nbd->config)) { + bdev->bd_invalidated = 1; } out: mutex_unlock(&nbd_index_mutex);