ext4: Convert ext4_da_convert_inline_data_to_extent() to use a folio

Saves a number of calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20230324180129.1220691-13-willy@infradead.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Matthew Wilcox 2023-03-24 18:01:12 +00:00 committed by Theodore Ts'o
parent f8f8c89f59
commit 4ed9b598ac
1 changed files with 14 additions and 13 deletions

View File

@ -848,10 +848,11 @@ static int ext4_da_convert_inline_data_to_extent(struct address_space *mapping,
void **fsdata) void **fsdata)
{ {
int ret = 0, inline_size; int ret = 0, inline_size;
struct page *page; struct folio *folio;
page = grab_cache_page_write_begin(mapping, 0); folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN,
if (!page) mapping_gfp_mask(mapping));
if (!folio)
return -ENOMEM; return -ENOMEM;
down_read(&EXT4_I(inode)->xattr_sem); down_read(&EXT4_I(inode)->xattr_sem);
@ -862,32 +863,32 @@ 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 (!PageUptodate(page)) { if (!folio_test_uptodate(folio)) {
ret = ext4_read_inline_page(inode, page); ret = ext4_read_inline_page(inode, &folio->page);
if (ret < 0) if (ret < 0)
goto out; goto out;
} }
ret = __block_write_begin(page, 0, inline_size, ret = __block_write_begin(&folio->page, 0, inline_size,
ext4_da_get_block_prep); ext4_da_get_block_prep);
if (ret) { if (ret) {
up_read(&EXT4_I(inode)->xattr_sem); up_read(&EXT4_I(inode)->xattr_sem);
unlock_page(page); folio_unlock(folio);
put_page(page); folio_put(folio);
ext4_truncate_failed_write(inode); ext4_truncate_failed_write(inode);
return ret; return ret;
} }
SetPageDirty(page); folio_mark_dirty(folio);
SetPageUptodate(page); folio_mark_uptodate(folio);
ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA); ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
*fsdata = (void *)CONVERT_INLINE_DATA; *fsdata = (void *)CONVERT_INLINE_DATA;
out: out:
up_read(&EXT4_I(inode)->xattr_sem); up_read(&EXT4_I(inode)->xattr_sem);
if (page) { if (folio) {
unlock_page(page); folio_unlock(folio);
put_page(page); folio_put(folio);
} }
return ret; return ret;
} }