From patchwork Thu Nov 26 13:03:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 1406621 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=VJx6atGa; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=pD29czXU; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4ChdTt0FdNz9sVL for ; Fri, 27 Nov 2020 00:12:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=owcmsaFbnZWDz3hDHBBjq+aR0vE4XzsscChrsUrSttw=; b=VJx6atGaDcFaJ4vmg+tR2nApe pGDCXjkEmuNqlvZu1x5FlBM78mzxxWc7t6vgq9P0zmcig/wq4ylIE7suz50e/9CJ6twPfFNgY8Gqf StfqxfD+71jhYJqsno7DCtxX4wZ240LAAF3br0nxsZGphwwkm/eb0jxmQeF3uQxa5kZAlboMSmXs8 ZB1b+M5/otn8ZfwXpBUx0+6oPdPm0f/hi9pSMUUL+xSxNs8nYngNJsk7YrZui0ClwF88deTuA9QhA PnQ6hTRs59wLRLc9oNu7gqVqDQnj7X98JxOjhLHhjeF17s049WOhLKFj/Yd6RXSspAV0r4lAhw06P 2gJCJxfYw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiH44-0000Ki-W1; Thu, 26 Nov 2020 13:12:01 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiGzF-00085I-H6 for linux-mtd@merlin.infradead.org; Thu, 26 Nov 2020 13:07:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=Bme5TLsLFPob464lUA3WbC3cRcGjsnB3bNEoo7Ro4xo=; b=pD29czXUGx7/JOI4aMyEeWQSMv N1pSrnLkpYZ1vq8lC0yj+QgDREYrZk8VsWtw25yH+LOOzsfPs12mfVambko3CQU5GmLhQd+ADpITR NimIO8kPlWXa1Ia40xiB690MR+b5inhHr9jscb7BELxpkGdihO6KSv4PW4H+bkyq/lvvorRsTObAn Z9+1XFVjPvzDzKPe4mnNvFUtdTeoIJI+do7cSsBSktZYaHDBuk98oBX5ks+o27ANd3JuHjqbQ/zPV JT3vxOZ0JJZMxIPsjC2wmWnt/UCdnXQTIIFNjhYzNw52BemG06yiDmkrywPn4RYaymOzpQ9HDY4rz q2zpyhig==; Received: from [2001:4bb8:18c:1dd6:27b8:b8a1:c13e:ceb1] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kiGzE-00041Y-0x; Thu, 26 Nov 2020 13:07:00 +0000 From: Christoph Hellwig To: Jens Axboe Subject: [PATCH 19/44] block: refactor __blkdev_put Date: Thu, 26 Nov 2020 14:03:57 +0100 Message-Id: <20201126130422.92945-20-hch@lst.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201126130422.92945-1-hch@lst.de> References: <20201126130422.92945-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-bcache@vger.kernel.org, Jan Kara , Mike Snitzer , linux-mm@kvack.org, Greg Kroah-Hartman , Jan Kara , Josef Bacik , Coly Li , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, dm-devel@redhat.com, linux-mtd@lists.infradead.org, Johannes Thumshirn , Tejun Heo Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Reorder the code to have one big section for the last close, and to use bdev_is_partition. Signed-off-by: Christoph Hellwig Reviewed-by: Greg Kroah-Hartman Reviewed-by: Jan Kara Acked-by: Tejun Heo --- fs/block_dev.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index d707ab376da86e..41c50cfba864e2 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1738,22 +1738,22 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) WARN_ON_ONCE(bdev->bd_holders); sync_blockdev(bdev); kill_bdev(bdev); - bdev_write_inode(bdev); - } - if (bdev->bd_contains == bdev) { - if (disk->fops->release) + + if (!bdev_is_partition(bdev) && disk->fops->release) disk->fops->release(disk, mode); - } - if (!bdev->bd_openers) { + disk_put_part(bdev->bd_part); bdev->bd_part = NULL; bdev->bd_disk = NULL; - if (bdev != bdev->bd_contains) + if (bdev_is_partition(bdev)) victim = bdev->bd_contains; bdev->bd_contains = NULL; put_disk_and_module(disk); + } else { + if (!bdev_is_partition(bdev) && disk->fops->release) + disk->fops->release(disk, mode); } mutex_unlock(&bdev->bd_mutex); bdput(bdev);