From: Christoph Hellwig <hch@lst.de>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: [PATCH 4/6] btrfs: move dropping the bg reference out of submit_eb_page
Date: Mon, 15 May 2023 21:22:54 +0200 [thread overview]
Message-ID: <20230515192256.29006-5-hch@lst.de> (raw)
In-Reply-To: <20230515192256.29006-1-hch@lst.de>
Instead of putting the cached bg for zoned metadata writes in
submit_eb_page, let the btrfs_revert_meta_write_pointer and
btrfs_schedule_zone_finish_bg helpers consume it. This mirrors how the
reference to it is acquired in btrfs_check_meta_write_pointer and
isolated the extent_buffer writeback code from some of the zoned
device implementation details. It also avoids a reference roundtrip
for the case where btrfs_schedule_zone_finish_bg actually schedules
a zone_finish command.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/extent_io.c | 3 ---
fs/btrfs/zoned.c | 7 +++++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index d5937ed0962d38..1205b3a3147e7d 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1955,8 +1955,6 @@ static int submit_eb_page(struct page *page, struct writeback_control *wbc,
if (!lock_extent_buffer_for_io(eb, wbc)) {
btrfs_revert_meta_write_pointer(cache, eb);
- if (cache)
- btrfs_put_block_group(cache);
free_extent_buffer(eb);
return 0;
}
@@ -1965,7 +1963,6 @@ static int submit_eb_page(struct page *page, struct writeback_control *wbc,
* Implies write in zoned mode. Mark the last eb in a block group.
*/
btrfs_schedule_zone_finish_bg(cache, eb);
- btrfs_put_block_group(cache);
}
write_one_eb(eb, wbc);
free_extent_buffer(eb);
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index e4b8134ab70166..eed96ec35052a0 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1752,6 +1752,7 @@ void btrfs_revert_meta_write_pointer(struct btrfs_block_group *cache,
ASSERT(cache->meta_write_pointer == eb->start + eb->len);
cache->meta_write_pointer = eb->start;
+ btrfs_put_block_group(cache);
}
int btrfs_zoned_issue_zeroout(struct btrfs_device *device, u64 physical, u64 length)
@@ -2145,17 +2146,19 @@ void btrfs_schedule_zone_finish_bg(struct btrfs_block_group *bg,
struct extent_buffer *eb)
{
if (!test_bit(BLOCK_GROUP_FLAG_SEQUENTIAL_ZONE, &bg->runtime_flags) ||
- eb->start + eb->len * 2 <= bg->start + bg->zone_capacity)
+ eb->start + eb->len * 2 <= bg->start + bg->zone_capacity) {
+ btrfs_put_block_group(bg);
return;
+ }
if (WARN_ON(bg->zone_finish_work.func == btrfs_zone_finish_endio_workfn)) {
btrfs_err(bg->fs_info, "double scheduling of bg %llu zone finishing",
bg->start);
+ btrfs_put_block_group(bg);
return;
}
/* For the work */
- btrfs_get_block_group(bg);
atomic_inc(&eb->refs);
bg->last_eb = eb;
INIT_WORK(&bg->zone_finish_work, btrfs_zone_finish_endio_workfn);
--
2.39.2
next prev parent reply other threads:[~2023-05-15 19:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-15 19:22 simplify dirty buffer tracking Christoph Hellwig
2023-05-15 19:22 ` [PATCH 1/6] btrfs: use a linked list for tracking per-transaction/log dirty buffers Christoph Hellwig
2023-05-17 10:40 ` Filipe Manana
2023-05-17 12:21 ` Christoph Hellwig
2023-05-17 16:24 ` Filipe Manana
2023-05-17 16:37 ` Christoph Hellwig
2023-05-15 19:22 ` [PATCH 2/6] btrfs: remove convert_extent_bit Christoph Hellwig
2023-05-15 19:22 ` [PATCH 3/6] btrfs: directly wait for buffer writeback completion in btrfs_wait_buffers Christoph Hellwig
2023-05-15 19:22 ` Christoph Hellwig [this message]
2023-05-15 19:22 ` [PATCH 5/6] btrfs: move locking and write pointer checking into write_one_eb Christoph Hellwig
2023-05-15 19:22 ` [PATCH 6/6] btrfs: bypass filemap_fdatawrite_range in btrfs_write_buffers Christoph Hellwig
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=20230515192256.29006-5-hch@lst.de \
--to=hch@lst.de \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox