From patchwork Wed May 16 18:36:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10404653 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 1C108602C2 for ; Wed, 16 May 2018 18:36:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A1FB2863B for ; Wed, 16 May 2018 18:36:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F12D028671; Wed, 16 May 2018 18:36:13 +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 8928D2866C for ; Wed, 16 May 2018 18:36:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750846AbeEPSgM (ORCPT ); Wed, 16 May 2018 14:36:12 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:36783 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750759AbeEPSgM (ORCPT ); Wed, 16 May 2018 14:36:12 -0400 Received: by mail-qk0-f195.google.com with SMTP id l132-v6so1501352qke.3 for ; Wed, 16 May 2018 11:36:11 -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=2kRTmnze3ATqx07Rgz8vhQuEu+fb3hx3ndM9YFO7A2g=; b=DYEDVzCYUnikIlXA08GOfCNl6bSXOagjgUleEzc66xxkiGDVzibtWsmznraD1E5YmS 8OrhiLTFozkMlPr39GaNINpQ5jnGgOTiUnhSQLgHULnFv+6IsK1eUO8AhdMCjxr9jAFq M3gzIT2rvD8DhQFV2/HieVLWgakyFJCqKOZIr2mMlxxjVeBSYgySUWAigDQ/BTe/LfDI Hw+suA031eDLapigYEOW1cY9AesaiJ6IeoVYo5MPleQ3C/xO77fmgd4jhd1LWZXnqJJa bqUKBaNidPMwQ1liyjy0b6nC90NuGJuf4S+B+YaFTlvPnzPgbE0FDf/7rvQs7g1WDufO HduA== 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=2kRTmnze3ATqx07Rgz8vhQuEu+fb3hx3ndM9YFO7A2g=; b=f4A7xyGdvhRVx8LlOK7hOqc8eyZfgpbjmAwCz32/6VwcmTMQ397fYC3xPAQx7TS5ek /3zNMQ/3dxAAGO48vZ+4P4GTv9T+Rn9z4iGC/WCmEtDyRp2+gi0VsU/BpUvzBeYqXmwd 3kvqvnEXCcdHUEf+Tnt/ExNCJayflsV+xeM7qSftlEA8FfCUwckn0kTCOuQpnapNmjRx CFhxfT1z51+xzFjnctGYExmVg9sF1/6poD/VdkYPEQ76v8VVeE8hWvSeLJniiCn/po4e rMMBko9xWhGEoHUlfPnychNN1s5LLRvANx+wkyvfuFOgvHaUbktUFO5DR6YZT1EcCV4C Ethg== X-Gm-Message-State: ALKqPwdxp1x+BhyjAbfH9nd+oSnf6+vREuPYancWTBSk3lIFHL+3t4G3 rJLfEDpfwOXdoZf28YGEkIAiq59k X-Google-Smtp-Source: AB8JxZqC8IQw9M2KzzAGnNQeq7yrX3volnBfiu2ZRzTiTjt11KYrluJpQjBJGUIYL9vyfw+/6DSKIg== X-Received: by 2002:a37:6282:: with SMTP id w124-v6mr2126521qkb.300.1526495771481; Wed, 16 May 2018 11:36:11 -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 q8-v6sm2375782qtb.13.2018.05.16.11.36.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 11:36:10 -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 4/5] nbd: fix how we set bd_invalidated Date: Wed, 16 May 2018 14:36:04 -0400 Message-Id: <20180516183605.16159-4-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180516183605.16159-1-josef@toxicpanda.com> References: <20180516183605.16159-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 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index bc47bae9697a..24788bd10c8b 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -240,7 +240,10 @@ static void nbd_size_update(struct nbd_device *nbd) blk_queue_physical_block_size(nbd->disk->queue, config->blksize); set_capacity(nbd->disk, config->bytesize >> 9); if (bdev) { - bd_set_size(bdev, config->bytesize); + if (bdev->bd_disk) + bd_set_size(bdev, config->bytesize); + else + bdev->bd_invalidated = 1; bdput(bdev); } kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE); @@ -961,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) @@ -1279,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);