requestqueue.c (ebf8889bd1fe3615991ff4494635d237280652a2) requestqueue.c (8b0d8e03f847d9c1677b8a193cd124debbc54633)
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.

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

15#include "lock.h"
16#include "dir.h"
17#include "config.h"
18#include "requestqueue.h"
19
20struct rq_entry {
21 struct list_head list;
22 int nodeid;
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.

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

15#include "lock.h"
16#include "dir.h"
17#include "config.h"
18#include "requestqueue.h"
19
20struct rq_entry {
21 struct list_head list;
22 int nodeid;
23 char request[0];
23 struct dlm_message request;
24};
25
26/*
27 * Requests received while the lockspace is in recovery get added to the
28 * request queue and processed when recovery is complete. This happens when
29 * the lockspace is suspended on some nodes before it is on others, or the
30 * lockspace is enabled on some while still suspended on others.
31 */
32
24};
25
26/*
27 * Requests received while the lockspace is in recovery get added to the
28 * request queue and processed when recovery is complete. This happens when
29 * the lockspace is suspended on some nodes before it is on others, or the
30 * lockspace is enabled on some while still suspended on others.
31 */
32
33void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd)
33void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_message *ms)
34{
35 struct rq_entry *e;
34{
35 struct rq_entry *e;
36 int length = hd->h_length;
36 int length = ms->m_header.h_length - sizeof(struct dlm_message);
37
38 e = kmalloc(sizeof(struct rq_entry) + length, GFP_KERNEL);
39 if (!e) {
40 log_print("dlm_add_requestqueue: out of memory len %d", length);
41 return;
42 }
43
44 e->nodeid = nodeid;
37
38 e = kmalloc(sizeof(struct rq_entry) + length, GFP_KERNEL);
39 if (!e) {
40 log_print("dlm_add_requestqueue: out of memory len %d", length);
41 return;
42 }
43
44 e->nodeid = nodeid;
45 memcpy(e->request, hd, length);
45 memcpy(&e->request, ms, ms->m_header.h_length);
46
47 mutex_lock(&ls->ls_requestqueue_mutex);
48 list_add_tail(&e->list, &ls->ls_requestqueue);
49 mutex_unlock(&ls->ls_requestqueue_mutex);
50}
51
52/*
53 * Called by dlm_recoverd to process normal messages saved while recovery was

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

71 if (list_empty(&ls->ls_requestqueue)) {
72 mutex_unlock(&ls->ls_requestqueue_mutex);
73 error = 0;
74 break;
75 }
76 e = list_entry(ls->ls_requestqueue.next, struct rq_entry, list);
77 mutex_unlock(&ls->ls_requestqueue_mutex);
78
46
47 mutex_lock(&ls->ls_requestqueue_mutex);
48 list_add_tail(&e->list, &ls->ls_requestqueue);
49 mutex_unlock(&ls->ls_requestqueue_mutex);
50}
51
52/*
53 * Called by dlm_recoverd to process normal messages saved while recovery was

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

71 if (list_empty(&ls->ls_requestqueue)) {
72 mutex_unlock(&ls->ls_requestqueue_mutex);
73 error = 0;
74 break;
75 }
76 e = list_entry(ls->ls_requestqueue.next, struct rq_entry, list);
77 mutex_unlock(&ls->ls_requestqueue_mutex);
78
79 dlm_receive_message_saved(ls, (struct dlm_message *)e->request);
79 dlm_receive_message_saved(ls, &e->request);
80
81 mutex_lock(&ls->ls_requestqueue_mutex);
82 list_del(&e->list);
83 kfree(e);
84
85 if (dlm_locking_stopped(ls)) {
86 log_debug(ls, "process_requestqueue abort running");
87 mutex_unlock(&ls->ls_requestqueue_mutex);

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

171
172void dlm_purge_requestqueue(struct dlm_ls *ls)
173{
174 struct dlm_message *ms;
175 struct rq_entry *e, *safe;
176
177 mutex_lock(&ls->ls_requestqueue_mutex);
178 list_for_each_entry_safe(e, safe, &ls->ls_requestqueue, list) {
80
81 mutex_lock(&ls->ls_requestqueue_mutex);
82 list_del(&e->list);
83 kfree(e);
84
85 if (dlm_locking_stopped(ls)) {
86 log_debug(ls, "process_requestqueue abort running");
87 mutex_unlock(&ls->ls_requestqueue_mutex);

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

171
172void dlm_purge_requestqueue(struct dlm_ls *ls)
173{
174 struct dlm_message *ms;
175 struct rq_entry *e, *safe;
176
177 mutex_lock(&ls->ls_requestqueue_mutex);
178 list_for_each_entry_safe(e, safe, &ls->ls_requestqueue, list) {
179 ms = (struct dlm_message *) e->request;
179 ms = &e->request;
180
181 if (purge_request(ls, ms, e->nodeid)) {
182 list_del(&e->list);
183 kfree(e);
184 }
185 }
186 mutex_unlock(&ls->ls_requestqueue_mutex);
187}
188
180
181 if (purge_request(ls, ms, e->nodeid)) {
182 list_del(&e->list);
183 kfree(e);
184 }
185 }
186 mutex_unlock(&ls->ls_requestqueue_mutex);
187}
188