Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1067244pxu; Thu, 17 Dec 2020 01:03:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQdps3pSO+TSn9w7/VJ12gqmUQ2ynCrJm+DjdV1Pkziy6Dl4T4GDkpl7Qj0pfwQmENAuFh X-Received: by 2002:aa7:d94e:: with SMTP id l14mr10392411eds.98.1608195821685; Thu, 17 Dec 2020 01:03:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608195821; cv=none; d=google.com; s=arc-20160816; b=KEIBlCvvuvYt30vGIhGud3x9+ELC2LWcd29Gd2hBD18sep2l6dy7Wo5QPJW+o74dO9 nkiTHDtvaQeV6ZpN2BQGK5SwF4F7m/VhV1SL2pb0MKZMu4pnoFEfYEcjWP9Y2DfTZ67p tzoOTUkCURMIbz/mS/D3+0VsZAJ/xNgGWvCzZ3+RGxxULiDKrp80Xv11EkISZdDhyPJD M7XB/Fg3Q7xl1J+6MPiy9YiVatDbBln0DdzR7y0TngDGdZw9vG92xiyJl6LkfSTp93Vv DwKJl2Ec+LBtYFqHu0fZGgeebS+9D1Q74N6zL1CIPnaaStAIIfFE89Kxmyir/1SucSAM JJIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date; bh=kfIjtIT9XpL3qxBKhJnMKHbNohIPC6kYmeiTxPRA/7o=; b=zvt8UjNjMmvYmGU1LMY/7nfeMkqoG0F91rQo0GN1icsN0wu3mqoi/xdnAd88zojSsL UKM/qYusTJFmTaApR83A7Syv8HVT6LPqhX2Z0LozaPjp3u4J/Sd2KyVqMWCVGz26Y4mg 23Q4HzGKNKCwbx5CNLGSMP79l54rnbj74oB2N9mNrRfu79NsNW9pTxY/LW2mVxiPWiVR OmO2hTaQuav/bOaoZ4tdF6meUmXkanLSqaecSqp8erv1Weu/SjlU4Fh05evJBROmaN3M wT21UFu0HayJhRmJcCQo6QY+qJ0zXxq1vfuZB/ikRdlv8lhCWv8FNvgE4wq3CfG+btlg Uubg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u26si2145168ejx.267.2020.12.17.01.03.18; Thu, 17 Dec 2020 01:03:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727632AbgLQI7e (ORCPT + 99 others); Thu, 17 Dec 2020 03:59:34 -0500 Received: from relay10.mail.gandi.net ([217.70.178.230]:55559 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727035AbgLQI7e (ORCPT ); Thu, 17 Dec 2020 03:59:34 -0500 Received: from localhost (50-39-163-217.bvtn.or.frontiernet.net [50.39.163.217]) (Authenticated sender: josh@joshtriplett.org) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 7B417240010; Thu, 17 Dec 2020 08:58:49 +0000 (UTC) Date: Thu, 17 Dec 2020 00:58:47 -0800 From: Josh Triplett To: Josef Bacik , Jens Axboe Cc: linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org Subject: [PATCH] nbd: Respect max_part for all partition scans Message-ID: <86d03378210ddac44eb07ebb78c9b0f32c56fe96.1608195087.git.josh@joshtriplett.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The creation path of the NBD device respects max_part and only scans for partitions if max_part is not 0. However, some other code paths ignore max_part, and unconditionally scan for partitions. Add a check for max_part on each partition scan. Signed-off-by: Josh Triplett --- Caught this when reading recent NBD patches, which tweaked the nbd_set_size path. It doesn't seem worth factoring these two lines into a function, especially since the callers obtain the disk structure in different ways. drivers/block/nbd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 92f84ed0ba9e..6727358e147d 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -318,7 +318,8 @@ static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, blk_queue_logical_block_size(nbd->disk->queue, blksize); blk_queue_physical_block_size(nbd->disk->queue, blksize); - set_bit(GD_NEED_PART_SCAN, &nbd->disk->state); + if (max_part) + set_bit(GD_NEED_PART_SCAN, &nbd->disk->state); if (!set_capacity_and_notify(nbd->disk, bytesize >> 9)) kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE); return 0; @@ -1476,9 +1477,11 @@ 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); - set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state); + if (max_part) + set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state); } else if (nbd_disconnected(nbd->config)) { - set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state); + if (max_part) + set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state); } out: mutex_unlock(&nbd_index_mutex); -- 2.29.2