All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Geoff Levand <geoff@infradead.org>,
	Ilya Dryomov <idryomov@gmail.com>,
	Dongsheng Yang <dongsheng.yang@easystack.cn>,
	Mike Snitzer <snitzer@redhat.com>,
	Ira Weiny <ira.weiny@intel.com>,
	dm-devel@redhat.com, linux-mips@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, ceph-devel@vger.kernel.org
Subject: [PATCH 15/16] block: use bvec_kmap_local in t10_pi_type1_{prepare,complete}
Date: Tue,  8 Jun 2021 18:06:02 +0200	[thread overview]
Message-ID: <20210608160603.1535935-16-hch@lst.de> (raw)
In-Reply-To: <20210608160603.1535935-1-hch@lst.de>

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/t10-pi.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/block/t10-pi.c b/block/t10-pi.c
index d910534b3a41..00c203b2a921 100644
--- a/block/t10-pi.c
+++ b/block/t10-pi.c
@@ -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);
 		}
 	}
 }
-- 
2.30.2


WARNING: multiple messages have this Message-ID
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Mike Snitzer <snitzer@redhat.com>,
	Geoff Levand <geoff@infradead.org>,
	linuxppc-dev@lists.ozlabs.org, linux-mips@vger.kernel.org,
	Dongsheng Yang <dongsheng.yang@easystack.cn>,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	dm-devel@redhat.com, Ilya Dryomov <idryomov@gmail.com>,
	Ira Weiny <ira.weiny@intel.com>,
	ceph-devel@vger.kernel.org
Subject: [PATCH 15/16] block: use bvec_kmap_local in t10_pi_type1_{prepare, complete}
Date: Tue,  8 Jun 2021 18:06:02 +0200	[thread overview]
Message-ID: <20210608160603.1535935-16-hch@lst.de> (raw)
In-Reply-To: <20210608160603.1535935-1-hch@lst.de>

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/t10-pi.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/block/t10-pi.c b/block/t10-pi.c
index d910534b3a41..00c203b2a921 100644
--- a/block/t10-pi.c
+++ b/block/t10-pi.c
@@ -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);
 		}
 	}
 }
-- 
2.30.2


WARNING: multiple messages have this Message-ID
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Mike Snitzer <snitzer@redhat.com>,
	Geoff Levand <geoff@infradead.org>,
	linuxppc-dev@lists.ozlabs.org, linux-mips@vger.kernel.org,
	Dongsheng Yang <dongsheng.yang@easystack.cn>,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	dm-devel@redhat.com, Ilya Dryomov <idryomov@gmail.com>,
	Ira Weiny <ira.weiny@intel.com>,
	ceph-devel@vger.kernel.org
Subject: [dm-devel] [PATCH 15/16] block: use bvec_kmap_local in t10_pi_type1_{prepare, complete}
Date: Tue,  8 Jun 2021 18:06:02 +0200	[thread overview]
Message-ID: <20210608160603.1535935-16-hch@lst.de> (raw)
In-Reply-To: <20210608160603.1535935-1-hch@lst.de>

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/t10-pi.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/block/t10-pi.c b/block/t10-pi.c
index d910534b3a41..00c203b2a921 100644
--- a/block/t10-pi.c
+++ b/block/t10-pi.c
@@ -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);
 		}
 	}
 }
-- 
2.30.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  parent reply	other threads:[~2021-06-08 16:09 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-08 16:05 switch the block layer to use kmap_local_page Christoph Hellwig
2021-06-08 16:05 ` [dm-devel] " Christoph Hellwig
2021-06-08 16:05 ` Christoph Hellwig
2021-06-08 16:05 ` [PATCH 01/16] mm: use kmap_local_page in memzero_page Christoph Hellwig
2021-06-08 16:05   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:05   ` Christoph Hellwig
2021-06-08 18:17   ` Chaitanya Kulkarni
2021-06-08 18:17     ` [dm-devel] " Chaitanya Kulkarni
2021-06-08 18:17     ` Chaitanya Kulkarni
2021-06-08 16:05 ` [PATCH 02/16] MIPS: don't include <linux/genhd.h> in <asm/mach-rc32434/rb.h> Christoph Hellwig
2021-06-08 16:05   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:05   ` Christoph Hellwig
2021-06-08 16:23   ` Bart Van Assche
2021-06-08 16:23     ` [dm-devel] " Bart Van Assche
2021-06-08 16:23     ` Bart Van Assche
2021-06-08 16:05 ` [PATCH 03/16] bvec: fix the include guards for bvec.h Christoph Hellwig
2021-06-08 16:05   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:05   ` Christoph Hellwig
2021-06-08 16:23   ` Bart Van Assche
2021-06-08 16:23     ` [dm-devel] " Bart Van Assche
2021-06-08 16:23     ` Bart Van Assche
2021-06-08 18:18   ` Chaitanya Kulkarni
2021-06-08 18:18     ` [dm-devel] " Chaitanya Kulkarni
2021-06-08 18:18     ` Chaitanya Kulkarni
2021-06-08 16:05 ` [PATCH 04/16] bvec: add a bvec_kmap_local helper Christoph Hellwig
2021-06-08 16:05   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:05   ` Christoph Hellwig
2021-06-08 18:18   ` Chaitanya Kulkarni
2021-06-08 18:18     ` [dm-devel] " Chaitanya Kulkarni
2021-06-08 18:18     ` Chaitanya Kulkarni
2021-06-09  9:33   ` Ilya Dryomov
2021-06-09  9:33     ` [dm-devel] " Ilya Dryomov
2021-06-09  9:33     ` Ilya Dryomov
2021-06-08 16:05 ` [PATCH 05/16] bvec: add memcpy_{from,to}_bvec and memzero_bvec helper Christoph Hellwig
2021-06-08 16:05   ` [dm-devel] [PATCH 05/16] bvec: add memcpy_{from, to}_bvec " Christoph Hellwig
2021-06-08 16:05   ` Christoph Hellwig
2021-06-08 18:21   ` [PATCH 05/16] bvec: add memcpy_{from,to}_bvec " Chaitanya Kulkarni
2021-06-08 18:21     ` [dm-devel] [PATCH 05/16] bvec: add memcpy_{from, to}_bvec " Chaitanya Kulkarni
2021-06-08 18:21     ` [PATCH 05/16] bvec: add memcpy_{from,to}_bvec " Chaitanya Kulkarni
2021-06-08 16:05 ` [PATCH 06/16] block: use memzero_page in zero_fill_bio Christoph Hellwig
2021-06-08 16:05   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:05   ` Christoph Hellwig
2021-06-08 18:19   ` Chaitanya Kulkarni
2021-06-08 18:19     ` [dm-devel] " Chaitanya Kulkarni
2021-06-08 18:19     ` Chaitanya Kulkarni
2021-06-08 16:05 ` [PATCH 07/16] rbd: use memzero_bvec Christoph Hellwig
2021-06-08 16:05   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:05   ` Christoph Hellwig
2021-06-09  9:37   ` Ilya Dryomov
2021-06-09  9:37     ` [dm-devel] " Ilya Dryomov
2021-06-09  9:37     ` Ilya Dryomov
2021-06-08 16:05 ` [PATCH 08/16] dm-writecache: use bvec_kmap_local instead of bvec_kmap_irq Christoph Hellwig
2021-06-08 16:05   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:05   ` Christoph Hellwig
2021-06-08 16:30   ` Bart Van Assche
2021-06-08 16:30     ` [dm-devel] " Bart Van Assche
2021-06-08 16:30     ` Bart Van Assche
2021-06-08 16:38     ` Christoph Hellwig
2021-06-08 16:38       ` [dm-devel] " Christoph Hellwig
2021-06-08 16:38       ` Christoph Hellwig
2021-06-08 16:05 ` [PATCH 09/16] ps3disk: use memcpy_{from,to}_bvec Christoph Hellwig
2021-06-08 16:05   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:05   ` Christoph Hellwig
2021-06-09  1:48   ` Ira Weiny
2021-06-09  1:48     ` [dm-devel] " Ira Weiny
2021-06-09  1:48     ` Ira Weiny
2021-06-11  6:53     ` Christoph Hellwig
2021-06-11  6:53       ` [dm-devel] " Christoph Hellwig
2021-06-11  6:53       ` Christoph Hellwig
2021-06-12  4:07       ` Ira Weiny
2021-06-12  4:07         ` [dm-devel] " Ira Weiny
2021-06-12  4:07         ` Ira Weiny
2021-06-12  4:07         ` Ira Weiny
2021-06-15  5:02         ` Herbert Xu
2021-06-15  5:02           ` [dm-devel] " Herbert Xu
2021-06-15  5:02           ` Herbert Xu
2021-06-15  5:02           ` Herbert Xu
2021-06-08 16:05 ` [PATCH 10/16] block: remove bvec_kmap_irq and bvec_kunmap_irq Christoph Hellwig
2021-06-08 16:05   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:05   ` Christoph Hellwig
2021-06-08 16:05 ` [PATCH 11/16] block: rewrite bio_copy_data_iter to use bvec_kmap_local and memcpy_to_bvec Christoph Hellwig
2021-06-08 16:05   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:05   ` Christoph Hellwig
2021-06-08 16:05 ` [PATCH 12/16] block: use memcpy_to_bvec in copy_to_high_bio_irq Christoph Hellwig
2021-06-08 16:05   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:05   ` Christoph Hellwig
2021-06-08 18:24   ` Chaitanya Kulkarni
2021-06-08 18:24     ` [dm-devel] " Chaitanya Kulkarni
2021-06-08 18:24     ` Chaitanya Kulkarni
2021-06-08 16:06 ` [PATCH 13/16] block: use memcpy_from_bvec in bio_copy_kern_endio_read Christoph Hellwig
2021-06-08 16:06   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:06   ` Christoph Hellwig
2021-06-08 18:26   ` Chaitanya Kulkarni
2021-06-08 18:26     ` [dm-devel] " Chaitanya Kulkarni
2021-06-08 18:26     ` Chaitanya Kulkarni
2021-06-08 16:06 ` [PATCH 14/16] block: use memcpy_from_bvec in __blk_queue_bounce Christoph Hellwig
2021-06-08 16:06   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:06   ` Christoph Hellwig
2021-06-09  1:58   ` Ira Weiny
2021-06-09  1:58     ` [dm-devel] " Ira Weiny
2021-06-09  1:58     ` Ira Weiny
2021-06-08 16:06 ` Christoph Hellwig [this message]
2021-06-08 16:06   ` [dm-devel] [PATCH 15/16] block: use bvec_kmap_local in t10_pi_type1_{prepare, complete} Christoph Hellwig
2021-06-08 16:06   ` Christoph Hellwig
2021-06-08 16:06 ` [PATCH 16/16] block: use bvec_kmap_local in bio_integrity_process Christoph Hellwig
2021-06-08 16:06   ` [dm-devel] " Christoph Hellwig
2021-06-08 16:06   ` Christoph Hellwig
2021-06-09  1:59 ` switch the block layer to use kmap_local_page Ira Weiny
2021-06-09  1:59   ` [dm-devel] " Ira Weiny
2021-06-09  1:59   ` Ira Weiny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210608160603.1535935-16-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=ceph-devel@vger.kernel.org \
    --cc=dm-devel@redhat.com \
    --cc=dongsheng.yang@easystack.cn \
    --cc=geoff@infradead.org \
    --cc=idryomov@gmail.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=snitzer@redhat.com \
    --cc=tsbogend@alpha.franken.de \
    --subject='Re: [PATCH 15/16] block: use bvec_kmap_local in t10_pi_type1_{prepare,complete}' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.