public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Drokin <green@linuxhacker.ru>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org,
	Andreas Dilger <andreas.dilger@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Lustre Development List <lustre-devel@lists.lustre.org>,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH 01/15] lustre: switch lnet_sock_write() to sock_sendmsg()
Date: Sat, 23 Jul 2016 02:36:58 -0400	[thread overview]
Message-ID: <1469255832-746785-2-git-send-email-green@linuxhacker.ru> (raw)
In-Reply-To: <1469255832-746785-1-git-send-email-green@linuxhacker.ru>

From: Al Viro <viro@zeniv.linux.org.uk>

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 drivers/staging/lustre/lnet/lnet/lib-socket.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c
index 891fd59..4e6dd51 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-socket.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -265,21 +265,17 @@ lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout)
 	long jiffies_left = timeout * msecs_to_jiffies(MSEC_PER_SEC);
 	unsigned long then;
 	struct timeval tv;
+	struct kvec  iov = { .iov_base = buffer, .iov_len  = nob };
+	struct msghdr msg = {NULL,};
 
 	LASSERT(nob > 0);
 	/*
 	 * Caller may pass a zero timeout if she thinks the socket buffer is
 	 * empty enough to take the whole message immediately
 	 */
+	iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iov, 1, nob);
 	for (;;) {
-		struct kvec  iov = {
-			.iov_base = buffer,
-			.iov_len  = nob
-		};
-		struct msghdr msg = {
-			.msg_flags      = !timeout ? MSG_DONTWAIT : 0
-		};
-
+		msg.msg_flags = !timeout ? MSG_DONTWAIT : 0;
 		if (timeout) {
 			/* Set send timeout to remaining time */
 			jiffies_to_timeval(jiffies_left, &tv);
@@ -296,9 +292,6 @@ lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout)
 		rc = kernel_sendmsg(sock, &msg, &iov, 1, nob);
 		jiffies_left -= jiffies - then;
 
-		if (rc == nob)
-			return 0;
-
 		if (rc < 0)
 			return rc;
 
@@ -307,11 +300,11 @@ lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout)
 			return -ECONNABORTED;
 		}
 
+		if (!msg_data_left(&msg))
+			break;
+
 		if (jiffies_left <= 0)
 			return -EAGAIN;
-
-		buffer = ((char *)buffer) + rc;
-		nob -= rc;
 	}
 	return 0;
 }
-- 
2.7.4

  reply	other threads:[~2016-07-23  6:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-23  6:36 [PATCH 00/15] Lustre cleanups Oleg Drokin
2016-07-23  6:36 ` Oleg Drokin [this message]
2016-07-23  6:36 ` [PATCH 02/15] lustre: simplify the living hell out of ksocknal_lib_recv_kiov() Oleg Drokin
2016-07-23  6:37 ` [PATCH 03/15] lustre: don't reinvent struct bio_vec Oleg Drokin
2016-07-23  6:37 ` [PATCH 04/15] ksocknal_lib_recv_iov(): recvmsg doesn't bugger iovec anymore Oleg Drokin
2016-07-23  6:37 ` [PATCH 05/15] ksocknal_lib_send_iov(): sendmsg doesn't bugger iovec Oleg Drokin
2016-07-23  6:37 ` [PATCH 06/15] ksocknal_lib_send_kiov(): " Oleg Drokin
2016-07-23  6:37 ` [PATCH 07/15] lustre: ->kss_scratch... are unused now Oleg Drokin
2016-08-15 16:55   ` Greg Kroah-Hartman
2016-07-23  6:37 ` [PATCH 08/15] lustre: constify lib-move.c stuff Oleg Drokin
2016-07-23  6:37 ` [PATCH 09/15] lustre: pass iov_iter to ->lnd_recv() Oleg Drokin
2016-07-23  6:37 ` [PATCH 10/15] lustre: introduce lnet_copy_{k,}iov2iter(), kill lnet_copy_{k,}iov2{k,}iov() Oleg Drokin
2016-07-23  6:37 ` [PATCH 11/15] staging/lustre: Always return EEXIST on mkdir for existing names Oleg Drokin
2016-07-23  6:37 ` [PATCH 12/15] staging/lustre: Add spaces preferred around that '{+,-,*,/,|,<<,>>,&}' Oleg Drokin
2016-07-23 17:31   ` Joe Perches
2016-07-23 18:01     ` Oleg Drokin
2016-07-26  1:47       ` Joe Perches
2016-07-23  6:37 ` [PATCH 13/15] staging/lustre: Fix unnecessary parentheses around variables Oleg Drokin
2016-07-23  6:37 ` [PATCH 14/15] staging/lustre: Make alignment match open parenthesis Oleg Drokin
2016-07-23  6:37 ` [PATCH 15/15] staging/lustre: Remove unused cp_error from struct cl_page Oleg Drokin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1469255832-746785-2-git-send-email-green@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox