diff options
author | Matthew Wilcox <willy@infradead.org> | 2023-03-24 18:01:22 +0000 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2023-04-06 13:39:52 -0400 |
commit | 0b5a254395dc6db5c38d89e606c0298ed4c9e984 (patch) | |
tree | 78812eb16be5d6b487d504357fe3ca5a5d75d185 | |
parent | 02e4b04c56d03a518b958783900b22f33c6643d6 (diff) |
ext4: Use a folio in ext4_da_write_begin()
Remove a few calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20230324180129.1220691-23-willy@infradead.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | fs/ext4/inode.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index bf1a19c09b5d..9e8afac5c82e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2902,7 +2902,7 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, struct page **pagep, void **fsdata) { int ret, retries = 0; - struct page *page; + struct folio *folio; pgoff_t index; struct inode *inode = mapping->host; @@ -2929,22 +2929,23 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping, } retry: - page = grab_cache_page_write_begin(mapping, index); - if (!page) + folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN, + mapping_gfp_mask(mapping)); + if (!folio) return -ENOMEM; - /* In case writeback began while the page was unlocked */ - wait_for_stable_page(page); + /* In case writeback began while the folio was unlocked */ + folio_wait_stable(folio); #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); #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 if (ret < 0) { - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); /* * block_write_begin may have instantiated a few blocks * outside i_size. Trim these off again. Don't need @@ -2959,7 +2960,7 @@ retry: return ret; } - *pagep = page; + *pagep = &folio->page; return ret; } |