diff options
Diffstat (limited to 'fs/dlm/requestqueue.c')
-rw-r--r-- | fs/dlm/requestqueue.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/fs/dlm/requestqueue.c b/fs/dlm/requestqueue.c index 7b2b089634a2..0226d2a0a0fa 100644 --- a/fs/dlm/requestqueue.c +++ b/fs/dlm/requestqueue.c | |||
@@ -30,26 +30,39 @@ struct rq_entry { | |||
30 | * lockspace is enabled on some while still suspended on others. | 30 | * lockspace is enabled on some while still suspended on others. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd) | 33 | int dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd) |
34 | { | 34 | { |
35 | struct rq_entry *e; | 35 | struct rq_entry *e; |
36 | int length = hd->h_length; | 36 | int length = hd->h_length; |
37 | int rv = 0; | ||
37 | 38 | ||
38 | if (dlm_is_removed(ls, nodeid)) | 39 | if (dlm_is_removed(ls, nodeid)) |
39 | return; | 40 | return 0; |
40 | 41 | ||
41 | e = kmalloc(sizeof(struct rq_entry) + length, GFP_KERNEL); | 42 | e = kmalloc(sizeof(struct rq_entry) + length, GFP_KERNEL); |
42 | if (!e) { | 43 | if (!e) { |
43 | log_print("dlm_add_requestqueue: out of memory\n"); | 44 | log_print("dlm_add_requestqueue: out of memory\n"); |
44 | return; | 45 | return 0; |
45 | } | 46 | } |
46 | 47 | ||
47 | e->nodeid = nodeid; | 48 | e->nodeid = nodeid; |
48 | memcpy(e->request, hd, length); | 49 | memcpy(e->request, hd, length); |
49 | 50 | ||
51 | /* We need to check dlm_locking_stopped() after taking the mutex to | ||
52 | avoid a race where dlm_recoverd enables locking and runs | ||
53 | process_requestqueue between our earlier dlm_locking_stopped check | ||
54 | and this addition to the requestqueue. */ | ||
55 | |||
50 | mutex_lock(&ls->ls_requestqueue_mutex); | 56 | mutex_lock(&ls->ls_requestqueue_mutex); |
51 | list_add_tail(&e->list, &ls->ls_requestqueue); | 57 | if (dlm_locking_stopped(ls)) |
58 | list_add_tail(&e->list, &ls->ls_requestqueue); | ||
59 | else { | ||
60 | log_debug(ls, "dlm_add_requestqueue skip from %d", nodeid); | ||
61 | kfree(e); | ||
62 | rv = -EAGAIN; | ||
63 | } | ||
52 | mutex_unlock(&ls->ls_requestqueue_mutex); | 64 | mutex_unlock(&ls->ls_requestqueue_mutex); |
65 | return rv; | ||
53 | } | 66 | } |
54 | 67 | ||
55 | int dlm_process_requestqueue(struct dlm_ls *ls) | 68 | int dlm_process_requestqueue(struct dlm_ls *ls) |