Subject: linux-next: build failure after merge of the gfs2 tree

From: Stephen Rothwell <[email-masked]>
Date: Wed, 9 Jun 2021 13:07:51 +1000

Hi all,

After merging the gfs2 tree, today's linux-next build (powerpc
ppc64_defconfig) failed like this:

Caused by commit

  f8524fce6a88 ("iov_iter: Add iov_iter_fault_in_writeable()")

interacting with commits

  e59c7577f5d6 ("iov_iter: separate direction from flavour")
  30da2b24a3ed ("iov_iter: make the amount already copied available to iterator callbacks")

from the vfs tree.

I have applied the following fix up patch (I think it is mostly right?)

From: Stephen Rothwell <[email-masked]>
Date: Wed, 9 Jun 2021 12:51:59 +1000
Subject: [PATCH] iov_iter: fix up for iov changes

Signed-off-by: Stephen Rothwell <[email-masked]>
---
 lib/iov_iter.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index d225e827b22a..b2d7289dc729 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -462,17 +462,23 @@ EXPORT_SYMBOL(iov_iter_fault_in_readable);
 
 int iov_iter_fault_in_writeable(struct iov_iter *i, size_t bytes)
 {
-	size_t skip = i->iov_offset;
-	const struct iovec *iov;
-	int err;
-	struct iovec v;
+	if (iter_is_iovec(i)) {
+		const struct iovec *p;
+		size_t skip;
 
-	if (!(i->type & (ITER_BVEC|ITER_KVEC))) {
-		iterate_iovec(i, bytes, v, iov, skip, ({
-			err = fault_in_pages_writeable(v.iov_base, v.iov_len);
+		if (bytes > i->count)
+			bytes = i->count;
+		for (p = i->iov, skip = i->iov_offset; bytes; p++, skip = 0) {
+			size_t len = min(bytes, p->iov_len - skip);
+			int err;
+
+			if (unlikely(!len))
+				continue;
+			err = fault_in_pages_writeable(p->iov_base + skip, len);
 			if (unlikely(err))
 				return err;
-		0;}))
+			bytes -= len;
+		}
 	}
 	return 0;
 }
-- 
2.30.2

-- 
Cheers,
Stephen Rothwell