[PATCH 09/29] iov_iter: Split copy_from_iter_full()

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

 



Split copy_from_iter_full() by type.

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

 lib/iov_iter.c |   59 +++++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 41 insertions(+), 18 deletions(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 934193627540..3dba665a1ee9 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -923,32 +923,55 @@ static size_t no_copy_from_iter(void *addr, size_t bytes, struct iov_iter *i)
 	return bytes;
 }
 
-static bool xxx_copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i)
+static bool iovec_copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i)
 {
 	char *to = addr;
-	if (unlikely(iov_iter_is_pipe(i))) {
-		WARN_ON(1);
-		return false;
-	}
+
 	if (unlikely(i->count < bytes))
 		return false;
 
-	if (iter_is_iovec(i))
-		might_fault();
-	iterate_all_kinds(i, bytes, v, ({
+	might_fault();
+	iterate_over_iovec(i, bytes, v, ({
 		if (copyin((to += v.iov_len) - v.iov_len,
-				      v.iov_base, v.iov_len))
+			   v.iov_base, v.iov_len))
 			return false;
-		0;}),
+		0;}));
+	iov_iter_advance(i, bytes);
+	return true;
+}
+
+static bool bvec_copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i)
+{
+	char *to = addr;
+
+	if (unlikely(i->count < bytes))
+		return false;
+	iterate_over_bvec(i, bytes, v,
 		memcpy_from_page((to += v.bv_len) - v.bv_len, v.bv_page,
-				 v.bv_offset, v.bv_len),
-		memcpy((to += v.iov_len) - v.iov_len, v.iov_base, v.iov_len)
-	)
+				 v.bv_offset, v.bv_len));
+	iov_iter_advance(i, bytes);
+	return true;
+}
+
+static bool kvec_copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i)
+{
+	char *to = addr;
 
+	if (unlikely(i->count < bytes))
+		return false;
+
+	iterate_over_kvec(i, bytes, v,
+	       memcpy((to += v.iov_len) - v.iov_len, v.iov_base, v.iov_len));
 	iov_iter_advance(i, bytes);
 	return true;
 }
 
+static bool no_copy_from_iter_full(void *addr, size_t bytes, struct iov_iter *i)
+{
+	WARN_ON(1);
+	return false;
+}
+
 static size_t xxx_copy_from_iter_nocache(void *addr, size_t bytes, struct iov_iter *i)
 {
 	char *to = addr;
@@ -1985,7 +2008,7 @@ static const struct iov_iter_ops iovec_iter_ops = {
 	.copy_page_from_iter		= xxx_copy_page_from_iter,
 	.copy_to_iter			= iovec_copy_to_iter,
 	.copy_from_iter			= iovec_copy_from_iter,
-	.copy_from_iter_full		= xxx_copy_from_iter_full,
+	.copy_from_iter_full		= iovec_copy_from_iter_full,
 	.copy_from_iter_nocache		= xxx_copy_from_iter_nocache,
 	.copy_from_iter_full_nocache	= xxx_copy_from_iter_full_nocache,
 #ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE
@@ -2019,7 +2042,7 @@ static const struct iov_iter_ops kvec_iter_ops = {
 	.copy_page_from_iter		= xxx_copy_page_from_iter,
 	.copy_to_iter			= kvec_copy_to_iter,
 	.copy_from_iter			= kvec_copy_from_iter,
-	.copy_from_iter_full		= xxx_copy_from_iter_full,
+	.copy_from_iter_full		= kvec_copy_from_iter_full,
 	.copy_from_iter_nocache		= xxx_copy_from_iter_nocache,
 	.copy_from_iter_full_nocache	= xxx_copy_from_iter_full_nocache,
 #ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE
@@ -2053,7 +2076,7 @@ static const struct iov_iter_ops bvec_iter_ops = {
 	.copy_page_from_iter		= xxx_copy_page_from_iter,
 	.copy_to_iter			= bvec_copy_to_iter,
 	.copy_from_iter			= bvec_copy_from_iter,
-	.copy_from_iter_full		= xxx_copy_from_iter_full,
+	.copy_from_iter_full		= bvec_copy_from_iter_full,
 	.copy_from_iter_nocache		= xxx_copy_from_iter_nocache,
 	.copy_from_iter_full_nocache	= xxx_copy_from_iter_full_nocache,
 #ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE
@@ -2087,7 +2110,7 @@ static const struct iov_iter_ops pipe_iter_ops = {
 	.copy_page_from_iter		= xxx_copy_page_from_iter,
 	.copy_to_iter			= pipe_copy_to_iter,
 	.copy_from_iter			= no_copy_from_iter,
-	.copy_from_iter_full		= xxx_copy_from_iter_full,
+	.copy_from_iter_full		= no_copy_from_iter_full,
 	.copy_from_iter_nocache		= xxx_copy_from_iter_nocache,
 	.copy_from_iter_full_nocache	= xxx_copy_from_iter_full_nocache,
 #ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE
@@ -2121,7 +2144,7 @@ static const struct iov_iter_ops discard_iter_ops = {
 	.copy_page_from_iter		= xxx_copy_page_from_iter,
 	.copy_to_iter			= discard_copy_to_iter,
 	.copy_from_iter			= no_copy_from_iter,
-	.copy_from_iter_full		= xxx_copy_from_iter_full,
+	.copy_from_iter_full		= no_copy_from_iter_full,
 	.copy_from_iter_nocache		= xxx_copy_from_iter_nocache,
 	.copy_from_iter_full_nocache	= xxx_copy_from_iter_full_nocache,
 #ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux