mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cramfs: convert cramfs_blkdev_read() to use folios
@ 2026-09-06 23:45 Tal Zussman
  2026-10-12 14:54 ` Tal Zussman
  2026-10-21 11:02 ` Christian Brauner
  0 siblings, 2 replies; 5+ messages in thread
From: Tal Zussman @ 2026-09-06 23:45 UTC (permalink / raw)
  To: Nicolas Pitre
  Cc: Matthew Wilcox (Oracle),
	Christian Brauner, linux-fsdevel, linux-kernel, Tal Zussman

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(-)

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>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cramfs: convert cramfs_blkdev_read() to use folios
  2026-09-06 23:45 [PATCH] cramfs: convert cramfs_blkdev_read() to use folios Tal Zussman
@ 2026-10-12 14:54 ` Tal Zussman
  2026-10-12 16:16   ` Nicolas Pitre
  2026-10-21 11:02 ` Christian Brauner
  1 sibling, 1 reply; 5+ messages in thread
From: Tal Zussman @ 2026-10-12 14:54 UTC (permalink / raw)
  To: Nicolas Pitre
  Cc: Matthew Wilcox (Oracle), Christian Brauner, linux-fsdevel, linux-kernel

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>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cramfs: convert cramfs_blkdev_read() to use folios
  2026-10-12 14:54 ` Tal Zussman
@ 2026-10-12 16:16   ` Nicolas Pitre
  2026-10-13 16:46     ` Tal Zussman
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Pitre @ 2026-10-12 16:16 UTC (permalink / raw)
  To: Tal Zussman
  Cc: Matthew Wilcox (Oracle), Christian Brauner, linux-fsdevel, linux-kernel

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@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

Yes, please forward to the vfs tree.

Acked-by: Nicolas Pitre <nico@fluxnic.net>



> > 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>
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cramfs: convert cramfs_blkdev_read() to use folios
  2026-10-12 16:16   ` Nicolas Pitre
@ 2026-10-13 16:46     ` Tal Zussman
  0 siblings, 0 replies; 5+ messages in thread
From: Tal Zussman @ 2026-10-13 16:46 UTC (permalink / raw)
  To: Nicolas Pitre, Christian Brauner
  Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-kernel

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@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
> 
> Yes, please forward to the vfs tree.
> 
> Acked-by: Nicolas Pitre <nico@fluxnic.net>
> 
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@columbia.edu>
>> 
>> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cramfs: convert cramfs_blkdev_read() to use folios
  2026-09-06 23:45 [PATCH] cramfs: convert cramfs_blkdev_read() to use folios Tal Zussman
  2026-10-12 14:54 ` Tal Zussman
@ 2026-10-21 11:02 ` Christian Brauner
  1 sibling, 0 replies; 5+ messages in thread
From: Christian Brauner @ 2026-10-21 11:02 UTC (permalink / raw)
  To: Nicolas Pitre, Tal Zussman
  Cc: Matthew Wilcox (Oracle), linux-fsdevel, linux-kernel

On Sun, 06 Sep 2026 19:45:33 -0400, Tal Zussman wrote:
> Read the block device pages through read_mapping_folio() and copy with
> memcpy_from_folio() instead of going through a page.

Applied to the vfs-7.5.misc branch of the vfs/vfs.git tree.
Patches in the vfs-7.5.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.5.misc

[1/1] cramfs: convert cramfs_blkdev_read() to use folios
      https://git.kernel.org/vfs/vfs/c/06e2e8febbcc


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-21 11:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-06 23:45 [PATCH] cramfs: convert cramfs_blkdev_read() to use folios Tal Zussman
2026-10-12 14:54 ` Tal Zussman
2026-10-12 16:16   ` Nicolas Pitre
2026-10-13 16:46     ` Tal Zussman
2026-10-21 11:02 ` Christian Brauner

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®