cramfs: Convert cramfs_read_folio to use a folio

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>
This commit is contained in:
Matthew Wilcox (Oracle) 2024-05-30 21:20:55 +01:00 committed by Christian Brauner
parent 8c30a7344a
commit def27a2054
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2

View 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;
}