From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
Naohiro Aota <naohiro.aota@wdc.com>,
linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org
Subject: [PATCH 6/9] btrfs: store a block_device in struct btrfs_ordered_extent
Date: Thu, 22 Jul 2021 09:53:59 +0200 [thread overview]
Message-ID: <20210722075402.983367-7-hch@lst.de> (raw)
In-Reply-To: <20210722075402.983367-1-hch@lst.de>
Store the block device instead of the gendisk in the btrfs_ordered_extent
structure intead of acquiring a reference to it later.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/inode.c | 2 +-
fs/btrfs/ordered-data.c | 2 --
fs/btrfs/ordered-data.h | 3 +--
fs/btrfs/zoned.c | 12 ++++--------
4 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8f60314c36c5..0117d867ecf8 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2992,7 +2992,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
goto out;
}
- if (ordered_extent->disk)
+ if (ordered_extent->bdev)
btrfs_rewrite_logical_zoned(ordered_extent);
btrfs_free_io_failure_record(inode, start, end);
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 6eb41b7c0c84..5c0f8481e25e 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -190,8 +190,6 @@ static int __btrfs_add_ordered_extent(struct btrfs_inode *inode, u64 file_offset
entry->truncated_len = (u64)-1;
entry->qgroup_rsv = ret;
entry->physical = (u64)-1;
- entry->disk = NULL;
- entry->partno = (u8)-1;
ASSERT(type == BTRFS_ORDERED_REGULAR ||
type == BTRFS_ORDERED_NOCOW ||
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
index 566472004edd..b2d88aba8420 100644
--- a/fs/btrfs/ordered-data.h
+++ b/fs/btrfs/ordered-data.h
@@ -145,8 +145,7 @@ struct btrfs_ordered_extent {
* command in a workqueue context
*/
u64 physical;
- struct gendisk *disk;
- u8 partno;
+ struct block_device *bdev;
};
/*
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 297c0b1c0634..907c2cc45c9c 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1349,8 +1349,7 @@ void btrfs_record_physical_zoned(struct inode *inode, u64 file_offset,
return;
ordered->physical = physical;
- ordered->disk = bio->bi_bdev->bd_disk;
- ordered->partno = bio->bi_bdev->bd_partno;
+ ordered->bdev = bio->bi_bdev;
btrfs_put_ordered_extent(ordered);
}
@@ -1362,18 +1361,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))
+ ASSERT(!bdev_is_partition(ordered->bdev));
+ if (WARN_ON(!ordered->bdev))
return;
- if (WARN_ON(btrfs_rmap_block(fs_info, orig_logical, bdev,
+ if (WARN_ON(btrfs_rmap_block(fs_info, orig_logical, ordered->bdev,
ordered->physical, &logical, &nr,
&stripe_len)))
goto out;
@@ -1402,7 +1399,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
next prev parent reply other threads:[~2021-07-22 7:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 7:53 fixes and cleanups for block_device refcounting v2 Christoph Hellwig
2021-07-22 7:53 ` [PATCH 1/9] block: delay freeing the gendisk Christoph Hellwig
2021-07-22 7:53 ` [PATCH 2/9] block: assert the locking state in delete_partition Christoph Hellwig
2021-07-22 18:38 ` Chaitanya Kulkarni
2021-07-22 7:53 ` [PATCH 3/9] block: unhash the whole device inode earlier Christoph Hellwig
2021-07-22 8:19 ` Ming Lei
2021-07-22 13:12 ` Christoph Hellwig
2021-07-22 7:53 ` [PATCH 4/9] block: allocate bd_meta_info later in add_partitions Christoph Hellwig
2021-07-22 8:32 ` Ming Lei
2021-07-22 7:53 ` [PATCH 5/9] block: change the refcounting for partitions Christoph Hellwig
2021-07-22 8:41 ` Ming Lei
2021-07-22 13:12 ` Christoph Hellwig
2021-07-22 7:53 ` Christoph Hellwig [this message]
2021-07-22 12:58 ` [PATCH 6/9] btrfs: store a block_device in struct btrfs_ordered_extent David Sterba
2021-07-22 13:04 ` Christoph Hellwig
2021-07-22 7:54 ` [PATCH 7/9] loop: don't grab a reference to the block device Christoph Hellwig
2021-07-22 8:57 ` Ming Lei
2021-07-22 18:40 ` Chaitanya Kulkarni
2021-07-22 7:54 ` [PATCH 8/9] block: remove bdgrab Christoph Hellwig
2021-07-22 7:54 ` [PATCH 9/9] block: remove bdput Christoph Hellwig
2021-07-22 18:40 ` Chaitanya Kulkarni
2021-07-28 1:39 ` fixes and cleanups for block_device refcounting v2 Jens Axboe
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=20210722075402.983367-7-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 \
--cc=naohiro.aota@wdc.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).