diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2024-04-16 23:58:48 -0400 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2024-08-07 11:31:58 +0200 |
commit | 8eb835a1366f52d335aae7c2acff9c1bd57fb227 (patch) | |
tree | 71b5dbd9ec29ce3326a402bf95b636055da95d04 | |
parent | 0551bc716e830e36c16c70282bc4134e2f3ec821 (diff) |
fs: Convert block_write_begin() to use a folio
Use the folio APIs to retrieve the folio from the page cache and
manipulate it. Saves a few conversions between pages & folios.
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
-rw-r--r-- | fs/buffer.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/fs/buffer.c b/fs/buffer.c index e55ad471c530..a9aeb04da398 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2225,21 +2225,22 @@ int block_write_begin(struct address_space *mapping, loff_t pos, unsigned len, struct page **pagep, get_block_t *get_block) { pgoff_t index = pos >> PAGE_SHIFT; - struct page *page; + struct folio *folio; int status; - page = grab_cache_page_write_begin(mapping, index); - if (!page) - return -ENOMEM; + folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN, + mapping_gfp_mask(mapping)); + if (IS_ERR(folio)) + return PTR_ERR(folio); - status = __block_write_begin(page, pos, len, get_block); + status = __block_write_begin_int(folio, pos, len, get_block, NULL); if (unlikely(status)) { - unlock_page(page); - put_page(page); - page = NULL; + folio_unlock(folio); + folio_put(folio); + folio = NULL; } - *pagep = page; + *pagep = &folio->page; return status; } EXPORT_SYMBOL(block_write_begin); |