All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org
Subject: [PATCH 5/8] btrfs: no need to grab a reference to disk->part0
Date: Wed, 21 Jul 2021 17:35:20 +0200	[thread overview]
Message-ID: <20210721153523.103818-6-hch@lst.de> (raw)
In-Reply-To: <20210721153523.103818-1-hch@lst.de>

The struct block_device for the whole disk will not be freed while
the disk in use, so don't bother to grab a reference to it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/zoned.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 297c0b1c0634..21c5654967b0 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1362,20 +1362,16 @@ void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered)
 	struct extent_map_tree *em_tree;
 	struct extent_map *em;
 	struct btrfs_ordered_sum *sum;
-	struct block_device *bdev;
 	u64 orig_logical = ordered->disk_bytenr;
 	u64 *logical = NULL;
 	int nr, stripe_len;
 
 	/* Zoned devices should not have partitions. So, we can assume it is 0 */
 	ASSERT(ordered->partno == 0);
-	bdev = bdgrab(ordered->disk->part0);
-	if (WARN_ON(!bdev))
-		return;
 
-	if (WARN_ON(btrfs_rmap_block(fs_info, orig_logical, bdev,
-				     ordered->physical, &logical, &nr,
-				     &stripe_len)))
+	if (WARN_ON(btrfs_rmap_block(fs_info, orig_logical,
+			ordered->disk->part0, ordered->physical, &logical,
+			&nr, &stripe_len)))
 		goto out;
 
 	WARN_ON(nr != 1);
@@ -1402,7 +1398,6 @@ void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered)
 
 out:
 	kfree(logical);
-	bdput(bdev);
 }
 
 bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info,
-- 
2.30.2


  parent reply	other threads:[~2021-07-21 15:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21 15:35 fixes and cleanups for block_device refcounting Christoph Hellwig
2021-07-21 15:35 ` [PATCH 1/8] block: delay freeing the gendisk Christoph Hellwig
2021-07-22  2:05   ` Ming Lei
2021-07-21 15:35 ` [PATCH 2/8] block: assert the locking state in delete_partition Christoph Hellwig
2021-07-22  2:06   ` Ming Lei
2021-07-21 15:35 ` [PATCH 3/8] block: grab a device model reference in blkdev_get_no_open Christoph Hellwig
2021-07-22  2:47   ` Ming Lei
2021-07-21 15:35 ` [PATCH 4/8] block: don't grab a reference to the whole device in blkdev_get_part Christoph Hellwig
2021-07-21 15:35 ` Christoph Hellwig [this message]
2021-07-21 16:15   ` [PATCH 5/8] btrfs: no need to grab a reference to disk->part0 David Sterba
2021-07-21 15:35 ` [PATCH 6/8] loop: don't grab a reference to the block device Christoph Hellwig
2021-07-21 15:35 ` [PATCH 7/8] block: remove bdgrab Christoph Hellwig
2021-07-21 15:35 ` [PATCH 8/8] block: remove bdget/bdput Christoph Hellwig
2021-07-21 20:52 ` fixes and cleanups for block_device refcounting Josef Bacik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210721153523.103818-6-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.