block: use bvec_kmap_local in t10_pi_type1_{prepare,complete}
authorChristoph Hellwig <hch@lst.de>
Tue, 27 Jul 2021 05:56:45 +0000 (07:56 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 2 Aug 2021 19:37:28 +0000 (13:37 -0600)
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: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20210727055646.118787-15-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/t10-pi.c

index d910534..00c203b 100644 (file)
@@ -147,11 +147,10 @@ static void t10_pi_type1_prepare(struct request *rq)
                        break;
 
                bip_for_each_vec(iv, bip, iter) {
-                       void *p, *pmap;
                        unsigned int j;
+                       void *p;
 
-                       pmap = kmap_atomic(iv.bv_page);
-                       p = pmap + iv.bv_offset;
+                       p = bvec_kmap_local(&iv);
                        for (j = 0; j < iv.bv_len; j += tuple_sz) {
                                struct t10_pi_tuple *pi = p;
 
@@ -161,8 +160,7 @@ static void t10_pi_type1_prepare(struct request *rq)
                                ref_tag++;
                                p += tuple_sz;
                        }
-
-                       kunmap_atomic(pmap);
+                       kunmap_local(p);
                }
 
                bip->bip_flags |= BIP_MAPPED_INTEGRITY;
@@ -195,11 +193,10 @@ static void t10_pi_type1_complete(struct request *rq, unsigned int nr_bytes)
                struct bvec_iter iter;
 
                bip_for_each_vec(iv, bip, iter) {
-                       void *p, *pmap;
                        unsigned int j;
+                       void *p;
 
-                       pmap = kmap_atomic(iv.bv_page);
-                       p = pmap + iv.bv_offset;
+                       p = bvec_kmap_local(&iv);
                        for (j = 0; j < iv.bv_len && intervals; j += tuple_sz) {
                                struct t10_pi_tuple *pi = p;
 
@@ -210,8 +207,7 @@ static void t10_pi_type1_complete(struct request *rq, unsigned int nr_bytes)
                                intervals--;
                                p += tuple_sz;
                        }
-
-                       kunmap_atomic(pmap);
+                       kunmap_local(p);
                }
        }
 }