From: Christoph Hellwig <hch@lst.de>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>
Cc: Matthew Wilcox <willy@infradead.org>,
linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 22/23] btrfs: fix zoned handling in submit_uncompressed_range
Date: Wed, 28 Jun 2023 17:31:43 +0200 [thread overview]
Message-ID: <20230628153144.22834-23-hch@lst.de> (raw)
In-Reply-To: <20230628153144.22834-1-hch@lst.de>
For zoned file systems we need to use run_delalloc_zoned to submit
writeback, as we need to write out partial allocations when running into
zone active limits.
submit_uncompressed_range currently always calls cow_file_range to
allocate blocks and thus misses the active zone limits handling. Fix
this by passing the pages_dirty argument to run_delalloc_zoned and always
using it from submit_uncompressed_range as it does the right thing for
zoned and non-zone file systems.
To account for the fact that run_delalloc_zoned is now also used for
non-zoned file systems rename it to run_delalloc_cow, and add comment
describing it.
Fixes: 42c011000963 ("btrfs: zoned: introduce dedicated data write path for zoned filesystems")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/btrfs/inode.c | 52 +++++++++++++++++++-----------------------------
1 file changed, 20 insertions(+), 32 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ae5166d33253a5..2079bf48629b59 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -125,12 +125,10 @@ static struct kmem_cache *btrfs_inode_cachep;
static int btrfs_setsize(struct inode *inode, struct iattr *attr);
static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback);
-#define CFR_KEEP_LOCKED (1 << 0)
-#define CFR_NOINLINE (1 << 1)
-static noinline int cow_file_range(struct btrfs_inode *inode,
- struct page *locked_page,
- u64 start, u64 end, u64 *done_offset,
- u32 flags);
+static noinline int run_delalloc_cow(struct btrfs_inode *inode,
+ struct page *locked_page, u64 start,
+ u64 end, struct writeback_control *wbc,
+ bool pages_dirty);
static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start,
u64 len, u64 orig_start, u64 block_start,
u64 block_len, u64 orig_block_len,
@@ -1071,19 +1069,9 @@ static void submit_uncompressed_range(struct btrfs_inode *inode,
.no_cgroup_owner = 1,
};
- /*
- * Call cow_file_range() to run the delalloc range directly, since we
- * won't go to NOCOW or async path again.
- *
- * Also we call cow_file_range() with @unlock_page == 0, so that we
- * can directly submit them without interruption.
- */
- ret = cow_file_range(inode, locked_page, start, end, NULL,
- CFR_KEEP_LOCKED);
- /* Inline extent inserted, page gets unlocked and everything is done */
- if (ret == 1)
- return;
-
+ wbc_attach_fdatawrite_inode(&wbc, &inode->vfs_inode);
+ ret = run_delalloc_cow(inode, locked_page, start, end, &wbc, false);
+ wbc_detach_inode(&wbc);
if (ret < 0) {
btrfs_cleanup_ordered_extents(inode, locked_page, start, end - start + 1);
if (locked_page) {
@@ -1100,14 +1088,7 @@ static void submit_uncompressed_range(struct btrfs_inode *inode,
mapping_set_error(locked_page->mapping, ret);
unlock_page(locked_page);
}
- return;
}
-
- /* All pages will be unlocked, including @locked_page */
- wbc_attach_fdatawrite_inode(&wbc, &inode->vfs_inode);
- extent_write_locked_range(&inode->vfs_inode, NULL, start, end, &wbc,
- false);
- wbc_detach_inode(&wbc);
}
static void submit_one_async_extent(struct async_chunk *async_chunk,
@@ -1290,6 +1271,8 @@ static u64 get_extent_allocation_hint(struct btrfs_inode *inode, u64 start,
* btrfs_cleanup_ordered_extents(). See btrfs_run_delalloc_range() for
* example.
*/
+#define CFR_KEEP_LOCKED (1 << 0)
+#define CFR_NOINLINE (1 << 1)
static noinline int cow_file_range(struct btrfs_inode *inode,
struct page *locked_page, u64 start, u64 end,
u64 *done_offset, u32 flags)
@@ -1715,9 +1698,14 @@ static bool run_delalloc_compressed(struct btrfs_inode *inode,
return true;
}
-static noinline int run_delalloc_zoned(struct btrfs_inode *inode,
- struct page *locked_page, u64 start,
- u64 end, struct writeback_control *wbc)
+/*
+ * Run the delalloc range from start to end, and write back any dirty pages
+ * covered by the range.
+ */
+static noinline int run_delalloc_cow(struct btrfs_inode *inode,
+ struct page *locked_page, u64 start,
+ u64 end, struct writeback_control *wbc,
+ bool pages_dirty)
{
u64 done_offset = end;
int ret;
@@ -1727,9 +1715,8 @@ static noinline int run_delalloc_zoned(struct btrfs_inode *inode,
&done_offset, CFR_KEEP_LOCKED);
if (ret)
return ret;
-
extent_write_locked_range(&inode->vfs_inode, locked_page, start,
- done_offset, wbc, true);
+ done_offset, wbc, pages_dirty);
start = done_offset + 1;
}
@@ -2295,7 +2282,8 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
return 1;
if (zoned)
- ret = run_delalloc_zoned(inode, locked_page, start, end, wbc);
+ ret = run_delalloc_cow(inode, locked_page, start, end, wbc,
+ true);
else
ret = cow_file_range(inode, locked_page, start, end, NULL, 0);
--
2.39.2
next prev parent reply other threads:[~2023-06-28 15:33 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-28 15:31 btrfs compressed writeback cleanups Christoph Hellwig
2023-06-28 15:31 ` [PATCH 01/23] btrfs: pass a flags argument to cow_file_range Christoph Hellwig
2023-07-04 8:47 ` Johannes Thumshirn
2023-07-20 11:22 ` David Sterba
2023-07-20 13:25 ` Christoph Hellwig
2023-06-28 15:31 ` [PATCH 02/23] btrfs: don't create inline extents in fallback_to_cow Christoph Hellwig
2023-06-28 15:31 ` [PATCH 03/23] btrfs: split page locking out of __process_pages_contig Christoph Hellwig
2023-06-28 15:31 ` [PATCH 04/23] btrfs: remove btrfs_writepage_endio_finish_ordered Christoph Hellwig
2023-07-04 8:50 ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 05/23] btrfs: remove end_extent_writepage Christoph Hellwig
2023-06-28 15:31 ` [PATCH 06/23] btrfs: reduce debug spam from submit_compressed_extents Christoph Hellwig
2023-07-04 8:54 ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 07/23] btrfs: remove the return value from submit_uncompressed_range Christoph Hellwig
2023-07-04 8:56 ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 08/23] btrfs: remove the return value from extent_write_locked_range Christoph Hellwig
2023-07-04 8:56 ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 09/23] btrfs: improve the delalloc_to_write calculation in writepage_delalloc Christoph Hellwig
2023-06-28 15:31 ` [PATCH 10/23] btrfs: reduce the number of arguments to btrfs_run_delalloc_range Christoph Hellwig
2023-07-04 9:00 ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 11/23] btrfs: clean up the check for uncompressed ranges in submit_one_async_extent Christoph Hellwig
2023-07-04 9:07 ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 12/23] btrfs: don't clear async_chunk->inode in async_cow_start Christoph Hellwig
2023-06-28 15:31 ` [PATCH 13/23] btrfs: merge async_cow_start and compress_file_range Christoph Hellwig
2023-07-04 9:09 ` Johannes Thumshirn
2023-06-28 15:31 ` [PATCH 14/23] btrfs: merge submit_compressed_extents and async_cow_submit Christoph Hellwig
2023-06-28 15:31 ` [PATCH 15/23] btrfs: streamline compress_file_range Christoph Hellwig
2023-06-28 15:31 ` [PATCH 16/23] btrfs: further simplify the compress or not logic in compress_file_range Christoph Hellwig
2023-07-14 13:47 ` Josef Bacik
2023-06-28 15:31 ` [PATCH 17/23] btrfs: use a separate label for the incompressible case " Christoph Hellwig
2023-06-28 15:31 ` [PATCH 18/23] btrfs: share the code to free the page array " Christoph Hellwig
2023-06-28 15:31 ` [PATCH 19/23] btrfs: don't redirty pages " Christoph Hellwig
2023-07-20 11:41 ` David Sterba
2023-07-20 13:26 ` Christoph Hellwig
2023-06-28 15:31 ` [PATCH 20/23] btrfs: refactor the zoned device handling in cow_file_range Christoph Hellwig
2023-06-28 15:31 ` [PATCH 21/23] btrfs: don't redirty locked_page in run_delalloc_zoned Christoph Hellwig
2023-06-28 15:31 ` Christoph Hellwig [this message]
2023-06-28 15:31 ` [PATCH 23/23] mm: remove folio_account_redirty Christoph Hellwig
2023-06-28 15:45 ` Matthew Wilcox
2023-07-14 13:49 ` btrfs compressed writeback cleanups Josef Bacik
2023-07-20 11:47 ` David Sterba
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=20230628153144.22834-23-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 \
--cc=linux-fsdevel@vger.kernel.org \
--cc=willy@infradead.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;
as well as URLs for NNTP newsgroup(s).