]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
f2fs: Use a folio in f2fs_cache_compressed_page()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 31 Mar 2025 20:12:38 +0000 (21:12 +0100)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 28 Apr 2025 15:26:45 +0000 (15:26 +0000)
Look up a folio instead of a page, and if that fails, allocate a folio.
Removes five calls to compound_head(), one of the last few references to
add_to_page_cache_lru() and honours the cpuset_do_page_mem_spread()
setting.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/compress.c

index ed889ed4fd5c2c556d1dc8279b3c5b599ab3fff6..4c91038b3f6f7cabeb9b4632c3bce0cc180b1d60 100644 (file)
@@ -1928,7 +1928,7 @@ void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi,
 void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
                                                nid_t ino, block_t blkaddr)
 {
-       struct page *cpage;
+       struct folio *cfolio;
        int ret;
 
        if (!test_opt(sbi, COMPRESS_CACHE))
@@ -1940,28 +1940,28 @@ void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
        if (!f2fs_available_free_memory(sbi, COMPRESS_PAGE))
                return;
 
-       cpage = find_get_page(COMPRESS_MAPPING(sbi), blkaddr);
-       if (cpage) {
-               f2fs_put_page(cpage, 0);
+       cfolio = filemap_get_folio(COMPRESS_MAPPING(sbi), blkaddr);
+       if (!IS_ERR(cfolio)) {
+               f2fs_folio_put(cfolio, false);
                return;
        }
 
-       cpage = alloc_page(__GFP_NOWARN | __GFP_IO);
-       if (!cpage)
+       cfolio = filemap_alloc_folio(__GFP_NOWARN | __GFP_IO, 0);
+       if (!cfolio)
                return;
 
-       ret = add_to_page_cache_lru(cpage, COMPRESS_MAPPING(sbi),
+       ret = filemap_add_folio(COMPRESS_MAPPING(sbi), cfolio,
                                                blkaddr, GFP_NOFS);
        if (ret) {
-               f2fs_put_page(cpage, 0);
+               f2fs_folio_put(cfolio, false);
                return;
        }
 
-       set_page_private_data(cpage, ino);
+       set_page_private_data(&cfolio->page, ino);
 
-       memcpy(page_address(cpage), page_address(page), PAGE_SIZE);
-       SetPageUptodate(cpage);
-       f2fs_put_page(cpage, 1);
+       memcpy(folio_address(cfolio), page_address(page), PAGE_SIZE);
+       folio_mark_uptodate(cfolio);
+       f2fs_folio_put(cfolio, true);
 }
 
 bool f2fs_load_compressed_page(struct f2fs_sb_info *sbi, struct page *page,