[Devel] [PATCH vz9] fs/fuse kio: use iov_iter_get_pages2() + iov_iter_revert() scheme in do_recv_one_seg()

Konstantin Khorenko khorenko at virtuozzo.com
Thu Mar 7 19:05:42 MSK 2024


Mainstream has deprecated iov_iter_get_pages() + iov_iter_advance()
scheme in favour of iov_iter_get_pages2() + iov_iter_revert(), so we
have to use the new scheme as well.

Fixes: 75259bc81b21 ("fs/fuse kio: remove iov_iter_for_each_range()
usage")

The problem has appeared on rebasing to RHEL9.4 BETA 5.14.0-425.el9
kernel:
https://virtuozzo.atlassian.net/browse/PSBM-154941

Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_sock_io.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_sock_io.c b/fs/fuse/kio/pcs/pcs_sock_io.c
index 46de1023c876..189cf5c98c7d 100644
--- a/fs/fuse/kio/pcs/pcs_sock_io.c
+++ b/fs/fuse/kio/pcs/pcs_sock_io.c
@@ -226,10 +226,15 @@ static int do_recv_one_seg(struct socket *sock, struct iov_iter *it, size_t left
 		ssize_t len;
 		struct page* page;
 
-		len = iov_iter_get_pages(it, &page, size, 1, &offset);
+		len = iov_iter_get_pages2(it, &page, size, 1, &offset);
 		BUG_ON(len <=0);
 
 		ret = do_sock_recv(sock, kmap(page) + offset, len);
+		if (ret <= 0)
+			iov_iter_revert(it, len);
+		else if (ret < len)
+			iov_iter_revert(it, len - ret);
+
 		kunmap(page);
 		put_page(page);
 	}
@@ -313,7 +318,6 @@ static void pcs_sockio_recv(struct pcs_sockio *sio)
 				n = do_recv_one_seg(sio->socket, it, (size_t)(msg_size - sio->read_offset));
 				if (n > 0) {
 					sio->read_offset += n;
-					iov_iter_advance(it, n);
 				} else {
 					if (n == -EAGAIN || n == 0)
 						return;
-- 
2.39.3



More information about the Devel mailing list