]> err.no Git - linux-2.6/blobdiff - fs/dlm/lowcomms.c
[DLM] fix iovec length in recvmsg
[linux-2.6] / fs / dlm / lowcomms.c
index 75010da95b39e332b88e467ccb69fcfc7392ae19..867f93d0417e3fa1ca11e0e7e4b0363aa02d4a48 100644 (file)
@@ -174,7 +174,7 @@ static int nodeid_to_addr(int nodeid, struct sockaddr *retaddr)
        return 0;
 }
 
-static struct nodeinfo *nodeid2nodeinfo(int nodeid, int alloc)
+static struct nodeinfo *nodeid2nodeinfo(int nodeid, gfp_t alloc)
 {
        struct nodeinfo *ni;
        int r;
@@ -548,7 +548,7 @@ static int receive_from_sock(void)
        }
        len = iov[0].iov_len + iov[1].iov_len;
 
-       r = ret = kernel_recvmsg(sctp_con.sock, &msg, iov, 1, len,
+       r = ret = kernel_recvmsg(sctp_con.sock, &msg, iov, msg.msg_iovlen, len,
                                 MSG_NOSIGNAL | MSG_DONTWAIT);
        if (ret <= 0)
                goto out_close;
@@ -726,7 +726,7 @@ static int init_sock(void)
 }
 
 
-static struct writequeue_entry *new_writequeue_entry(int allocation)
+static struct writequeue_entry *new_writequeue_entry(gfp_t allocation)
 {
        struct writequeue_entry *entry;
 
@@ -748,7 +748,7 @@ static struct writequeue_entry *new_writequeue_entry(int allocation)
        return entry;
 }
 
-void *dlm_lowcomms_get_buffer(int nodeid, int len, int allocation, char **ppc)
+void *dlm_lowcomms_get_buffer(int nodeid, int len, gfp_t allocation, char **ppc)
 {
        struct writequeue_entry *e;
        int offset = 0;
@@ -934,11 +934,11 @@ static int send_to_sock(struct nodeinfo *ni)
                        break;
                e = list_entry(ni->writequeue.next, struct writequeue_entry,
                               list);
-               kmap(e->page);
                len = e->len;
                offset = e->offset;
                BUG_ON(len == 0 && e->users == 0);
                spin_unlock(&ni->writequeue_lock);
+               kmap(e->page);
 
                ret = 0;
                if (len) {
@@ -1190,10 +1190,6 @@ int dlm_lowcomms_start(void)
 {
        int error;
 
-       spin_lock_init(&write_nodes_lock);
-       INIT_LIST_HEAD(&write_nodes);
-       init_rwsem(&nodeinfo_lock);
-
        error = init_sock();
        if (error)
                goto fail_sock;
@@ -1224,6 +1220,9 @@ void dlm_lowcomms_stop(void)
 int dlm_lowcomms_init(void)
 {
        init_waitqueue_head(&lowcomms_recv_wait);
+       spin_lock_init(&write_nodes_lock);
+       INIT_LIST_HEAD(&write_nodes);
+       init_rwsem(&nodeinfo_lock);
        return 0;
 }