diff mbox series

[16/16] block: use bvec_kmap_local in bio_integrity_process

Message ID 20210608160603.1535935-17-hch@lst.de (mailing list archive)
State Not Applicable
Headers show
Series [01/16] mm: use kmap_local_page in memzero_page | expand
Related show

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch powerpc/merge (c53db722ec7ab3ebf29ecf61e922820f31e5284b)
snowpatch_ozlabs/build-ppc64le warning Build succeeded but added 4 new sparse warnings
snowpatch_ozlabs/build-ppc64be warning Build succeeded but added 4 new sparse warnings
snowpatch_ozlabs/build-ppc64e warning Build succeeded but added 4 new sparse warnings
snowpatch_ozlabs/build-pmac32 warning Build succeeded but added 3 new sparse warnings
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
snowpatch_ozlabs/needsstable success Patch has no Fixes tags

Commit Message

Christoph Hellwig June 8, 2021, 4:06 p.m. UTC
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>
---
 block/bio-integrity.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 4b4eb8964a6f..8f54d49dc500 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -172,18 +172,16 @@  static blk_status_t bio_integrity_process(struct bio *bio,
 	iter.prot_buf = prot_buf;
 
 	__bio_for_each_segment(bv, bio, bviter, *proc_iter) {
-		void *kaddr = kmap_atomic(bv.bv_page);
+		void *kaddr = bvec_kmap_local(&bv);
 
-		iter.data_buf = kaddr + bv.bv_offset;
+		iter.data_buf = kaddr;
 		iter.data_size = bv.bv_len;
-
 		ret = proc_fn(&iter);
-		if (ret) {
-			kunmap_atomic(kaddr);
-			return ret;
-		}
+		kunmap_local(kaddr);
+
+		if (ret)
+			break;
 
-		kunmap_atomic(kaddr);
 	}
 	return ret;
 }