btrfs: use bvec_kmap_local() in btrfs_decompress_buf2page()
authorChristoph Hellwig <hch@lst.de>
Wed, 9 Apr 2025 11:10:42 +0000 (13:10 +0200)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 12:30:47 +0000 (14:30 +0200)
This removes the last direct poke into bvec internals in btrfs.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c

index d0ed078e533467937d9a4416312cb44c2fbf45b6..b359ba41e7bde7e7d29fefd281a447c1b4ac7b29 100644 (file)
@@ -1198,6 +1198,7 @@ int btrfs_decompress_buf2page(const char *buf, u32 buf_len,
                u32 copy_start;
                /* Offset inside the full decompressed extent */
                u32 bvec_offset;
+               void *kaddr;
 
                bvec = bio_iter_iovec(orig_bio, orig_bio->bi_iter);
                /*
@@ -1220,10 +1221,12 @@ int btrfs_decompress_buf2page(const char *buf, u32 buf_len,
                 * @buf + @buf_len.
                 */
                ASSERT(copy_start - decompressed < buf_len);
-               memcpy_to_page(bvec.bv_page, bvec.bv_offset,
-                              buf + copy_start - decompressed, copy_len);
-               cur_offset += copy_len;
 
+               kaddr = bvec_kmap_local(&bvec);
+               memcpy(kaddr, buf + copy_start - decompressed, copy_len);
+               kunmap_local(kaddr);
+
+               cur_offset += copy_len;
                bio_advance(orig_bio, copy_len);
                /* Finished the bio */
                if (!orig_bio->bi_iter.bi_size)