Commit 9b320229 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: convert __extent_writepage() to be completely folio based

Now that we've gotten most of the helpers updated to only take a folio,
update __extent_writepage to only deal in folios.
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent c1deaa14
...@@ -1519,11 +1519,10 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode, ...@@ -1519,11 +1519,10 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode,
* Return 0 if everything goes well. * Return 0 if everything goes well.
* Return <0 for error. * Return <0 for error.
*/ */
static int __extent_writepage(struct page *page, struct btrfs_bio_ctrl *bio_ctrl) static int __extent_writepage(struct folio *folio, struct btrfs_bio_ctrl *bio_ctrl)
{ {
struct folio *folio = page_folio(page); struct inode *inode = folio->mapping->host;
struct inode *inode = page->mapping->host; const u64 page_start = folio_pos(folio);
const u64 page_start = page_offset(page);
int ret; int ret;
int nr = 0; int nr = 0;
size_t pg_offset; size_t pg_offset;
...@@ -1532,24 +1531,24 @@ static int __extent_writepage(struct page *page, struct btrfs_bio_ctrl *bio_ctrl ...@@ -1532,24 +1531,24 @@ static int __extent_writepage(struct page *page, struct btrfs_bio_ctrl *bio_ctrl
trace___extent_writepage(folio, inode, bio_ctrl->wbc); trace___extent_writepage(folio, inode, bio_ctrl->wbc);
WARN_ON(!PageLocked(page)); WARN_ON(!folio_test_locked(folio));
pg_offset = offset_in_page(i_size); pg_offset = offset_in_folio(folio, i_size);
if (page->index > end_index || if (folio->index > end_index ||
(page->index == end_index && !pg_offset)) { (folio->index == end_index && !pg_offset)) {
folio_invalidate(folio, 0, folio_size(folio)); folio_invalidate(folio, 0, folio_size(folio));
folio_unlock(folio); folio_unlock(folio);
return 0; return 0;
} }
if (page->index == end_index) if (folio->index == end_index)
memzero_page(page, pg_offset, PAGE_SIZE - pg_offset); folio_zero_range(folio, pg_offset, folio_size(folio) - pg_offset);
ret = set_page_extent_mapped(page); ret = set_folio_extent_mapped(folio);
if (ret < 0) if (ret < 0)
goto done; goto done;
ret = writepage_delalloc(BTRFS_I(inode), page, bio_ctrl->wbc); ret = writepage_delalloc(BTRFS_I(inode), &folio->page, bio_ctrl->wbc);
if (ret == 1) if (ret == 1)
return 0; return 0;
if (ret) if (ret)
...@@ -1565,13 +1564,13 @@ static int __extent_writepage(struct page *page, struct btrfs_bio_ctrl *bio_ctrl ...@@ -1565,13 +1564,13 @@ static int __extent_writepage(struct page *page, struct btrfs_bio_ctrl *bio_ctrl
done: done:
if (nr == 0) { if (nr == 0) {
/* make sure the mapping tag for page dirty gets cleared */ /* make sure the mapping tag for page dirty gets cleared */
set_page_writeback(page); folio_start_writeback(folio);
end_page_writeback(page); folio_end_writeback(folio);
} }
if (ret) { if (ret) {
btrfs_mark_ordered_io_finished(BTRFS_I(inode), page, page_start, btrfs_mark_ordered_io_finished(BTRFS_I(inode), &folio->page,
PAGE_SIZE, !ret); page_start, PAGE_SIZE, !ret);
mapping_set_error(page->mapping, ret); mapping_set_error(folio->mapping, ret);
} }
btrfs_folio_end_all_writers(inode_to_fs_info(inode), folio); btrfs_folio_end_all_writers(inode_to_fs_info(inode), folio);
...@@ -2228,7 +2227,7 @@ static int extent_write_cache_pages(struct address_space *mapping, ...@@ -2228,7 +2227,7 @@ static int extent_write_cache_pages(struct address_space *mapping,
continue; continue;
} }
ret = __extent_writepage(&folio->page, bio_ctrl); ret = __extent_writepage(folio, bio_ctrl);
if (ret < 0) { if (ret < 0) {
done = 1; done = 1;
break; break;
......
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