Re: [PATCH] cramfs: convert cramfs_blkdev_read() to use folios

From: Tal Zussman

Date: Tue Oct 13 2026 - 12:56:43 EST


On 10/12/26 12:16 PM, Nicolas Pitre wrote:
> On Mon, 12 Oct 2026, Tal Zussman wrote:
>
>> On 9/6/26 7:45 PM, Tal Zussman wrote:
>> > Read the block device pages through read_mapping_folio() and copy with
>> > memcpy_from_folio() instead of going through a page.
>> >
>> > Signed-off-by: Tal Zussman <tz2294@xxxxxxxxxxxx>
>> > ---
>> > fs/cramfs/inode.c | 23 +++++++++++++----------
>> > 1 file changed, 13 insertions(+), 10 deletions(-)
>> >
>>
>> Following up on this - I don't see a cramfs tree, so could this go
>> through vfs if everything looks ok? It gets us one step closer to
>> removing read_mapping_page().
>>
>> Thanks,
>> Tal
>
> Yes, please forward to the vfs tree.
>
> Acked-by: Nicolas Pitre <nico@xxxxxxxxxxx>
>
Thanks!

Christian, could you please pick this up?

>
>> > diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
>> > index d4cd03f4f60d..b55eb3bd29c1 100644
>> > --- a/fs/cramfs/inode.c
>> > +++ b/fs/cramfs/inode.c
>> > @@ -194,7 +194,7 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
>> > {
>> > struct address_space *mapping = sb->s_bdev->bd_mapping;
>> > struct file_ra_state ra = {};
>> > - struct page *pages[BLKS_PER_BUF];
>> > + struct folio *folios[BLKS_PER_BUF];
>> > unsigned i, blocknr, buffer;
>> > unsigned long devsize;
>> > char *data;
>> > @@ -227,15 +227,15 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
>> > page_cache_sync_readahead(mapping, &ra, NULL, blocknr, BLKS_PER_BUF);
>> >
>> > for (i = 0; i < BLKS_PER_BUF; i++) {
>> > - struct page *page = NULL;
>> > + struct folio *folio = NULL;
>> >
>> > if (blocknr + i < devsize) {
>> > - page = read_mapping_page(mapping, blocknr + i, NULL);
>> > + folio = read_mapping_folio(mapping, blocknr + i, NULL);
>> > /* synchronous error? */
>> > - if (IS_ERR(page))
>> > - page = NULL;
>> > + if (IS_ERR(folio))
>> > + folio = NULL;
>> > }
>> > - pages[i] = page;
>> > + folios[i] = folio;
>> > }
>> >
>> > buffer = next_buffer;
>> > @@ -245,11 +245,14 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
>> >
>> > data = read_buffers[buffer];
>> > for (i = 0; i < BLKS_PER_BUF; i++) {
>> > - struct page *page = pages[i];
>> > + struct folio *folio = folios[i];
>> >
>> > - if (page) {
>> > - memcpy_from_page(data, page, 0, PAGE_SIZE);
>> > - put_page(page);
>> > + if (folio) {
>> > + size_t offset = offset_in_folio(folio,
>> > + (loff_t)(blocknr + i) << PAGE_SHIFT);
>> > +
>> > + memcpy_from_folio(data, folio, offset, PAGE_SIZE);
>> > + folio_put(folio);
>> > } else
>> > memset(data, 0, PAGE_SIZE);
>> > data += PAGE_SIZE;
>> >
>> > ---
>> > base-commit: df2908090cda368b01ff43709f51890076c56157
>> > change-id: 20260906-cramfs-blkdev-read-folio-16fecf6908ac
>> >
>> > Best regards,
>> > --
>> > Tal Zussman <tz2294@xxxxxxxxxxxx>
>>
>>
>