diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-01-31 05:59:03 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-01-31 05:59:03 +0300 |
commit | 1ed2d76e0213751c82e3a242b61b0883daf330df (patch) | |
tree | 96c9d5d0fbb9c548ac448dea558b80632c266dc2 | |
parent | 8b0fdf631cf6a31f60a9ed3e1c0f37a9715de807 (diff) | |
parent | bc4802736d8b17eddde52e00838c348770f67c19 (diff) | |
download | linux-1ed2d76e0213751c82e3a242b61b0883daf330df.tar.xz |
Merge branch 'work.sock_recvmsg' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull kern_recvmsg reduction from Al Viro:
"kernel_recvmsg() is a set_fs()-using wrapper for sock_recvmsg(). In
all but one case that is not needed - use of ITER_KVEC for ->msg_iter
takes care of the data and does not care about set_fs(). The only
exception is svc_udp_recvfrom() where we want cmsg to be store into
kernel object; everything else can just use sock_recvmsg() and be done
with that.
A followup converting svc_udp_recvfrom() away from set_fs() (and
killing kernel_recvmsg() off) is *NOT* in here - I'd like to hear what
netdev folks think of the approach proposed in that followup)"
* 'work.sock_recvmsg' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
tipc: switch to sock_recvmsg()
smc: switch to sock_recvmsg()
ipvs: switch to sock_recvmsg()
mISDN: switch to sock_recvmsg()
drbd: switch to sock_recvmsg()
lustre lnet_sock_read(): switch to sock_recvmsg()
cfs2: switch to sock_recvmsg()
ncpfs: switch to sock_recvmsg()
dlm: switch to sock_recvmsg()
svc_recvfrom(): switch to sock_recvmsg()
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 8 | ||||
-rw-r--r-- | drivers/block/drbd/drbd_receiver.c | 3 | ||||
-rw-r--r-- | drivers/isdn/mISDN/l1oip_core.c | 22 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/lib-socket.c | 24 | ||||
-rw-r--r-- | fs/dlm/lowcomms.c | 4 | ||||
-rw-r--r-- | fs/ncpfs/sock.c | 3 | ||||
-rw-r--r-- | fs/ocfs2/cluster/tcp.c | 3 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_sync.c | 9 | ||||
-rw-r--r-- | net/smc/smc_clc.c | 18 | ||||
-rw-r--r-- | net/sunrpc/svcsock.c | 4 | ||||
-rw-r--r-- | net/tipc/server.c | 4 |
11 files changed, 46 insertions, 56 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 4b4697a1f963..0a0394aa1b9c 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -1847,7 +1847,7 @@ int drbd_send(struct drbd_connection *connection, struct socket *sock, void *buf, size_t size, unsigned msg_flags) { struct kvec iov = {.iov_base = buf, .iov_len = size}; - struct msghdr msg; + struct msghdr msg = {.msg_flags = msg_flags | MSG_NOSIGNAL}; int rv, sent = 0; if (!sock) @@ -1855,12 +1855,6 @@ int drbd_send(struct drbd_connection *connection, struct socket *sock, /* THINK if (signal_pending) return ... ? */ - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_control = NULL; - msg.msg_controllen = 0; - msg.msg_flags = msg_flags | MSG_NOSIGNAL; - iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iov, 1, size); if (sock == connection->data.socket) { diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index cb2fa63f6bc0..c72dee0ef083 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -516,7 +516,8 @@ static int drbd_recv_short(struct socket *sock, void *buf, size_t size, int flag struct msghdr msg = { .msg_flags = (flags ? flags : MSG_WAITALL | MSG_NOSIGNAL) }; - return kernel_recvmsg(sock, &msg, &iov, 1, size, msg.msg_flags); + iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &iov, 1, size); + return sock_recvmsg(sock, &msg, msg.msg_flags); } static int drbd_recv(struct drbd_connection *connection, void *buf, size_t size) diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c index e3654782a3e2..21d50e4cc5e1 100644 --- a/drivers/isdn/mISDN/l1oip_core.c +++ b/drivers/isdn/mISDN/l1oip_core.c @@ -645,8 +645,10 @@ l1oip_socket_thread(void *data) { struct l1oip *hc = (struct l1oip *)data; int ret = 0; - struct msghdr msg; struct sockaddr_in sin_rx; + struct kvec iov; + struct msghdr msg = {.msg_name = &sin_rx, + .msg_namelen = sizeof(sin_rx)}; unsigned char *recvbuf; size_t recvbuf_size = 1500; int recvlen; @@ -661,6 +663,9 @@ l1oip_socket_thread(void *data) goto fail; } + iov.iov_base = recvbuf; + iov.iov_len = recvbuf_size; + /* make daemon */ allow_signal(SIGTERM); @@ -697,12 +702,6 @@ l1oip_socket_thread(void *data) goto fail; } - /* build receive message */ - msg.msg_name = &sin_rx; - msg.msg_namelen = sizeof(sin_rx); - msg.msg_control = NULL; - msg.msg_controllen = 0; - /* build send message */ hc->sendmsg.msg_name = &hc->sin_remote; hc->sendmsg.msg_namelen = sizeof(hc->sin_remote); @@ -719,12 +718,9 @@ l1oip_socket_thread(void *data) printk(KERN_DEBUG "%s: socket created and open\n", __func__); while (!signal_pending(current)) { - struct kvec iov = { - .iov_base = recvbuf, - .iov_len = recvbuf_size, - }; - recvlen = kernel_recvmsg(socket, &msg, &iov, 1, - recvbuf_size, 0); + iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &iov, 1, + recvbuf_size); + recvlen = sock_recvmsg(socket, &msg, 0); if (recvlen > 0) { l1oip_socket_parse(hc, &sin_rx, recvbuf, recvlen); } else { diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c index 7d49d4865298..ed46aaca0ba3 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -314,19 +314,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, @@ -338,7 +339,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) @@ -347,10 +348,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) diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c index 05707850f93a..cff79ea0c01d 100644 --- a/fs/dlm/lowcomms.c +++ b/fs/dlm/lowcomms.c @@ -675,9 +675,9 @@ static int receive_from_sock(struct connection *con) nvec = 2; } len = iov[0].iov_len + iov[1].iov_len; + iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, iov, nvec, len); - r = ret = kernel_recvmsg(con->sock, &msg, iov, nvec, len, - MSG_DONTWAIT | MSG_NOSIGNAL); + r = ret = sock_recvmsg(con->sock, &msg, MSG_DONTWAIT | MSG_NOSIGNAL); if (ret <= 0) goto out_close; else if (ret == len) diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c index efb176b1751a..4c13174d85b7 100644 --- a/fs/ncpfs/sock.c +++ b/fs/ncpfs/sock.c @@ -39,7 +39,8 @@ static int _recv(struct socket *sock, void *buf, int size, unsigned flags) { struct msghdr msg = {NULL, }; struct kvec iov = {buf, size}; - return kernel_recvmsg(sock, &msg, &iov, 1, size, flags); + iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &iov, 1, size); + return sock_recvmsg(sock, &msg, flags); } static int _send(struct socket *sock, const void *buff, int len) diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index bebe59feca58..eac5140aac47 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -918,7 +918,8 @@ static int o2net_recv_tcp_msg(struct socket *sock, void *data, size_t len) { struct kvec vec = { .iov_len = len, .iov_base = data, }; struct msghdr msg = { .msg_flags = MSG_DONTWAIT, }; - return kernel_recvmsg(sock, &msg, &vec, 1, len, msg.msg_flags); + iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &vec, 1, len); + return sock_recvmsg(sock, &msg, MSG_DONTWAIT); } static int o2net_send_tcp_msg(struct socket *sock, struct kvec *vec, diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c index 9ee71cb276d7..fbaf3bd05b2e 100644 --- a/net/netfilter/ipvs/ip_vs_sync.c +++ b/net/netfilter/ipvs/ip_vs_sync.c @@ -1636,17 +1636,14 @@ static int ip_vs_receive(struct socket *sock, char *buffer, const size_t buflen) { struct msghdr msg = {NULL,}; - struct kvec iov; + struct kvec iov = {buffer, buflen}; int len; EnterFunction(7); /* Receive a packet */ - iov.iov_base = buffer; - iov.iov_len = (size_t)buflen; - - len = kernel_recvmsg(sock, &msg, &iov, 1, buflen, MSG_DONTWAIT); - + iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &iov, 1, buflen); + len = sock_recvmsg(sock, &msg, MSG_DONTWAIT); if (len < 0) return len; diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c index 1800e16b2a02..511548085d16 100644 --- a/net/smc/smc_clc.c +++ b/net/smc/smc_clc.c @@ -35,7 +35,7 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen, struct smc_clc_msg_hdr *clcm = buf; struct msghdr msg = {NULL, 0}; int reason_code = 0; - struct kvec vec; + struct kvec vec = {buf, buflen}; int len, datlen; int krflags; @@ -43,12 +43,15 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen, * so we don't consume any subsequent CLC message or payload data * in the TCP byte stream */ - vec.iov_base = buf; - vec.iov_len = buflen; + /* + * Caller must make sure that buflen is no less than + * sizeof(struct smc_clc_msg_hdr) + */ krflags = MSG_PEEK | MSG_WAITALL; smc->clcsock->sk->sk_rcvtimeo = CLC_WAIT_TIME; - len = kernel_recvmsg(smc->clcsock, &msg, &vec, 1, - sizeof(struct smc_clc_msg_hdr), krflags); + iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &vec, 1, + sizeof(struct smc_clc_msg_hdr)); + len = sock_recvmsg(smc->clcsock, &msg, krflags); if (signal_pending(current)) { reason_code = -EINTR; clc_sk->sk_err = EINTR; @@ -83,12 +86,11 @@ int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen, } /* receive the complete CLC message */ - vec.iov_base = buf; - vec.iov_len = buflen; memset(&msg, 0, sizeof(struct msghdr)); + iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &vec, 1, buflen); krflags = MSG_WAITALL; smc->clcsock->sk->sk_rcvtimeo = CLC_WAIT_TIME; - len = kernel_recvmsg(smc->clcsock, &msg, &vec, 1, datlen, krflags); + len = sock_recvmsg(smc->clcsock, &msg, krflags); if (len < datlen) { smc->sk.sk_err = EPROTO; reason_code = -EPROTO; diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index ff8e06cd067e..5570719e4787 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -338,8 +338,8 @@ static int svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, rqstp->rq_xprt_hlen = 0; clear_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags); - len = kernel_recvmsg(svsk->sk_sock, &msg, iov, nr, buflen, - msg.msg_flags); + iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, iov, nr, buflen); + len = sock_recvmsg(svsk->sk_sock, &msg, msg.msg_flags); /* If we read a full record, then assume there may be more * data to read (stream based sockets only!) */ diff --git a/net/tipc/server.c b/net/tipc/server.c index d60c30342327..78a292a84afc 100644 --- a/net/tipc/server.c +++ b/net/tipc/server.c @@ -264,8 +264,8 @@ static int tipc_receive_from_sock(struct tipc_conn *con) iov.iov_base = buf; iov.iov_len = s->max_rcvbuf_size; msg.msg_name = &addr; - ret = kernel_recvmsg(con->sock, &msg, &iov, 1, iov.iov_len, - MSG_DONTWAIT); + iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &iov, 1, iov.iov_len); + ret = sock_recvmsg(con->sock, &msg, MSG_DONTWAIT); if (ret <= 0) { kmem_cache_free(s->rcvbuf_cache, buf); goto out_close; |