Commit 9a9d01f0 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Theodore Ts'o

ext4: Convert ext4_da_write_inline_data_begin() 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-14-willy@infradead.orgSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 4ed9b598
...@@ -909,10 +909,9 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping, ...@@ -909,10 +909,9 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
{ {
int ret; int ret;
handle_t *handle; handle_t *handle;
struct page *page; struct folio *folio;
struct ext4_iloc iloc; struct ext4_iloc iloc;
int retries = 0; int retries = 0;
unsigned int flags;
ret = ext4_get_inode_loc(inode, &iloc); ret = ext4_get_inode_loc(inode, &iloc);
if (ret) if (ret)
...@@ -944,10 +943,9 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping, ...@@ -944,10 +943,9 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
* We cannot recurse into the filesystem as the transaction * We cannot recurse into the filesystem as the transaction
* is already started. * is already started.
*/ */
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_journal; goto out_journal;
} }
...@@ -958,8 +956,8 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping, ...@@ -958,8 +956,8 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
goto out_release_page; goto out_release_page;
} }
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_release_page; goto out_release_page;
} }
...@@ -969,13 +967,13 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping, ...@@ -969,13 +967,13 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
goto out_release_page; goto out_release_page;
up_read(&EXT4_I(inode)->xattr_sem); up_read(&EXT4_I(inode)->xattr_sem);
*pagep = page; *pagep = &folio->page;
brelse(iloc.bh); brelse(iloc.bh);
return 1; return 1;
out_release_page: out_release_page:
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);
out_journal: out_journal:
ext4_journal_stop(handle); ext4_journal_stop(handle);
out: out:
......
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