linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Pavel Begunkov <asml.silence@gmail.com>,
	Matthew Wilcox <willy@infradead.org>,
	Jens Axboe <axboe@kernel.dk>,
	Alexander Viro <viro@zeniv.linux.org.uk>
Cc: dhowells@redhat.com,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 25/29] iov_iter: Split csum_and_copy_to_iter()
Date: Sat, 21 Nov 2020 14:16:37 +0000	[thread overview]
Message-ID: <160596819702.154728.12031895151454434193.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <160596800145.154728.7192318545120181269.stgit@warthog.procyon.org.uk>

Split csum_and_copy_to_iter() by type.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 lib/iov_iter.c |   68 ++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 48 insertions(+), 20 deletions(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 8820a9e72815..2f8019e3b09a 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -698,14 +698,15 @@ static __wsum csum_and_memcpy(void *to, const void *from, size_t len,
 	return csum_block_add(sum, next, off);
 }
 
-static size_t csum_and_copy_to_pipe_iter(const void *addr, size_t bytes,
-				__wsum *csum, struct iov_iter *i)
+static size_t pipe_csum_and_copy_to_iter(const void *addr, size_t bytes,
+				void *csump, struct iov_iter *i)
 {
 	struct pipe_inode_info *pipe = i->pipe;
 	unsigned int p_mask = pipe->ring_size - 1;
 	unsigned int i_head;
 	size_t n, r;
 	size_t off = 0;
+	__wsum *csum = csump;
 	__wsum sum = *csum;
 
 	if (!sanity(i))
@@ -1914,7 +1915,7 @@ static bool no_csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *cs
 	return false;
 }
 
-static size_t xxx_csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump,
+static size_t iovec_csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump,
 			     struct iov_iter *i)
 {
 	const char *from = addr;
@@ -1922,15 +1923,8 @@ static size_t xxx_csum_and_copy_to_iter(const void *addr, size_t bytes, void *cs
 	__wsum sum, next;
 	size_t off = 0;
 
-	if (unlikely(iov_iter_is_pipe(i)))
-		return csum_and_copy_to_pipe_iter(addr, bytes, csum, i);
-
 	sum = *csum;
-	if (unlikely(iov_iter_is_discard(i))) {
-		WARN_ON(1);	/* for now */
-		return 0;
-	}
-	iterate_and_advance(i, bytes, v, ({
+	iterate_and_advance_iovec(i, bytes, v, ({
 		next = csum_and_copy_to_user((from += v.iov_len) - v.iov_len,
 					     v.iov_base,
 					     v.iov_len);
@@ -1939,24 +1933,58 @@ static size_t xxx_csum_and_copy_to_iter(const void *addr, size_t bytes, void *cs
 			off += v.iov_len;
 		}
 		next ? 0 : v.iov_len;
-	}), ({
+	}));
+	*csum = sum;
+	return bytes;
+}
+
+static size_t bvec_csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump,
+			     struct iov_iter *i)
+{
+	const char *from = addr;
+	__wsum *csum = csump;
+	__wsum sum;
+	size_t off = 0;
+
+	sum = *csum;
+	iterate_and_advance_bvec(i, bytes, v, ({
 		char *p = kmap_atomic(v.bv_page);
 		sum = csum_and_memcpy(p + v.bv_offset,
 				      (from += v.bv_len) - v.bv_len,
 				      v.bv_len, sum, off);
 		kunmap_atomic(p);
 		off += v.bv_len;
-	}),({
+	}));
+	*csum = sum;
+	return bytes;
+}
+
+static size_t kvec_csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump,
+			     struct iov_iter *i)
+{
+	const char *from = addr;
+	__wsum *csum = csump;
+	__wsum sum;
+	size_t off = 0;
+
+	sum = *csum;
+	iterate_and_advance_kvec(i, bytes, v, ({
 		sum = csum_and_memcpy(v.iov_base,
 				     (from += v.iov_len) - v.iov_len,
 				     v.iov_len, sum, off);
 		off += v.iov_len;
-	})
-	)
+	}));
 	*csum = sum;
 	return bytes;
 }
 
+static size_t discard_csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump,
+			     struct iov_iter *i)
+{
+	WARN_ON(1);	/* for now */
+	return 0;
+}
+
 size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp,
 		struct iov_iter *i)
 {
@@ -2256,7 +2284,7 @@ static const struct iov_iter_ops iovec_iter_ops = {
 #ifdef CONFIG_ARCH_HAS_COPY_MC
 	.copy_mc_to_iter		= iovec_copy_mc_to_iter,
 #endif
-	.csum_and_copy_to_iter		= xxx_csum_and_copy_to_iter,
+	.csum_and_copy_to_iter		= iovec_csum_and_copy_to_iter,
 	.csum_and_copy_from_iter	= iovec_csum_and_copy_from_iter,
 	.csum_and_copy_from_iter_full	= iovec_csum_and_copy_from_iter_full,
 
@@ -2290,7 +2318,7 @@ static const struct iov_iter_ops kvec_iter_ops = {
 #ifdef CONFIG_ARCH_HAS_COPY_MC
 	.copy_mc_to_iter		= kvec_copy_mc_to_iter,
 #endif
-	.csum_and_copy_to_iter		= xxx_csum_and_copy_to_iter,
+	.csum_and_copy_to_iter		= kvec_csum_and_copy_to_iter,
 	.csum_and_copy_from_iter	= kvec_csum_and_copy_from_iter,
 	.csum_and_copy_from_iter_full	= kvec_csum_and_copy_from_iter_full,
 
@@ -2324,7 +2352,7 @@ static const struct iov_iter_ops bvec_iter_ops = {
 #ifdef CONFIG_ARCH_HAS_COPY_MC
 	.copy_mc_to_iter		= bvec_copy_mc_to_iter,
 #endif
-	.csum_and_copy_to_iter		= xxx_csum_and_copy_to_iter,
+	.csum_and_copy_to_iter		= bvec_csum_and_copy_to_iter,
 	.csum_and_copy_from_iter	= bvec_csum_and_copy_from_iter,
 	.csum_and_copy_from_iter_full	= bvec_csum_and_copy_from_iter_full,
 
@@ -2358,7 +2386,7 @@ static const struct iov_iter_ops pipe_iter_ops = {
 #ifdef CONFIG_ARCH_HAS_COPY_MC
 	.copy_mc_to_iter		= pipe_copy_mc_to_iter,
 #endif
-	.csum_and_copy_to_iter		= xxx_csum_and_copy_to_iter,
+	.csum_and_copy_to_iter		= pipe_csum_and_copy_to_iter,
 	.csum_and_copy_from_iter	= no_csum_and_copy_from_iter,
 	.csum_and_copy_from_iter_full	= no_csum_and_copy_from_iter_full,
 
@@ -2392,7 +2420,7 @@ static const struct iov_iter_ops discard_iter_ops = {
 #ifdef CONFIG_ARCH_HAS_COPY_MC
 	.copy_mc_to_iter		= discard_copy_to_iter,
 #endif
-	.csum_and_copy_to_iter		= xxx_csum_and_copy_to_iter,
+	.csum_and_copy_to_iter		= discard_csum_and_copy_to_iter,
 	.csum_and_copy_from_iter	= no_csum_and_copy_from_iter,
 	.csum_and_copy_from_iter_full	= no_csum_and_copy_from_iter_full,
 



  parent reply	other threads:[~2020-11-21 14:17 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-21 14:13 [PATCH 00/29] RFC: iov_iter: Switch to using an ops table David Howells
2020-11-21 14:13 ` [PATCH 01/29] iov_iter: Switch to using a table of operations David Howells
2020-11-21 14:31   ` Pavel Begunkov
2020-11-23 23:21     ` Pavel Begunkov
2020-11-21 18:21   ` Linus Torvalds
2020-12-11  1:30     ` Al Viro
2020-11-22 13:33   ` David Howells
2020-11-22 13:58     ` David Laight
2020-11-22 19:22     ` Linus Torvalds
2020-11-22 22:34       ` David Laight
2020-11-22 22:46   ` David Laight
2020-11-23  8:05   ` Christoph Hellwig
2020-11-23 10:31   ` David Howells
2020-11-23 23:42     ` Pavel Begunkov
2020-11-24 12:50     ` David Howells
2020-11-24 15:30       ` Jens Axboe
2020-11-27 17:14       ` David Howells
2020-11-23 11:14   ` David Howells
     [not found]   ` <20201203064536.GE27350@xsang-OptiPlex-9020>
2020-12-03 17:47     ` [iov_iter] 9bd0e337c6: will-it-scale.per_process_ops -4.8% regression Linus Torvalds
2020-12-03 17:50       ` Jens Axboe
2020-12-04 11:50     ` David Howells
2020-12-04 11:51     ` David Howells
2020-12-07 13:10       ` Oliver Sang
2020-12-07 13:20       ` David Howells
2020-11-21 14:13 ` [PATCH 02/29] iov_iter: Split copy_page_to_iter() David Howells
2020-11-21 14:13 ` [PATCH 03/29] iov_iter: Split iov_iter_fault_in_readable David Howells
2020-11-21 14:13 ` [PATCH 04/29] iov_iter: Split the iterate_and_advance() macro David Howells
2020-11-21 14:14 ` [PATCH 05/29] iov_iter: Split copy_to_iter() David Howells
2020-11-21 14:14 ` [PATCH 06/29] iov_iter: Split copy_mc_to_iter() David Howells
2020-11-21 14:14 ` [PATCH 07/29] iov_iter: Split copy_from_iter() David Howells
2020-11-21 14:14 ` [PATCH 08/29] iov_iter: Split the iterate_all_kinds() macro David Howells
2020-11-21 14:14 ` [PATCH 09/29] iov_iter: Split copy_from_iter_full() David Howells
2020-11-21 14:14 ` [PATCH 10/29] iov_iter: Split copy_from_iter_nocache() David Howells
2020-11-21 14:14 ` [PATCH 11/29] iov_iter: Split copy_from_iter_flushcache() David Howells
2020-11-21 14:14 ` [PATCH 12/29] iov_iter: Split copy_from_iter_full_nocache() David Howells
2020-11-21 14:15 ` [PATCH 13/29] iov_iter: Split copy_page_from_iter() David Howells
2020-11-21 14:15 ` [PATCH 14/29] iov_iter: Split iov_iter_zero() David Howells
2020-11-21 14:15 ` [PATCH 15/29] iov_iter: Split copy_from_user_atomic() David Howells
2020-11-21 14:15 ` [PATCH 16/29] iov_iter: Split iov_iter_advance() David Howells
2020-11-21 14:15 ` [PATCH 17/29] iov_iter: Split iov_iter_revert() David Howells
2020-11-21 14:15 ` [PATCH 18/29] iov_iter: Split iov_iter_single_seg_count() David Howells
2020-11-21 14:15 ` [PATCH 19/29] iov_iter: Split iov_iter_alignment() David Howells
2020-11-21 14:15 ` [PATCH 20/29] iov_iter: Split iov_iter_gap_alignment() David Howells
2020-11-21 14:16 ` [PATCH 21/29] iov_iter: Split iov_iter_get_pages() David Howells
2020-11-21 14:16 ` [PATCH 22/29] iov_iter: Split iov_iter_get_pages_alloc() David Howells
2020-11-21 14:16 ` [PATCH 23/29] iov_iter: Split csum_and_copy_from_iter() David Howells
2020-11-21 14:16 ` [PATCH 24/29] iov_iter: Split csum_and_copy_from_iter_full() David Howells
2020-11-21 14:16 ` David Howells [this message]
2020-11-21 14:16 ` [PATCH 26/29] iov_iter: Split iov_iter_npages() David Howells
2020-11-21 14:16 ` [PATCH 27/29] iov_iter: Split dup_iter() David Howells
2020-11-21 14:17 ` [PATCH 28/29] iov_iter: Split iov_iter_for_each_range() David Howells
2020-11-21 14:17 ` [PATCH 29/29] iov_iter: Remove iterate_all_kinds() and iterate_and_advance() David Howells
2020-11-21 14:34 ` [PATCH 00/29] RFC: iov_iter: Switch to using an ops table Pavel Begunkov
2020-11-21 18:23 ` Linus Torvalds
2020-12-11  3:24 ` Matthew Wilcox

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=160596819702.154728.12031895151454434193.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).