From patchwork Wed Mar 30 05:29:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12795489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3A76C433FE for ; Wed, 30 Mar 2022 05:29:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238900AbiC3FbW (ORCPT ); Wed, 30 Mar 2022 01:31:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242986AbiC3FbV (ORCPT ); Wed, 30 Mar 2022 01:31:21 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 026DE15B042 for ; Tue, 29 Mar 2022 22:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=vVUxEXGeE/RLZMR3d5tslbUH4dPXsuMDdYT090T28t8=; b=zuETnPQOIQSi55vjCuqzmX04uP ZYEbQbSe0IVARWl8XdETEN0T2mh6p6Vou3r8fJDwzqCK/LAW2ZKJMLEQgQeKh2m8NZV3SsJsmgtRP fUDQfk1iqimpV6XcSHR8jjt2yyQZfwkkgUA3MgvPB6483avlLACS3lO8G9V533taXrEHOkzN3KmZ2 n5390wM175sScorseyfEbg+8yc2ra4JSUYBIrxWElqsD3fXX1Fwp+Vie9AX8LDaOZqZ4wuHDxD7oK NH9w7/loxhSuuB31RO6lxyuXglfX9BJvHyGLsp2yNDH3sePG8UDOLdnG3lMkGn7mH7ruHXbWAwN/Y jxvcUz1Q==; Received: from 213-225-15-62.nat.highway.a1.net ([213.225.15.62] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZQtY-00EL9z-BE; Wed, 30 Mar 2022 05:29:25 +0000 From: Christoph Hellwig To: Jens Axboe , Josef Bacik , Minchan Kim , Nitin Gupta Cc: Tetsuo Handa , Jan Kara , "Darrick J . Wong" , Ming Lei , Matteo Croce , linux-block@vger.kernel.org, nbd@other.debian.org Subject: [PATCH 01/15] nbd: use the correct block_device in nbd_bdev_reset Date: Wed, 30 Mar 2022 07:29:03 +0200 Message-Id: <20220330052917.2566582-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220330052917.2566582-1-hch@lst.de> References: <20220330052917.2566582-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The bdev parameter to ->ioctl contains the block device that the ioctl is called on, which can be the partition. But the openers check in nbd_bdev_reset really needs to check use the whole device, so switch to using that. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara --- drivers/block/nbd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 5a1f98494dddf..2f29da41fbc80 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1217,11 +1217,11 @@ static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg) return -ENOSPC; } -static void nbd_bdev_reset(struct block_device *bdev) +static void nbd_bdev_reset(struct nbd_device *nbd) { - if (bdev->bd_openers > 1) + if (nbd->disk->part0->bd_openers > 1) return; - set_capacity(bdev->bd_disk, 0); + set_capacity(nbd->disk, 0); } static void nbd_parse_flags(struct nbd_device *nbd) @@ -1389,7 +1389,7 @@ static int nbd_start_device(struct nbd_device *nbd) return nbd_set_size(nbd, config->bytesize, nbd_blksize(config)); } -static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *bdev) +static int nbd_start_device_ioctl(struct nbd_device *nbd) { struct nbd_config *config = nbd->config; int ret; @@ -1408,7 +1408,7 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b flush_workqueue(nbd->recv_workq); mutex_lock(&nbd->config_lock); - nbd_bdev_reset(bdev); + nbd_bdev_reset(nbd); /* user requested, ignore socket errors */ if (test_bit(NBD_RT_DISCONNECT_REQUESTED, &config->runtime_flags)) ret = 0; @@ -1422,7 +1422,7 @@ static void nbd_clear_sock_ioctl(struct nbd_device *nbd, { sock_shutdown(nbd); __invalidate_device(bdev, true); - nbd_bdev_reset(bdev); + nbd_bdev_reset(nbd); if (test_and_clear_bit(NBD_RT_HAS_CONFIG_REF, &nbd->config->runtime_flags)) nbd_config_put(nbd); @@ -1468,7 +1468,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, config->flags = arg; return 0; case NBD_DO_IT: - return nbd_start_device_ioctl(nbd, bdev); + return nbd_start_device_ioctl(nbd); case NBD_CLEAR_QUE: /* * This is for compatibility only. The queue is always cleared