1 /******************************************************************************
2 *******************************************************************************
4 ** Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved.
6 ** This copyrighted material is made available to anyone wishing to use,
7 ** modify, copy, or redistribute it subject to the terms and conditions
8 ** of the GNU General Public License v.2.
10 *******************************************************************************
11 ******************************************************************************/
13 #include "dlm_internal.h"
18 #include "requestqueue.h"
21 struct list_head list
;
24 struct dlm_message request
;
28 * Requests received while the lockspace is in recovery get added to the
29 * request queue and processed when recovery is complete. This happens when
30 * the lockspace is suspended on some nodes before it is on others, or the
31 * lockspace is enabled on some while still suspended on others.
34 void dlm_add_requestqueue(struct dlm_ls
*ls
, int nodeid
, struct dlm_message
*ms
)
37 int length
= ms
->m_header
.h_length
- sizeof(struct dlm_message
);
39 e
= kmalloc(sizeof(struct rq_entry
) + length
, GFP_NOFS
);
41 log_print("dlm_add_requestqueue: out of memory len %d", length
);
45 e
->recover_seq
= ls
->ls_recover_seq
& 0xFFFFFFFF;
47 memcpy(&e
->request
, ms
, ms
->m_header
.h_length
);
49 mutex_lock(&ls
->ls_requestqueue_mutex
);
50 list_add_tail(&e
->list
, &ls
->ls_requestqueue
);
51 mutex_unlock(&ls
->ls_requestqueue_mutex
);
55 * Called by dlm_recoverd to process normal messages saved while recovery was
56 * happening. Normal locking has been enabled before this is called. dlm_recv
57 * upon receiving a message, will wait for all saved messages to be drained
58 * here before processing the message it got. If a new dlm_ls_stop() arrives
59 * while we're processing these saved messages, it may block trying to suspend
60 * dlm_recv if dlm_recv is waiting for us in dlm_wait_requestqueue. In that
61 * case, we don't abort since locking_stopped is still 0. If dlm_recv is not
62 * waiting for us, then this processing may be aborted due to locking_stopped.
65 int dlm_process_requestqueue(struct dlm_ls
*ls
)
68 struct dlm_message
*ms
;
71 mutex_lock(&ls
->ls_requestqueue_mutex
);
74 if (list_empty(&ls
->ls_requestqueue
)) {
75 mutex_unlock(&ls
->ls_requestqueue_mutex
);
79 e
= list_entry(ls
->ls_requestqueue
.next
, struct rq_entry
, list
);
80 mutex_unlock(&ls
->ls_requestqueue_mutex
);
84 log_limit(ls
, "dlm_process_requestqueue msg %d from %d "
85 "lkid %x remid %x result %d seq %u",
86 ms
->m_type
, ms
->m_header
.h_nodeid
,
87 ms
->m_lkid
, ms
->m_remid
, ms
->m_result
,
90 dlm_receive_message_saved(ls
, &e
->request
, e
->recover_seq
);
92 mutex_lock(&ls
->ls_requestqueue_mutex
);
96 if (dlm_locking_stopped(ls
)) {
97 log_debug(ls
, "process_requestqueue abort running");
98 mutex_unlock(&ls
->ls_requestqueue_mutex
);
109 * After recovery is done, locking is resumed and dlm_recoverd takes all the
110 * saved requests and processes them as they would have been by dlm_recv. At
111 * the same time, dlm_recv will start receiving new requests from remote nodes.
112 * We want to delay dlm_recv processing new requests until dlm_recoverd has
113 * finished processing the old saved requests. We don't check for locking
114 * stopped here because dlm_ls_stop won't stop locking until it's suspended us
118 void dlm_wait_requestqueue(struct dlm_ls
*ls
)
121 mutex_lock(&ls
->ls_requestqueue_mutex
);
122 if (list_empty(&ls
->ls_requestqueue
))
124 mutex_unlock(&ls
->ls_requestqueue_mutex
);
127 mutex_unlock(&ls
->ls_requestqueue_mutex
);
130 static int purge_request(struct dlm_ls
*ls
, struct dlm_message
*ms
, int nodeid
)
132 uint32_t type
= ms
->m_type
;
134 /* the ls is being cleaned up and freed by release_lockspace */
138 if (dlm_is_removed(ls
, nodeid
))
141 /* directory operations are always purged because the directory is
142 always rebuilt during recovery and the lookups resent */
144 if (type
== DLM_MSG_REMOVE
||
145 type
== DLM_MSG_LOOKUP
||
146 type
== DLM_MSG_LOOKUP_REPLY
)
149 if (!dlm_no_directory(ls
))
155 void dlm_purge_requestqueue(struct dlm_ls
*ls
)
157 struct dlm_message
*ms
;
158 struct rq_entry
*e
, *safe
;
160 mutex_lock(&ls
->ls_requestqueue_mutex
);
161 list_for_each_entry_safe(e
, safe
, &ls
->ls_requestqueue
, list
) {
164 if (purge_request(ls
, ms
, e
->nodeid
)) {
169 mutex_unlock(&ls
->ls_requestqueue_mutex
);
This page took 0.034033 seconds and 5 git commands to generate.