]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
dlm: use proper C for dlm/requestqueue stuff (and fix alignment bug)
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 25 Jan 2008 05:28:28 +0000 (00:28 -0500)
committerDavid Teigland <teigland@redhat.com>
Mon, 4 Feb 2008 07:21:32 +0000 (01:21 -0600)
a) don't cast the pointer to dlm_header *, we use it as dlm_message *
   anyway.
b) we copy the message into a queue element, then pass the pointer to
   copy to dlm_receive_message_saved(); declare it properly to make sure
   that we have the right alignment.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David Teigland <teigland@redhat.com>
fs/dlm/lock.c
fs/dlm/requestqueue.c
fs/dlm/requestqueue.h

index ff4a198fa6776a325d730748bd3d8b5782cd189a..d9f07a42e3cfbfd442111517ffe2a7b8e2bd9530 100644 (file)
@@ -3802,7 +3802,7 @@ static void dlm_receive_message(struct dlm_ls *ls, struct dlm_message *ms,
                                int nodeid)
 {
        if (dlm_locking_stopped(ls)) {
-               dlm_add_requestqueue(ls, nodeid, (struct dlm_header *) ms);
+               dlm_add_requestqueue(ls, nodeid, ms);
        } else {
                dlm_wait_requestqueue(ls);
                _receive_message(ls, ms);
index 0de04f17cceaeec20383d5613e9fd17152e5df10..daa4183fbb8489ea759b439aec402092cd7dc0a6 100644 (file)
@@ -20,7 +20,7 @@
 struct rq_entry {
        struct list_head list;
        int nodeid;
-       char request[0];
+       struct dlm_message request;
 };
 
 /*
@@ -30,10 +30,10 @@ struct rq_entry {
  * lockspace is enabled on some while still suspended on others.
  */
 
-void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd)
+void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_message *ms)
 {
        struct rq_entry *e;
-       int length = hd->h_length;
+       int length = ms->m_header.h_length - sizeof(struct dlm_message);
 
        e = kmalloc(sizeof(struct rq_entry) + length, GFP_KERNEL);
        if (!e) {
@@ -42,7 +42,7 @@ void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd)
        }
 
        e->nodeid = nodeid;
-       memcpy(e->request, hd, length);
+       memcpy(&e->request, ms, ms->m_header.h_length);
 
        mutex_lock(&ls->ls_requestqueue_mutex);
        list_add_tail(&e->list, &ls->ls_requestqueue);
@@ -76,7 +76,7 @@ int dlm_process_requestqueue(struct dlm_ls *ls)
                e = list_entry(ls->ls_requestqueue.next, struct rq_entry, list);
                mutex_unlock(&ls->ls_requestqueue_mutex);
 
-               dlm_receive_message_saved(ls, (struct dlm_message *)e->request);
+               dlm_receive_message_saved(ls, &e->request);
 
                mutex_lock(&ls->ls_requestqueue_mutex);
                list_del(&e->list);
@@ -176,7 +176,7 @@ void dlm_purge_requestqueue(struct dlm_ls *ls)
 
        mutex_lock(&ls->ls_requestqueue_mutex);
        list_for_each_entry_safe(e, safe, &ls->ls_requestqueue, list) {
-               ms = (struct dlm_message *) e->request;
+               ms =  &e->request;
 
                if (purge_request(ls, ms, e->nodeid)) {
                        list_del(&e->list);
index aba34fc05ee442ba98eb47e14c87b5d3530d67a4..10ce449b77da4a17e42c5af72704d1f211b1e6f6 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef __REQUESTQUEUE_DOT_H__
 #define __REQUESTQUEUE_DOT_H__
 
-void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd);
+void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_message *ms);
 int dlm_process_requestqueue(struct dlm_ls *ls);
 void dlm_wait_requestqueue(struct dlm_ls *ls);
 void dlm_purge_requestqueue(struct dlm_ls *ls);