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)
long jiffies_left = timeout * msecs_to_jiffies(MSEC_PER_SEC);
unsigned long then;
struct timeval tv;
LASSERT(nob > 0);
LASSERT(jiffies_left > 0);
for (;;) {
struct kvec iov = {
.iov_base = buffer,
.iov_len = nob
......@@ -331,6 +326,12 @@ lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout)
.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 */
jiffies_to_timeval(jiffies_left, &tv);
rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
......@@ -342,7 +343,7 @@ lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout)
}
then = jiffies;
rc = kernel_recvmsg(sock, &msg, &iov, 1, nob, 0);
rc = sock_recvmsg(sock, &msg, 0);
jiffies_left -= jiffies - then;
if (rc < 0)
......@@ -351,10 +352,7 @@ lnet_sock_read(struct socket *sock, void *buffer, int nob, int timeout)
if (!rc)
return -ECONNRESET;
buffer = ((char *)buffer) + rc;
nob -= rc;
if (!nob)
if (!msg_data_left(&msg))
return 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