Commit 4ed9b598 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Theodore Ts'o

ext4: Convert ext4_da_convert_inline_data_to_extent() to use a folio

Saves a number of calls to compound_head().
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20230324180129.1220691-13-willy@infradead.orgSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent f8f8c89f
......@@ -848,10 +848,11 @@ static int ext4_da_convert_inline_data_to_extent(struct address_space *mapping,
void **fsdata)
{
int ret = 0, inline_size;
struct page *page;
struct folio *folio;
page = grab_cache_page_write_begin(mapping, 0);
if (!page)
folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN,
mapping_gfp_mask(mapping));
if (!folio)
return -ENOMEM;
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);
if (!PageUptodate(page)) {
ret = ext4_read_inline_page(inode, page);
if (!folio_test_uptodate(folio)) {
ret = ext4_read_inline_page(inode, &folio->page);
if (ret < 0)
goto out;
}
ret = __block_write_begin(page, 0, inline_size,
ret = __block_write_begin(&folio->page, 0, inline_size,
ext4_da_get_block_prep);
if (ret) {
up_read(&EXT4_I(inode)->xattr_sem);
unlock_page(page);
put_page(page);
folio_unlock(folio);
folio_put(folio);
ext4_truncate_failed_write(inode);
return ret;
}
SetPageDirty(page);
SetPageUptodate(page);
folio_mark_dirty(folio);
folio_mark_uptodate(folio);
ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
*fsdata = (void *)CONVERT_INLINE_DATA;
out:
up_read(&EXT4_I(inode)->xattr_sem);
if (page) {
unlock_page(page);
put_page(page);
if (folio) {
folio_unlock(folio);
folio_put(folio);
}
return ret;
}
......
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