Commit fd25dc34 authored by Al Viro's avatar Al Viro Committed by Greg Kroah-Hartman

lustre: switch lnet_sock_write() to sock_sendmsg()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2afad7fc
...@@ -265,21 +265,17 @@ lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout) ...@@ -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); long jiffies_left = timeout * msecs_to_jiffies(MSEC_PER_SEC);
unsigned long then; unsigned long then;
struct timeval tv; struct timeval tv;
struct kvec iov = { .iov_base = buffer, .iov_len = nob };
struct msghdr msg = {NULL,};
LASSERT(nob > 0); LASSERT(nob > 0);
/* /*
* Caller may pass a zero timeout if she thinks the socket buffer is * Caller may pass a zero timeout if she thinks the socket buffer is
* empty enough to take the whole message immediately * empty enough to take the whole message immediately
*/ */
iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iov, 1, nob);
for (;;) { for (;;) {
struct kvec iov = { msg.msg_flags = !timeout ? MSG_DONTWAIT : 0;
.iov_base = buffer,
.iov_len = nob
};
struct msghdr msg = {
.msg_flags = !timeout ? MSG_DONTWAIT : 0
};
if (timeout) { if (timeout) {
/* Set send timeout to remaining time */ /* Set send timeout to remaining time */
jiffies_to_timeval(jiffies_left, &tv); jiffies_to_timeval(jiffies_left, &tv);
...@@ -296,9 +292,6 @@ lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout) ...@@ -296,9 +292,6 @@ lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout)
rc = kernel_sendmsg(sock, &msg, &iov, 1, nob); rc = kernel_sendmsg(sock, &msg, &iov, 1, nob);
jiffies_left -= jiffies - then; jiffies_left -= jiffies - then;
if (rc == nob)
return 0;
if (rc < 0) if (rc < 0)
return rc; return rc;
...@@ -307,11 +300,11 @@ lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout) ...@@ -307,11 +300,11 @@ lnet_sock_write(struct socket *sock, void *buffer, int nob, int timeout)
return -ECONNABORTED; return -ECONNABORTED;
} }
if (!msg_data_left(&msg))
break;
if (jiffies_left <= 0) if (jiffies_left <= 0)
return -EAGAIN; return -EAGAIN;
buffer = ((char *)buffer) + rc;
nob -= rc;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment