Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ed2d76e authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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()
parents 8b0fdf63 bc480273
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -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) {
+2 −1
Original line number Diff line number Diff line
@@ -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)
+9 −13
Original line number Diff line number Diff line
@@ -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 {
+11 −13
Original line number Diff line number Diff line
@@ -314,11 +314,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
@@ -327,6 +322,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,
@@ -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)
+2 −2
Original line number Diff line number Diff line
@@ -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)
Loading