]> www.infradead.org Git - users/hch/block.git/commitdiff
bcache: use bvec_kmap_local in bio_csum
authorChristoph Hellwig <hch@lst.de>
Thu, 20 May 2021 13:10:45 +0000 (15:10 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 21 May 2021 05:57:23 +0000 (07:57 +0200)
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>
drivers/md/bcache/request.c

index 466f187e1215d613199dae3098f88324e513997b..0296c4c5670b557c6b30e3b72cc14530e6f9345b 100644 (file)
@@ -44,10 +44,10 @@ static void bio_csum(struct bio *bio, struct bkey *k)
        uint64_t csum = 0;
 
        bio_for_each_segment(bv, bio, iter) {
-               void *d = kmap(bv.bv_page) + bv.bv_offset;
+               void *d = bvec_kmap_local(&bv);
 
                csum = crc64_be(csum, d, bv.bv_len);
-               kunmap(bv.bv_page);
+               kunmap(d);
        }
 
        k->ptr[KEY_PTRS(k)] = csum & (~0ULL >> 1);