mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tal Zussman <tz2294@columbia.edu>
To: Nicolas Pitre <nico@fluxnic.net>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Christian Brauner <brauner@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cramfs: convert cramfs_blkdev_read() to use folios
Date: Mon, 12 Oct 2026 10:54:14 -0400	[thread overview]
Message-ID: <810d7901-b897-4880-a8d4-d80fe0f8770b@columbia.edu> (raw)
In-Reply-To: <20260906-cramfs-blkdev-read-folio-v1-1-1be99a82be55@columbia.edu>

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@columbia.edu>
> ---
>  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

> 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@columbia.edu>


  reply	other threads:[~2026-10-12 14:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06 23:45 Tal Zussman
2026-10-12 14:54 ` Tal Zussman [this message]
2026-10-12 16:16   ` Nicolas Pitre
2026-10-13 16:46     ` Tal Zussman
2026-10-21 11:02 ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=810d7901-b897-4880-a8d4-d80fe0f8770b@columbia.edu \
    --to=tz2294@columbia.edu \
    --cc=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nico@fluxnic.net \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®