[PATCH 24/29] iov_iter: Split csum_and_copy_from_iter_full()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Split csum_and_copy_from_iter_full() by type.

Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
---

 lib/iov_iter.c |   62 ++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 47 insertions(+), 15 deletions(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 1f596cffddf9..8820a9e72815 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1841,20 +1841,16 @@ static size_t no_csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum,
 	return 0;
 }
 
-static bool xxx_csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum,
+static bool iovec_csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum,
 			       struct iov_iter *i)
 {
 	char *to = addr;
 	__wsum sum, next;
 	size_t off = 0;
 	sum = *csum;
-	if (unlikely(iov_iter_is_pipe(i) || iov_iter_is_discard(i))) {
-		WARN_ON(1);
-		return false;
-	}
 	if (unlikely(i->count < bytes))
 		return false;
-	iterate_all_kinds(i, bytes, v, ({
+	iterate_over_iovec(i, bytes, v, ({
 		next = csum_and_copy_from_user(v.iov_base,
 					       (to += v.iov_len) - v.iov_len,
 					       v.iov_len);
@@ -1863,25 +1859,61 @@ static bool xxx_csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *c
 		sum = csum_block_add(sum, next, off);
 		off += v.iov_len;
 		0;
-	}), ({
+	}));
+	*csum = sum;
+	iov_iter_advance(i, bytes);
+	return true;
+}
+
+static bool bvec_csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum,
+			       struct iov_iter *i)
+{
+	char *to = addr;
+	__wsum sum;
+	size_t off = 0;
+	sum = *csum;
+	if (unlikely(i->count < bytes))
+		return false;
+	iterate_over_bvec(i, bytes, v, ({
 		char *p = kmap_atomic(v.bv_page);
 		sum = csum_and_memcpy((to += v.bv_len) - v.bv_len,
 				      p + v.bv_offset, v.bv_len,
 				      sum, off);
 		kunmap_atomic(p);
 		off += v.bv_len;
-	}),({
+	}));
+	*csum = sum;
+	iov_iter_advance(i, bytes);
+	return true;
+}
+
+static bool kvec_csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum,
+			       struct iov_iter *i)
+{
+	char *to = addr;
+	__wsum sum;
+	size_t off = 0;
+	sum = *csum;
+	if (unlikely(i->count < bytes))
+		return false;
+	iterate_over_kvec(i, bytes, v, ({
 		sum = csum_and_memcpy((to += v.iov_len) - v.iov_len,
 				      v.iov_base, v.iov_len,
 				      sum, off);
 		off += v.iov_len;
-	})
-	)
+	}));
 	*csum = sum;
 	iov_iter_advance(i, bytes);
 	return true;
 }
 
+static bool no_csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum,
+			       struct iov_iter *i)
+{
+	WARN_ON(1);
+	return false;
+}
+
 static size_t xxx_csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump,
 			     struct iov_iter *i)
 {
@@ -2226,7 +2258,7 @@ static const struct iov_iter_ops iovec_iter_ops = {
 #endif
 	.csum_and_copy_to_iter		= xxx_csum_and_copy_to_iter,
 	.csum_and_copy_from_iter	= iovec_csum_and_copy_from_iter,
-	.csum_and_copy_from_iter_full	= xxx_csum_and_copy_from_iter_full,
+	.csum_and_copy_from_iter_full	= iovec_csum_and_copy_from_iter_full,
 
 	.zero				= iovec_zero,
 	.alignment			= iovec_alignment,
@@ -2260,7 +2292,7 @@ static const struct iov_iter_ops kvec_iter_ops = {
 #endif
 	.csum_and_copy_to_iter		= xxx_csum_and_copy_to_iter,
 	.csum_and_copy_from_iter	= kvec_csum_and_copy_from_iter,
-	.csum_and_copy_from_iter_full	= xxx_csum_and_copy_from_iter_full,
+	.csum_and_copy_from_iter_full	= kvec_csum_and_copy_from_iter_full,
 
 	.zero				= kvec_zero,
 	.alignment			= kvec_alignment,
@@ -2294,7 +2326,7 @@ static const struct iov_iter_ops bvec_iter_ops = {
 #endif
 	.csum_and_copy_to_iter		= xxx_csum_and_copy_to_iter,
 	.csum_and_copy_from_iter	= bvec_csum_and_copy_from_iter,
-	.csum_and_copy_from_iter_full	= xxx_csum_and_copy_from_iter_full,
+	.csum_and_copy_from_iter_full	= bvec_csum_and_copy_from_iter_full,
 
 	.zero				= bvec_zero,
 	.alignment			= bvec_alignment,
@@ -2328,7 +2360,7 @@ static const struct iov_iter_ops pipe_iter_ops = {
 #endif
 	.csum_and_copy_to_iter		= xxx_csum_and_copy_to_iter,
 	.csum_and_copy_from_iter	= no_csum_and_copy_from_iter,
-	.csum_and_copy_from_iter_full	= xxx_csum_and_copy_from_iter_full,
+	.csum_and_copy_from_iter_full	= no_csum_and_copy_from_iter_full,
 
 	.zero				= pipe_zero,
 	.alignment			= pipe_alignment,
@@ -2362,7 +2394,7 @@ static const struct iov_iter_ops discard_iter_ops = {
 #endif
 	.csum_and_copy_to_iter		= xxx_csum_and_copy_to_iter,
 	.csum_and_copy_from_iter	= no_csum_and_copy_from_iter,
-	.csum_and_copy_from_iter_full	= xxx_csum_and_copy_from_iter_full,
+	.csum_and_copy_from_iter_full	= no_csum_and_copy_from_iter_full,
 
 	.zero				= discard_zero,
 	.alignment			= no_alignment,





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux