Commit 0b5a2543 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Theodore Ts'o

ext4: Use a folio in ext4_da_write_begin()

Remove a few calls to compound_head().
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20230324180129.1220691-23-willy@infradead.orgSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 02e4b04c
...@@ -2902,7 +2902,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, ...@@ -2902,7 +2902,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
struct page **pagep, void **fsdata) struct page **pagep, void **fsdata)
{ {
int ret, retries = 0; int ret, retries = 0;
struct page *page; struct folio *folio;
pgoff_t index; pgoff_t index;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
...@@ -2929,22 +2929,23 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, ...@@ -2929,22 +2929,23 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
} }
retry: retry:
page = grab_cache_page_write_begin(mapping, index); folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN,
if (!page) mapping_gfp_mask(mapping));
if (!folio)
return -ENOMEM; return -ENOMEM;
/* In case writeback began while the page was unlocked */ /* In case writeback began while the folio was unlocked */
wait_for_stable_page(page); folio_wait_stable(folio);
#ifdef CONFIG_FS_ENCRYPTION #ifdef CONFIG_FS_ENCRYPTION
ret = ext4_block_write_begin(page, pos, len, ret = ext4_block_write_begin(&folio->page, pos, len,
ext4_da_get_block_prep); ext4_da_get_block_prep);
#else #else
ret = __block_write_begin(page, pos, len, ext4_da_get_block_prep); ret = __block_write_begin(&folio->page, pos, len, ext4_da_get_block_prep);
#endif #endif
if (ret < 0) { if (ret < 0) {
unlock_page(page); folio_unlock(folio);
put_page(page); folio_put(folio);
/* /*
* block_write_begin may have instantiated a few blocks * block_write_begin may have instantiated a few blocks
* outside i_size. Trim these off again. Don't need * outside i_size. Trim these off again. Don't need
...@@ -2959,7 +2960,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, ...@@ -2959,7 +2960,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
return ret; return ret;
} }
*pagep = page; *pagep = &folio->page;
return ret; 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