Commit 98583226 authored by Al Viro's avatar Al Viro

lustre lnet_sock_read(): switch to sock_recvmsg()

... and don't bother reinitializing msg.msg_iter
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent e749d4fa
...@@ -318,11 +318,6 @@ lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout) ...@@ -318,11 +318,6 @@ lnet_sock_read(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;
LASSERT(nob > 0);
LASSERT(jiffies_left > 0);
for (;;) {
struct kvec iov = { struct kvec iov = {
.iov_base = buffer, .iov_base = buffer,
.iov_len = nob .iov_len = nob
...@@ -331,6 +326,12 @@ lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout) ...@@ -331,6 +326,12 @@ lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout)
.msg_flags = 0 .msg_flags = 0
}; };
LASSERT(nob > 0);
LASSERT(jiffies_left > 0);
iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &iov, 1, nob);
for (;;) {
/* Set receive timeout to remaining time */ /* Set receive timeout to remaining time */
jiffies_to_timeval(jiffies_left, &tv); jiffies_to_timeval(jiffies_left, &tv);
rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
...@@ -342,7 +343,7 @@ lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout) ...@@ -342,7 +343,7 @@ lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout)
} }
then = jiffies; then = jiffies;
rc = kernel_recvmsg(sock, &msg, &iov, 1, nob, 0); rc = sock_recvmsg(sock, &msg, 0);
jiffies_left -= jiffies - then; jiffies_left -= jiffies - then;
if (rc < 0) if (rc < 0)
...@@ -351,10 +352,7 @@ lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout) ...@@ -351,10 +352,7 @@ lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout)
if (!rc) if (!rc)
return -ECONNRESET; return -ECONNRESET;
buffer = ((char *)buffer) + rc; if (!msg_data_left(&msg))
nob -= rc;
if (!nob)
return 0; return 0;
if (jiffies_left <= 0) if (jiffies_left <= 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