Commit 8aec120a authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: use bvec_kmap_local in t10_pi_type1_{prepare,complete}

Using local kmaps slightly reduces the chances to stray writes, and
the bvec interface cleans up the code a little bit.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20210727055646.118787-15-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 4aebe859
...@@ -147,11 +147,10 @@ static void t10_pi_type1_prepare(struct request *rq) ...@@ -147,11 +147,10 @@ static void t10_pi_type1_prepare(struct request *rq)
break; break;
bip_for_each_vec(iv, bip, iter) { bip_for_each_vec(iv, bip, iter) {
void *p, *pmap;
unsigned int j; unsigned int j;
void *p;
pmap = kmap_atomic(iv.bv_page); p = bvec_kmap_local(&iv);
p = pmap + iv.bv_offset;
for (j = 0; j < iv.bv_len; j += tuple_sz) { for (j = 0; j < iv.bv_len; j += tuple_sz) {
struct t10_pi_tuple *pi = p; struct t10_pi_tuple *pi = p;
...@@ -161,8 +160,7 @@ static void t10_pi_type1_prepare(struct request *rq) ...@@ -161,8 +160,7 @@ static void t10_pi_type1_prepare(struct request *rq)
ref_tag++; ref_tag++;
p += tuple_sz; p += tuple_sz;
} }
kunmap_local(p);
kunmap_atomic(pmap);
} }
bip->bip_flags |= BIP_MAPPED_INTEGRITY; bip->bip_flags |= BIP_MAPPED_INTEGRITY;
...@@ -195,11 +193,10 @@ static void t10_pi_type1_complete(struct request *rq, unsigned int nr_bytes) ...@@ -195,11 +193,10 @@ static void t10_pi_type1_complete(struct request *rq, unsigned int nr_bytes)
struct bvec_iter iter; struct bvec_iter iter;
bip_for_each_vec(iv, bip, iter) { bip_for_each_vec(iv, bip, iter) {
void *p, *pmap;
unsigned int j; unsigned int j;
void *p;
pmap = kmap_atomic(iv.bv_page); p = bvec_kmap_local(&iv);
p = pmap + iv.bv_offset;
for (j = 0; j < iv.bv_len && intervals; j += tuple_sz) { for (j = 0; j < iv.bv_len && intervals; j += tuple_sz) {
struct t10_pi_tuple *pi = p; struct t10_pi_tuple *pi = p;
...@@ -210,8 +207,7 @@ static void t10_pi_type1_complete(struct request *rq, unsigned int nr_bytes) ...@@ -210,8 +207,7 @@ static void t10_pi_type1_complete(struct request *rq, unsigned int nr_bytes)
intervals--; intervals--;
p += tuple_sz; p += tuple_sz;
} }
kunmap_local(p);
kunmap_atomic(pmap);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment