Use the folio APIs throughout and remove a PAGE_SIZE assumption. Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> --- fs/ext4/inode.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 727aa2e51a9d..9b2c21d0e1f3 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -136,7 +136,7 @@ static inline int ext4_begin_ordered_truncate(struct inode *inode, new_size); } -static int __ext4_journalled_writepage(struct page *page, unsigned int len); +static int __ext4_journalled_writepage(struct folio *folio, unsigned int len); static int ext4_meta_trans_blocks(struct inode *inode, int lblocks, int pextents); @@ -1891,10 +1891,10 @@ int ext4_da_get_block_prep(struct inode *inode, sector_t iblock, return 0; } -static int __ext4_journalled_writepage(struct page *page, +static int __ext4_journalled_writepage(struct folio *folio, unsigned int len) { - struct address_space *mapping = page->mapping; + struct address_space *mapping = folio->mapping; struct inode *inode = mapping->host; handle_t *handle = NULL; int ret = 0, err = 0; @@ -1902,37 +1902,38 @@ static int __ext4_journalled_writepage(struct page *page, struct buffer_head *inode_bh = NULL; loff_t size; - ClearPageChecked(page); + folio_clear_checked(folio); if (inline_data) { - BUG_ON(page->index != 0); + BUG_ON(folio->index != 0); BUG_ON(len > ext4_get_max_inline_size(inode)); - inode_bh = ext4_journalled_write_inline_data(inode, len, page); + inode_bh = ext4_journalled_write_inline_data(inode, len, + &folio->page); if (inode_bh == NULL) goto out; } /* - * We need to release the page lock before we start the - * journal, so grab a reference so the page won't disappear + * We need to release the folio lock before we start the + * journal, so grab a reference so the folio won't disappear * out from under us. */ - get_page(page); - unlock_page(page); + folio_get(folio); + folio_unlock(folio); handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, ext4_writepage_trans_blocks(inode)); if (IS_ERR(handle)) { ret = PTR_ERR(handle); - put_page(page); + folio_put(folio); goto out_no_pagelock; } BUG_ON(!ext4_handle_valid(handle)); - lock_page(page); - put_page(page); + folio_lock(folio); + folio_put(folio); size = i_size_read(inode); - if (page->mapping != mapping || page_offset(page) > size) { - /* The page got truncated from under us */ + if (folio->mapping != mapping || folio_pos(folio) > size) { + /* The folio got truncated from under us */ ext4_journal_stop(handle); ret = 0; goto out; @@ -1941,12 +1942,11 @@ static int __ext4_journalled_writepage(struct page *page, if (inline_data) { ret = ext4_mark_inode_dirty(handle, inode); } else { - struct buffer_head *page_bufs = page_buffers(page); + struct buffer_head *page_bufs = folio_buffers(folio); - if (page->index == size >> PAGE_SHIFT) - len = size & ~PAGE_MASK; - else - len = PAGE_SIZE; + len = folio_size(folio); + if (folio_pos(folio) + len > size) + len = size - folio_pos(folio); ret = ext4_walk_page_buffers(handle, inode, page_bufs, 0, len, NULL, do_journal_get_write_access); @@ -1956,7 +1956,7 @@ static int __ext4_journalled_writepage(struct page *page, } if (ret == 0) ret = err; - err = ext4_jbd2_inode_add_write(handle, inode, page_offset(page), len); + err = ext4_jbd2_inode_add_write(handle, inode, folio_pos(folio), len); if (ret == 0) ret = err; EXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid; @@ -1966,7 +1966,7 @@ static int __ext4_journalled_writepage(struct page *page, ext4_set_inode_state(inode, EXT4_STATE_JDATA); out: - unlock_page(page); + folio_unlock(folio); out_no_pagelock: brelse(inode_bh); return ret; @@ -2086,7 +2086,7 @@ static int ext4_writepage(struct page *page, * It's mmapped pagecache. Add buffers and journal it. There * doesn't seem much point in redirtying the folio here. */ - return __ext4_journalled_writepage(page, len); + return __ext4_journalled_writepage(folio, len); ext4_io_submit_init(&io_submit, wbc); io_submit.io_end = ext4_init_io_end(inode, GFP_NOFS); -- 2.35.1