]> git.hungrycats.org Git - linux/commitdiff
btrfs: zlib: use memcpy_from_folio() in copy_data_into_buffer()
authorFilipe Manana <fdmanana@suse.com>
Mon, 26 Oct 2026 17:31:37 +0000 (17:31 +0000)
committerDavid Sterba <dsterba@suse.com>
Fri, 30 Oct 2026 20:36:19 +0000 (21:36 +0100)
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.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshrin@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/zlib.c

index e995d0b1452b9257a4e1f0a9661d1f6042c87d0c..1f2a91f966a263c775de8a2904fce7cdcdec7d29 100644 (file)
@@ -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;
        }