Commit 66d5955a authored by Alexander Aring's avatar Alexander Aring Committed by David Teigland

fs: dlm: introduce con_next_wq helper

This patch introduce a function to determine if something is ready to
being send in the writequeue. It's not just that the writequeue is not
empty additional the first entry need to have a valid length field.
Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
parent 88aa023a
...@@ -175,6 +175,22 @@ static void sctp_connect_to_sock(struct connection *con); ...@@ -175,6 +175,22 @@ static void sctp_connect_to_sock(struct connection *con);
static void tcp_connect_to_sock(struct connection *con); static void tcp_connect_to_sock(struct connection *con);
static void dlm_tcp_shutdown(struct connection *con); static void dlm_tcp_shutdown(struct connection *con);
/* need to held writequeue_lock */
static struct writequeue_entry *con_next_wq(struct connection *con)
{
struct writequeue_entry *e;
if (list_empty(&con->writequeue))
return NULL;
e = list_first_entry(&con->writequeue, struct writequeue_entry,
list);
if (e->len == 0)
return NULL;
return e;
}
static struct connection *__find_con(int nodeid, int r) static struct connection *__find_con(int nodeid, int r)
{ {
struct connection *con; struct connection *con;
...@@ -1646,10 +1662,9 @@ int dlm_lowcomms_resend_msg(struct dlm_msg *msg) ...@@ -1646,10 +1662,9 @@ int dlm_lowcomms_resend_msg(struct dlm_msg *msg)
/* Send a message */ /* Send a message */
static void send_to_sock(struct connection *con) static void send_to_sock(struct connection *con)
{ {
int ret = 0;
const int msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL; const int msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL;
struct writequeue_entry *e; struct writequeue_entry *e;
int len, offset; int len, offset, ret;
int count = 0; int count = 0;
mutex_lock(&con->sock_mutex); mutex_lock(&con->sock_mutex);
...@@ -1658,7 +1673,8 @@ static void send_to_sock(struct connection *con) ...@@ -1658,7 +1673,8 @@ static void send_to_sock(struct connection *con)
spin_lock(&con->writequeue_lock); spin_lock(&con->writequeue_lock);
for (;;) { for (;;) {
if (list_empty(&con->writequeue)) e = con_next_wq(con);
if (!e)
break; break;
e = list_first_entry(&con->writequeue, struct writequeue_entry, list); e = list_first_entry(&con->writequeue, struct writequeue_entry, list);
...@@ -1667,8 +1683,6 @@ static void send_to_sock(struct connection *con) ...@@ -1667,8 +1683,6 @@ static void send_to_sock(struct connection *con)
BUG_ON(len == 0 && e->users == 0); BUG_ON(len == 0 && e->users == 0);
spin_unlock(&con->writequeue_lock); spin_unlock(&con->writequeue_lock);
ret = 0;
if (len) {
ret = kernel_sendpage(con->sock, e->page, offset, len, ret = kernel_sendpage(con->sock, e->page, offset, len,
msg_flags); msg_flags);
if (ret == -EAGAIN || ret == 0) { if (ret == -EAGAIN || ret == 0) {
...@@ -1685,7 +1699,6 @@ static void send_to_sock(struct connection *con) ...@@ -1685,7 +1699,6 @@ static void send_to_sock(struct connection *con)
goto out; goto out;
} else if (ret < 0) } else if (ret < 0)
goto out; goto out;
}
/* Don't starve people filling buffers */ /* Don't starve people filling buffers */
if (++count >= MAX_SEND_MSG_COUNT) { if (++count >= MAX_SEND_MSG_COUNT) {
......
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