Commit 62699b3f authored by Alexander Aring's avatar Alexander Aring Committed by David Teigland
Browse files

fs: dlm: move receive loop into receive handler



This patch moves the kernel_recvmsg() loop call into the
receive_from_sock() function instead of doing the loop outside the
function and abort the loop over it's return value.

Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
parent c51b0221
Loading
Loading
Loading
Loading
+31 −37
Original line number Diff line number Diff line
@@ -895,7 +895,6 @@ static int con_realloc_receive_buf(struct connection *con, int newlen)
/* Data received from remote end */
static int receive_from_sock(struct connection *con)
{
	int call_again_soon = 0;
	struct msghdr msg;
	struct kvec iov;
	int ret, buflen;
@@ -915,6 +914,7 @@ static int receive_from_sock(struct connection *con)
			goto out_resched;
	}

	for (;;) {
		/* calculate new buffer parameter regarding last receive and
		 * possible leftover bytes
		 */
@@ -925,10 +925,10 @@ static int receive_from_sock(struct connection *con)
		msg.msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL;
		ret = kernel_recvmsg(con->sock, &msg, &iov, 1, iov.iov_len,
				     msg.msg_flags);
	if (ret <= 0)
		if (ret == -EAGAIN)
			break;
		else if (ret <= 0)
			goto out_close;
	else if (ret == iov.iov_len)
		call_again_soon = 1;

		/* new buflen according readed bytes and leftover from last receive */
		buflen = ret + con->rx_leftover;
@@ -944,11 +944,8 @@ static int receive_from_sock(struct connection *con)
		if (con->rx_leftover) {
			memmove(con->rx_buf, con->rx_buf + ret,
				con->rx_leftover);
		call_again_soon = true;
		}

	if (call_again_soon)
		goto out_resched;
	}

	mutex_unlock(&con->sock_mutex);
	return 0;
@@ -1511,12 +1508,9 @@ int dlm_lowcomms_close(int nodeid)
static void process_recv_sockets(struct work_struct *work)
{
	struct connection *con = container_of(work, struct connection, rwork);
	int err;

	clear_bit(CF_READ_PENDING, &con->flags);
	do {
		err = receive_from_sock(con);
	} while (!err);
	receive_from_sock(con);
}

static void process_listen_recv_socket(struct work_struct *work)