]> www.infradead.org Git - users/hch/block.git/commitdiff
drbd: use bvec_kmap_local in recv_dless_read
authorChristoph Hellwig <hch@lst.de>
Thu, 20 May 2021 13:14:18 +0000 (15:14 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 1 Mar 2022 12:21:31 +0000 (14:21 +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>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
drivers/block/drbd/drbd_receiver.c

index 04e3ec12d8b4945ca9cbed00a78bae9526da1a6a..fa00cf2ea9529ea639748b06aced3e79cb9e2d8a 100644 (file)
@@ -2017,10 +2017,10 @@ static int recv_dless_read(struct drbd_peer_device *peer_device, struct drbd_req
        D_ASSERT(peer_device->device, sector == bio->bi_iter.bi_sector);
 
        bio_for_each_segment(bvec, bio, iter) {
-               void *mapped = kmap(bvec.bv_page) + bvec.bv_offset;
+               void *mapped = bvec_kmap_local(&bvec);
                expect = min_t(int, data_size, bvec.bv_len);
                err = drbd_recv_all_warn(peer_device->connection, mapped, expect);
-               kunmap(bvec.bv_page);
+               kunmap_local(mapped);
                if (err)
                        return err;
                data_size -= expect;