btrfs: use bvec_kmap_local in btrfs_csum_one_bio
authorChristoph Hellwig <hch@lst.de>
Tue, 12 Oct 2021 06:31:53 +0000 (08:31 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 26 Oct 2021 17:08:06 +0000 (19:08 +0200)
Using local kmaps slightly reduces the chances to stray writes, and
the bvec interface cleans up the code a little bit.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file-item.c

index ddb9c7ee796f07401d387521e0d018b4b2652e37..d1cbb64a78f3a207422797e5b97f93f43048036b 100644 (file)
@@ -708,12 +708,12 @@ blk_status_t btrfs_csum_one_bio(struct btrfs_inode *inode, struct bio *bio,
                                index = 0;
                        }
 
-                       data = kmap_atomic(bvec.bv_page);
-                       crypto_shash_digest(shash, data + bvec.bv_offset
-                                           + (i * fs_info->sectorsize),
+                       data = bvec_kmap_local(&bvec);
+                       crypto_shash_digest(shash,
+                                           data + (i * fs_info->sectorsize),
                                            fs_info->sectorsize,
                                            sums->sums + index);
-                       kunmap_atomic(data);
+                       kunmap_local(data);
                        index += fs_info->csum_size;
                        offset += fs_info->sectorsize;
                        this_sum_bytes += fs_info->sectorsize;