]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
cramfs: Convert cramfs_read_folio to use a folio
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 30 May 2024 20:20:55 +0000 (21:20 +0100)
committerChristian Brauner <brauner@kernel.org>
Fri, 31 May 2024 10:31:39 +0000 (12:31 +0200)
Remove the conversion back into a page and use the folio APIs throughout.
Remove the setting of PG_error instead of converting it; it is unused
by core code or by the rest of cramfs, so it serves no purpose here.
Use folio_end_read() to save an atomic operation and unify the two
exit paths.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20240530202110.2653630-4-willy@infradead.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/cramfs/inode.c

index 460690ca0174368d6dfbe346bfa51062a2eeae6a..547b703cf6d379ef517fedec4cb41bd9eebcf099 100644 (file)
@@ -811,19 +811,19 @@ out:
 
 static int cramfs_read_folio(struct file *file, struct folio *folio)
 {
-       struct page *page = &folio->page;
-       struct inode *inode = page->mapping->host;
+       struct inode *inode = folio->mapping->host;
        u32 maxblock;
        int bytes_filled;
        void *pgdata;
+       bool success = false;
 
        maxblock = (inode->i_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
        bytes_filled = 0;
-       pgdata = kmap_local_page(page);
+       pgdata = kmap_local_folio(folio, 0);
 
-       if (page->index < maxblock) {
+       if (folio->index < maxblock) {
                struct super_block *sb = inode->i_sb;
-               u32 blkptr_offset = OFFSET(inode) + page->index * 4;
+               u32 blkptr_offset = OFFSET(inode) + folio->index * 4;
                u32 block_ptr, block_start, block_len;
                bool uncompressed, direct;
 
@@ -844,7 +844,7 @@ static int cramfs_read_folio(struct file *file, struct folio *folio)
                        if (uncompressed) {
                                block_len = PAGE_SIZE;
                                /* if last block: cap to file length */
-                               if (page->index == maxblock - 1)
+                               if (folio->index == maxblock - 1)
                                        block_len =
                                                offset_in_page(inode->i_size);
                        } else {
@@ -861,7 +861,7 @@ static int cramfs_read_folio(struct file *file, struct folio *folio)
                         * from the previous block's pointer.
                         */
                        block_start = OFFSET(inode) + maxblock * 4;
-                       if (page->index)
+                       if (folio->index)
                                block_start = *(u32 *)
                                        cramfs_read(sb, blkptr_offset - 4, 4);
                        /* Beware... previous ptr might be a direct ptr */
@@ -906,17 +906,12 @@ static int cramfs_read_folio(struct file *file, struct folio *folio)
        }
 
        memset(pgdata + bytes_filled, 0, PAGE_SIZE - bytes_filled);
-       flush_dcache_page(page);
-       kunmap_local(pgdata);
-       SetPageUptodate(page);
-       unlock_page(page);
-       return 0;
+       flush_dcache_folio(folio);
 
+       success = true;
 err:
        kunmap_local(pgdata);
-       ClearPageUptodate(page);
-       SetPageError(page);
-       unlock_page(page);
+       folio_end_read(folio, success);
        return 0;
 }