summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-09-20 20:01:11 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-12-02 20:38:05 -0500
commit985832267da5698c2a3b90f6cc920ac49fe7cf1e (patch)
tree98c5d21a22724ec700f7d0090347e47a30626089
parente749d4facf24190ab1549886f69ab16880f5d234 (diff)
downloadlinux-985832267da5698c2a3b90f6cc920ac49fe7cf1e.tar.bz2
lustre lnet_sock_read(): switch to sock_recvmsg()
... and don't bother reinitializing msg.msg_iter Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-socket.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c
index 539a26444f31..984d76843b19 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-socket.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c
@@ -318,19 +318,20 @@ 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;
+ struct kvec iov = {
+ .iov_base = buffer,
+ .iov_len = nob
+ };
+ struct msghdr msg = {
+ .msg_flags = 0
+ };
LASSERT(nob > 0);
LASSERT(jiffies_left > 0);
- for (;;) {
- struct kvec iov = {
- .iov_base = buffer,
- .iov_len = nob
- };
- struct msghdr msg = {
- .msg_flags = 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)