[Devel] [PATCH RHEL7 COMMIT] fuse kio: Get msg size in second argument of pcs_sockio::get_msg()

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jun 25 19:04:24 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.15
------>
commit f7b0a6b484daa48342e534ba2244dcc8c2a37aa8
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Mon Jun 25 19:04:24 2018 +0300

    fuse kio: Get msg size in second argument of pcs_sockio::get_msg()
    
    The patch makes pcs_sockio::get_msg() to populate msg_size,
    and to store it in pcs_sockio::current_msg_size.
    
    This will be used in next patch to skip allocation of msg,
    which are going to be dropped.
    
    https://pmc.acronis.com/browse/VSTOR-11208
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    ============================================
    Patchset description:
    fuse kio: Add trash message handler
    
    This patchset adds a possibility to handle big messages,
    which we are going to drop, in the special way.
    It makes the code to avoid message allocation. Instead of this,
    we read messages in trash buffer, and this action removes
    the trash message data from socket.
    
    All the changes in pcs_sockio_recv() are made in generic way
    via helpers, and the view of the branches and algorhythm remains
    the same.
    
    https://pmc.acronis.com/browse/VSTOR-11208
    
    Kirill Tkhai (2):
          fuse kio: Get msg size in second argument of pcs_sockio::get_msg()
          fuse kio: Skip processing of messages above PAGE_SIZE size
---
 fs/fuse/kio/pcs/pcs_rpc.c     |  7 ++++---
 fs/fuse/kio/pcs/pcs_sock_io.c | 15 +++++++++------
 fs/fuse/kio/pcs/pcs_sock_io.h |  3 ++-
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_rpc.c b/fs/fuse/kio/pcs/pcs_rpc.c
index 9977661b1e11..3294f6cdf360 100644
--- a/fs/fuse/kio/pcs/pcs_rpc.c
+++ b/fs/fuse/kio/pcs/pcs_rpc.c
@@ -495,7 +495,7 @@ void rpc_work_input(struct pcs_msg * msg)
 	pcs_free_msg(msg);
 }
 
-struct pcs_msg * rpc_get_hdr(struct pcs_sockio * sio)
+struct pcs_msg *rpc_get_hdr(struct pcs_sockio * sio, u32 *msg_size)
 {
 	struct pcs_rpc * ep = sio->parent;
 	struct pcs_rpc_hdr * h = (struct pcs_rpc_hdr*)sio_inline_buffer(sio);
@@ -517,7 +517,7 @@ struct pcs_msg * rpc_get_hdr(struct pcs_sockio * sio)
 		if (ep->ops->get_hdr) {
 			msg = ep->ops->get_hdr(ep, h);
 			if (msg)
-				return msg;
+				goto found;
 		}
 		next_input = rpc_work_input;
 		break;
@@ -536,8 +536,9 @@ struct pcs_msg * rpc_get_hdr(struct pcs_sockio * sio)
 
 	memcpy(msg->_inline_buffer, h, sizeof(struct pcs_rpc_hdr));
 	msg->done = next_input;
-	msg->size = h->len;
 	msg->private = NULL;
+found:
+	*msg_size = msg->size = h->len;
 	return msg;
 }
 
diff --git a/fs/fuse/kio/pcs/pcs_sock_io.c b/fs/fuse/kio/pcs/pcs_sock_io.c
index 29cd199dffa0..907261400b36 100644
--- a/fs/fuse/kio/pcs/pcs_sock_io.c
+++ b/fs/fuse/kio/pcs/pcs_sock_io.c
@@ -155,6 +155,7 @@ static void pcs_sockio_recv(struct pcs_sockio *sio)
 	struct iov_iter *it = &sio->read_iter;
 	struct pcs_rpc *ep = sio->parent;
 	int count = 0;
+	u32 msg_size;
 	unsigned long loop_timeout = jiffies + PCS_SIO_SLICE;
 
 	(void)ep;
@@ -184,7 +185,7 @@ static void pcs_sockio_recv(struct pcs_sockio *sio)
 				if(sio->hdr_ptr != sio->hdr_max)
 					return;
 
-				msg = sio->get_msg(sio);
+				msg = sio->get_msg(sio, &msg_size);
 				if (msg == NULL) {
 					if (sio->hdr_ptr < sio->hdr_max)
 						continue;
@@ -196,6 +197,7 @@ static void pcs_sockio_recv(struct pcs_sockio *sio)
 				sio->read_offset = sio->hdr_ptr;
 				sio->hdr_ptr = 0;
 				sio->current_msg = msg;
+				sio->current_msg_size = msg_size;
 				msg->get_iter(msg, sio->read_offset, it);
 				TRACE(PEER_FMT" msg:%p read_off:%d iov_size:%ld\n", PEER_ARGS(ep), msg, sio->read_offset,
 				      iov_iter_count(it));
@@ -208,8 +210,9 @@ static void pcs_sockio_recv(struct pcs_sockio *sio)
 			}
 		} else { /* Continue recevining message */
 			msg = sio->current_msg;
+			msg_size = sio->current_msg_size;;
 
-			while (sio->read_offset < msg->size) {
+			while (sio->read_offset < msg_size) {
 				void *buf;
 				size_t len;
 				struct page *page;
@@ -219,14 +222,14 @@ static void pcs_sockio_recv(struct pcs_sockio *sio)
 					msg->get_iter(msg, sio->read_offset, it);
 
 				TRACE(PEER_FMT" msg:%p->size:%d off:%d it_count:%ld\n",
-				      PEER_ARGS(ep), msg, msg->size, sio->read_offset,
+				      PEER_ARGS(ep), msg, msg_size, sio->read_offset,
 				      iov_iter_count(it));
 
-				BUG_ON(iov_iter_count(it) > msg->size - sio->read_offset);
+				BUG_ON(iov_iter_count(it) > msg_size - sio->read_offset);
 
 				page = iov_iter_kmap(it, &buf, &len);
-				if (len > msg->size - sio->read_offset)
-					len = msg->size - sio->read_offset;
+				if (len > msg_size - sio->read_offset)
+					len = msg_size - sio->read_offset;
 				n = do_sock_recv(conn->socket, buf, len);
 				if (page)
 					kunmap(page);
diff --git a/fs/fuse/kio/pcs/pcs_sock_io.h b/fs/fuse/kio/pcs/pcs_sock_io.h
index af5443017de4..83f5ca356707 100644
--- a/fs/fuse/kio/pcs/pcs_sock_io.h
+++ b/fs/fuse/kio/pcs/pcs_sock_io.h
@@ -126,12 +126,13 @@ struct pcs_sockio
 	u32			retrans;
 
 	struct pcs_msg		*current_msg;
+	u32			current_msg_size;
 	int			read_offset;
 	int			write_offset;
 	struct iov_iter		read_iter;
 	struct iov_iter		write_iter;
 	struct mutex		mutex;
-	struct pcs_msg *	(*get_msg)(struct pcs_sockio *);
+	struct pcs_msg *	(*get_msg)(struct pcs_sockio *, u32 *);
 	/* eof() handler could be called twice: once on graceful socket shutdown and from sio_abort() */
 	void			(*eof)(struct pcs_sockio *);
 	void			(*write_wakeup)(struct pcs_sockio *);


More information about the Devel mailing list