]> err.no Git - linux-2.6/blobdiff - fs/dlm/lowcomms-tcp.c
ACPI: IA64: fix allnoconfig build
[linux-2.6] / fs / dlm / lowcomms-tcp.c
index 18ade44287e7d54a4e82b6b26da3ceda2e0712d5..07e0a122c32fcafe29546a2c02dabbcb93a019c9 100644 (file)
@@ -2,7 +2,7 @@
 *******************************************************************************
 **
 **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
-**  Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -109,7 +109,6 @@ struct connection {
        struct page *rx_page;
        struct cbuf cb;
        int retries;
-       atomic_t waiting_requests;
 #define MAX_CONNECT_RETRIES 3
        struct connection *othercon;
        struct work_struct rwork; /* Receive workqueue */
@@ -269,17 +268,20 @@ static void close_connection(struct connection *con, bool and_other)
 static int receive_from_sock(struct connection *con)
 {
        int ret = 0;
-       struct msghdr msg;
-       struct iovec iov[2];
-       mm_segment_t fs;
+       struct msghdr msg = {};
+       struct kvec iov[2];
        unsigned len;
        int r;
        int call_again_soon = 0;
+       int nvec;
 
        mutex_lock(&con->sock_mutex);
 
-       if (con->sock == NULL)
-               goto out;
+       if (con->sock == NULL) {
+               ret = -EAGAIN;
+               goto out_close;
+       }
+
        if (con->rx_page == NULL) {
                /*
                 * This doesn't need to be atomic, but I think it should
@@ -291,21 +293,13 @@ static int receive_from_sock(struct connection *con)
                cbuf_init(&con->cb, PAGE_CACHE_SIZE);
        }
 
-       msg.msg_control = NULL;
-       msg.msg_controllen = 0;
-       msg.msg_iovlen = 1;
-       msg.msg_iov = iov;
-       msg.msg_name = NULL;
-       msg.msg_namelen = 0;
-       msg.msg_flags = 0;
-
        /*
         * iov[0] is the bit of the circular buffer between the current end
         * point (cb.base + cb.len) and the end of the buffer.
         */
        iov[0].iov_len = con->cb.base - cbuf_data(&con->cb);
        iov[0].iov_base = page_address(con->rx_page) + cbuf_data(&con->cb);
-       iov[1].iov_len = 0;
+       nvec = 1;
 
        /*
         * iov[1] is the bit of the circular buffer between the start of the
@@ -315,15 +309,12 @@ static int receive_from_sock(struct connection *con)
                iov[0].iov_len = PAGE_CACHE_SIZE - cbuf_data(&con->cb);
                iov[1].iov_len = con->cb.base;
                iov[1].iov_base = page_address(con->rx_page);
-               msg.msg_iovlen = 2;
+               nvec = 2;
        }
        len = iov[0].iov_len + iov[1].iov_len;
 
-       fs = get_fs();
-       set_fs(get_ds());
-       r = ret = sock_recvmsg(con->sock, &msg, len,
+       r = ret = kernel_recvmsg(con->sock, &msg, iov, nvec, len,
                               MSG_DONTWAIT | MSG_NOSIGNAL);
-       set_fs(fs);
 
        if (ret <= 0)
                goto out_close;
@@ -352,7 +343,6 @@ static int receive_from_sock(struct connection *con)
                con->rx_page = NULL;
        }
 
-out:
        if (call_again_soon)
                goto out_resched;
        mutex_unlock(&con->sock_mutex);
@@ -370,6 +360,9 @@ out_close:
                close_connection(con, false);
                /* Reconnect when there is something to send */
        }
+       /* Don't return success if we really got EOF */
+       if (ret == 0)
+               ret = -EAGAIN;
 
        return ret;
 }
@@ -847,7 +840,6 @@ int dlm_lowcomms_close(int nodeid)
        if (con) {
                clean_one_writequeue(con);
                close_connection(con, true);
-               atomic_set(&con->waiting_requests, 0);
        }
        return 0;