Commit 778b8785 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: don't redirty locked_page in run_delalloc_zoned

extent_write_locked_range currently expects that either all or no
pages are dirty when it is called.  Bur run_delalloc_zoned is called
directly in the writepages path, and has the dirty bit cleared only
for locked_page and which the extent_write_cache_pages currently
operates.  It currently works around this by redirtying locked_page,
but that is a bit inefficient and cumbersome.  Pass a locked_page
argument to run_delalloc_zoned so that clearing the dirty bit can
be skipped on just that page.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 6e144bf1
......@@ -2161,8 +2161,9 @@ static int extent_write_cache_pages(struct address_space *mapping,
* already been ran (aka, ordered extent inserted) and all pages are still
* locked.
*/
void extent_write_locked_range(struct inode *inode, u64 start, u64 end,
struct writeback_control *wbc, bool pages_dirty)
void extent_write_locked_range(struct inode *inode, struct page *locked_page,
u64 start, u64 end, struct writeback_control *wbc,
bool pages_dirty)
{
bool found_error = false;
int ret = 0;
......@@ -2189,7 +2190,7 @@ void extent_write_locked_range(struct inode *inode, u64 start, u64 end,
page = find_get_page(mapping, cur >> PAGE_SHIFT);
ASSERT(PageLocked(page));
if (pages_dirty) {
if (pages_dirty && page != locked_page) {
ASSERT(PageDirty(page));
clear_page_dirty_for_io(page);
}
......
......@@ -177,8 +177,9 @@ int try_release_extent_mapping(struct page *page, gfp_t mask);
int try_release_extent_buffer(struct page *page);
int btrfs_read_folio(struct file *file, struct folio *folio);
void extent_write_locked_range(struct inode *inode, u64 start, u64 end,
struct writeback_control *wbc, bool pages_dirty);
void extent_write_locked_range(struct inode *inode, struct page *locked_page,
u64 start, u64 end, struct writeback_control *wbc,
bool pages_dirty);
int extent_writepages(struct address_space *mapping,
struct writeback_control *wbc);
int btree_write_cache_pages(struct address_space *mapping,
......
......@@ -1105,7 +1105,8 @@ static void submit_uncompressed_range(struct btrfs_inode *inode,
/* All pages will be unlocked, including @locked_page */
wbc_attach_fdatawrite_inode(&wbc, &inode->vfs_inode);
extent_write_locked_range(&inode->vfs_inode, start, end, &wbc, false);
extent_write_locked_range(&inode->vfs_inode, NULL, start, end, &wbc,
false);
wbc_detach_inode(&wbc);
}
......@@ -1719,7 +1720,6 @@ static noinline int run_delalloc_zoned(struct btrfs_inode *inode,
{
u64 done_offset = end;
int ret;
bool locked_page_done = false;
while (start <= end) {
ret = cow_file_range(inode, locked_page, start, end, &done_offset,
......@@ -1727,13 +1727,8 @@ static noinline int run_delalloc_zoned(struct btrfs_inode *inode,
if (ret)
return ret;
if (!locked_page_done) {
__set_page_dirty_nobuffers(locked_page);
account_page_redirty(locked_page);
}
locked_page_done = true;
extent_write_locked_range(&inode->vfs_inode, start, done_offset,
wbc, true);
extent_write_locked_range(&inode->vfs_inode, locked_page, start,
done_offset, wbc, true);
start = done_offset + 1;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment