requestqueue.c (6d40c4a708e0e996fd9c60d4093aebba5fe1f749) requestqueue.c (4875647a08e35f77274838d97ca8fa44158d50e2)
1/******************************************************************************
2*******************************************************************************
3**
4** Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved.
5**
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.

--- 51 unchanged lines hidden (view full) ---

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.
63 */
64
65int dlm_process_requestqueue(struct dlm_ls *ls)
66{
67 struct rq_entry *e;
1/******************************************************************************
2*******************************************************************************
3**
4** Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved.
5**
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.

--- 51 unchanged lines hidden (view full) ---

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.
63 */
64
65int dlm_process_requestqueue(struct dlm_ls *ls)
66{
67 struct rq_entry *e;
68 struct dlm_message *ms;
68 int error = 0;
69
70 mutex_lock(&ls->ls_requestqueue_mutex);
71
72 for (;;) {
73 if (list_empty(&ls->ls_requestqueue)) {
74 mutex_unlock(&ls->ls_requestqueue_mutex);
75 error = 0;
76 break;
77 }
78 e = list_entry(ls->ls_requestqueue.next, struct rq_entry, list);
79 mutex_unlock(&ls->ls_requestqueue_mutex);
80
69 int error = 0;
70
71 mutex_lock(&ls->ls_requestqueue_mutex);
72
73 for (;;) {
74 if (list_empty(&ls->ls_requestqueue)) {
75 mutex_unlock(&ls->ls_requestqueue_mutex);
76 error = 0;
77 break;
78 }
79 e = list_entry(ls->ls_requestqueue.next, struct rq_entry, list);
80 mutex_unlock(&ls->ls_requestqueue_mutex);
81
82 ms = &e->request;
83
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,
88 e->recover_seq);
89
81 dlm_receive_message_saved(ls, &e->request, e->recover_seq);
82
83 mutex_lock(&ls->ls_requestqueue_mutex);
84 list_del(&e->list);
85 kfree(e);
86
87 if (dlm_locking_stopped(ls)) {
88 log_debug(ls, "process_requestqueue abort running");

--- 46 unchanged lines hidden (view full) ---

135 if (type == DLM_MSG_REMOVE ||
136 type == DLM_MSG_LOOKUP ||
137 type == DLM_MSG_LOOKUP_REPLY)
138 return 1;
139
140 if (!dlm_no_directory(ls))
141 return 0;
142
90 dlm_receive_message_saved(ls, &e->request, e->recover_seq);
91
92 mutex_lock(&ls->ls_requestqueue_mutex);
93 list_del(&e->list);
94 kfree(e);
95
96 if (dlm_locking_stopped(ls)) {
97 log_debug(ls, "process_requestqueue abort running");

--- 46 unchanged lines hidden (view full) ---

144 if (type == DLM_MSG_REMOVE ||
145 type == DLM_MSG_LOOKUP ||
146 type == DLM_MSG_LOOKUP_REPLY)
147 return 1;
148
149 if (!dlm_no_directory(ls))
150 return 0;
151
143 /* with no directory, the master is likely to change as a part of
144 recovery; requests to/from the defunct master need to be purged */
145
146 switch (type) {
147 case DLM_MSG_REQUEST:
148 case DLM_MSG_CONVERT:
149 case DLM_MSG_UNLOCK:
150 case DLM_MSG_CANCEL:
151 /* we're no longer the master of this resource, the sender
152 will resend to the new master (see waiter_needs_recovery) */
153
154 if (dlm_hash2nodeid(ls, ms->m_hash) != dlm_our_nodeid())
155 return 1;
156 break;
157
158 case DLM_MSG_REQUEST_REPLY:
159 case DLM_MSG_CONVERT_REPLY:
160 case DLM_MSG_UNLOCK_REPLY:
161 case DLM_MSG_CANCEL_REPLY:
162 case DLM_MSG_GRANT:
163 /* this reply is from the former master of the resource,
164 we'll resend to the new master if needed */
165
166 if (dlm_hash2nodeid(ls, ms->m_hash) != nodeid)
167 return 1;
168 break;
169 }
170
171 return 0;
152 return 1;
172}
173
174void dlm_purge_requestqueue(struct dlm_ls *ls)
175{
176 struct dlm_message *ms;
177 struct rq_entry *e, *safe;
178
179 mutex_lock(&ls->ls_requestqueue_mutex);
180 list_for_each_entry_safe(e, safe, &ls->ls_requestqueue, list) {
181 ms = &e->request;
182
183 if (purge_request(ls, ms, e->nodeid)) {
184 list_del(&e->list);
185 kfree(e);
186 }
187 }
188 mutex_unlock(&ls->ls_requestqueue_mutex);
189}
190
153}
154
155void dlm_purge_requestqueue(struct dlm_ls *ls)
156{
157 struct dlm_message *ms;
158 struct rq_entry *e, *safe;
159
160 mutex_lock(&ls->ls_requestqueue_mutex);
161 list_for_each_entry_safe(e, safe, &ls->ls_requestqueue, list) {
162 ms = &e->request;
163
164 if (purge_request(ls, ms, e->nodeid)) {
165 list_del(&e->list);
166 kfree(e);
167 }
168 }
169 mutex_unlock(&ls->ls_requestqueue_mutex);
170}
171