Commit 6b87fbe4 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Theodore Ts'o

ext4: Convert ext4_read_inline_page() to ext4_read_inline_folio()

All callers now have a folio, so pass it and use it.  The folio may
be large, although I doubt we'll want to use a large folio for an
inline file.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarTheodore Ts'o <tytso@mit.edu>
Link: https://lore.kernel.org/r/20230324180129.1220691-15-willy@infradead.orgSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 9a9d01f0
...@@ -467,16 +467,16 @@ static int ext4_destroy_inline_data_nolock(handle_t *handle, ...@@ -467,16 +467,16 @@ static int ext4_destroy_inline_data_nolock(handle_t *handle,
return error; return error;
} }
static int ext4_read_inline_page(struct inode *inode, struct page *page) static int ext4_read_inline_folio(struct inode *inode, struct folio *folio)
{ {
void *kaddr; void *kaddr;
int ret = 0; int ret = 0;
size_t len; size_t len;
struct ext4_iloc iloc; struct ext4_iloc iloc;
BUG_ON(!PageLocked(page)); BUG_ON(!folio_test_locked(folio));
BUG_ON(!ext4_has_inline_data(inode)); BUG_ON(!ext4_has_inline_data(inode));
BUG_ON(page->index); BUG_ON(folio->index);
if (!EXT4_I(inode)->i_inline_off) { if (!EXT4_I(inode)->i_inline_off) {
ext4_warning(inode->i_sb, "inode %lu doesn't have inline data.", ext4_warning(inode->i_sb, "inode %lu doesn't have inline data.",
...@@ -489,12 +489,13 @@ static int ext4_read_inline_page(struct inode *inode, struct page *page) ...@@ -489,12 +489,13 @@ static int ext4_read_inline_page(struct inode *inode, struct page *page)
goto out; goto out;
len = min_t(size_t, ext4_get_inline_size(inode), i_size_read(inode)); len = min_t(size_t, ext4_get_inline_size(inode), i_size_read(inode));
kaddr = kmap_atomic(page); BUG_ON(len > PAGE_SIZE);
kaddr = kmap_local_folio(folio, 0);
ret = ext4_read_inline_data(inode, kaddr, len, &iloc); ret = ext4_read_inline_data(inode, kaddr, len, &iloc);
flush_dcache_page(page); flush_dcache_folio(folio);
kunmap_atomic(kaddr); kunmap_local(kaddr);
zero_user_segment(page, len, PAGE_SIZE); folio_zero_segment(folio, len, folio_size(folio));
SetPageUptodate(page); folio_mark_uptodate(folio);
brelse(iloc.bh); brelse(iloc.bh);
out: out:
...@@ -516,7 +517,7 @@ int ext4_readpage_inline(struct inode *inode, struct folio *folio) ...@@ -516,7 +517,7 @@ int ext4_readpage_inline(struct inode *inode, struct folio *folio)
* So for all the other pages, just set them uptodate. * So for all the other pages, just set them uptodate.
*/ */
if (!folio->index) if (!folio->index)
ret = ext4_read_inline_page(inode, &folio->page); ret = ext4_read_inline_folio(inode, folio);
else if (!folio_test_uptodate(folio)) { else if (!folio_test_uptodate(folio)) {
folio_zero_segment(folio, 0, folio_size(folio)); folio_zero_segment(folio, 0, folio_size(folio));
folio_mark_uptodate(folio); folio_mark_uptodate(folio);
...@@ -581,7 +582,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping, ...@@ -581,7 +582,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
from = 0; from = 0;
to = ext4_get_inline_size(inode); to = ext4_get_inline_size(inode);
if (!folio_test_uptodate(folio)) { if (!folio_test_uptodate(folio)) {
ret = ext4_read_inline_page(inode, &folio->page); ret = ext4_read_inline_folio(inode, folio);
if (ret < 0) if (ret < 0)
goto out; goto out;
} }
...@@ -707,7 +708,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping, ...@@ -707,7 +708,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
} }
if (!folio_test_uptodate(folio)) { if (!folio_test_uptodate(folio)) {
ret = ext4_read_inline_page(inode, &folio->page); ret = ext4_read_inline_folio(inode, folio);
if (ret < 0) { if (ret < 0) {
folio_unlock(folio); folio_unlock(folio);
folio_put(folio); folio_put(folio);
...@@ -864,7 +865,7 @@ static int ext4_da_convert_inline_data_to_extent(struct address_space *mapping, ...@@ -864,7 +865,7 @@ static int ext4_da_convert_inline_data_to_extent(struct address_space *mapping,
inline_size = ext4_get_inline_size(inode); inline_size = ext4_get_inline_size(inode);
if (!folio_test_uptodate(folio)) { if (!folio_test_uptodate(folio)) {
ret = ext4_read_inline_page(inode, &folio->page); ret = ext4_read_inline_folio(inode, folio);
if (ret < 0) if (ret < 0)
goto out; goto out;
} }
...@@ -957,7 +958,7 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping, ...@@ -957,7 +958,7 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
} }
if (!folio_test_uptodate(folio)) { if (!folio_test_uptodate(folio)) {
ret = ext4_read_inline_page(inode, &folio->page); ret = ext4_read_inline_folio(inode, folio);
if (ret < 0) if (ret < 0)
goto out_release_page; goto out_release_page;
} }
......
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