OSDN Git Service

drbd: use bvec_kmap_local in drbd_csum_bio
authorChristoph Hellwig <hch@lst.de>
Thu, 3 Mar 2022 11:19:03 +0000 (14:19 +0300)
committerJens Axboe <axboe@kernel.dk>
Fri, 4 Mar 2022 19:29:21 +0000 (12:29 -0700)
Using local kmaps slightly reduces the chances to stray writes, and
the bvec interface cleans up the code a little bit.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/20220303111905.321089-9-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/drbd/drbd_worker.c

index a5e04b3..1b48c81 100644 (file)
@@ -326,9 +326,9 @@ void drbd_csum_bio(struct crypto_shash *tfm, struct bio *bio, void *digest)
        bio_for_each_segment(bvec, bio, iter) {
                u8 *src;
 
-               src = kmap_atomic(bvec.bv_page);
-               crypto_shash_update(desc, src + bvec.bv_offset, bvec.bv_len);
-               kunmap_atomic(src);
+               src = bvec_kmap_local(&bvec);
+               crypto_shash_update(desc, src, bvec.bv_len);
+               kunmap_local(src);
 
                /* REQ_OP_WRITE_SAME has only one segment,
                 * checksum the payload only once. */