Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs: zlib: use memcpy_from_folio() in copy_data_into_buffer()
@ 2026-10-26 17:39 fdmanana
  2026-10-26 21:12 ` Qu Wenruo
  2026-10-27  7:05 ` Johannes Thumshirn
  0 siblings, 2 replies; 3+ messages in thread
From: fdmanana @ 2026-10-26 17:39 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

We are manually mapping the folio, copying from it with memcpy() and then
unmapping, but this can all simply be done with memcpy_from_folio() that
is provided by the MM layer. So use memcpy_from_folio() instead.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/zlib.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
index e995d0b1452b..1f2a91f966a2 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -122,7 +122,6 @@ static int copy_data_into_buffer(struct address_space *mapping,
 
 	while (cur < filepos + length) {
 		struct folio *folio;
-		void *data_in;
 		unsigned int offset;
 		unsigned long copy_length;
 		int ret;
@@ -135,9 +134,8 @@ static int copy_data_into_buffer(struct address_space *mapping,
 		copy_length = min(folio_size(folio) - offset,
 				  filepos + length - cur);
 
-		data_in = kmap_local_folio(folio, offset);
-		memcpy(workspace->buf + cur - filepos, data_in, copy_length);
-		kunmap_local(data_in);
+		memcpy_from_folio(workspace->buf + cur - filepos, folio, offset,
+				  copy_length);
 		folio_put(folio);
 		cur += copy_length;
 	}
-- 
2.53.0


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

* Re: [PATCH] btrfs: zlib: use memcpy_from_folio() in copy_data_into_buffer()
  2026-10-26 17:39 [PATCH] btrfs: zlib: use memcpy_from_folio() in copy_data_into_buffer() fdmanana
@ 2026-10-26 21:12 ` Qu Wenruo
  2026-10-27  7:05 ` Johannes Thumshirn
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2026-10-26 21:12 UTC (permalink / raw)
  To: fdmanana, linux-btrfs



在 2026/10/27 04:09, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
> 
> We are manually mapping the folio, copying from it with memcpy() and then
> unmapping, but this can all simply be done with memcpy_from_folio() that
> is provided by the MM layer. So use memcpy_from_folio() instead.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>   fs/btrfs/zlib.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
> index e995d0b1452b..1f2a91f966a2 100644
> --- a/fs/btrfs/zlib.c
> +++ b/fs/btrfs/zlib.c
> @@ -122,7 +122,6 @@ static int copy_data_into_buffer(struct address_space *mapping,
>   
>   	while (cur < filepos + length) {
>   		struct folio *folio;
> -		void *data_in;
>   		unsigned int offset;
>   		unsigned long copy_length;
>   		int ret;
> @@ -135,9 +134,8 @@ static int copy_data_into_buffer(struct address_space *mapping,
>   		copy_length = min(folio_size(folio) - offset,
>   				  filepos + length - cur);
>   
> -		data_in = kmap_local_folio(folio, offset);
> -		memcpy(workspace->buf + cur - filepos, data_in, copy_length);
> -		kunmap_local(data_in);
> +		memcpy_from_folio(workspace->buf + cur - filepos, folio, offset,
> +				  copy_length);
>   		folio_put(folio);
>   		cur += copy_length;
>   	}


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

* Re: [PATCH] btrfs: zlib: use memcpy_from_folio() in copy_data_into_buffer()
  2026-10-26 17:39 [PATCH] btrfs: zlib: use memcpy_from_folio() in copy_data_into_buffer() fdmanana
  2026-10-26 21:12 ` Qu Wenruo
@ 2026-10-27  7:05 ` Johannes Thumshirn
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2026-10-27  7:05 UTC (permalink / raw)
  To: fdmanana, linux-btrfs

Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

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

end of thread, other threads:[~2026-10-27  7:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-26 17:39 [PATCH] btrfs: zlib: use memcpy_from_folio() in copy_data_into_buffer() fdmanana
2026-10-26 21:12 ` Qu Wenruo
2026-10-27  7:05 ` Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox