ext4: Convert ext4_try_to_write_inline_data() 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-12-willy@infradead.org Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
83eba701cf
commit
f8f8c89f59
|
@ -653,8 +653,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
handle_t *handle;
|
handle_t *handle;
|
||||||
unsigned int flags;
|
struct folio *folio;
|
||||||
struct page *page;
|
|
||||||
struct ext4_iloc iloc;
|
struct ext4_iloc iloc;
|
||||||
|
|
||||||
if (pos + len > ext4_get_max_inline_size(inode))
|
if (pos + len > ext4_get_max_inline_size(inode))
|
||||||
|
@ -691,28 +690,27 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
flags = memalloc_nofs_save();
|
folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
|
||||||
page = grab_cache_page_write_begin(mapping, 0);
|
mapping_gfp_mask(mapping));
|
||||||
memalloc_nofs_restore(flags);
|
if (!folio) {
|
||||||
if (!page) {
|
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
*pagep = page;
|
*pagep = &folio->page;
|
||||||
down_read(&EXT4_I(inode)->xattr_sem);
|
down_read(&EXT4_I(inode)->xattr_sem);
|
||||||
if (!ext4_has_inline_data(inode)) {
|
if (!ext4_has_inline_data(inode)) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
unlock_page(page);
|
folio_unlock(folio);
|
||||||
put_page(page);
|
folio_put(folio);
|
||||||
goto out_up_read;
|
goto out_up_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
unlock_page(page);
|
folio_unlock(folio);
|
||||||
put_page(page);
|
folio_put(folio);
|
||||||
goto out_up_read;
|
goto out_up_read;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue