aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dlm
diff options
context:
space:
mode:
Diffstat (limited to 'fs/dlm')
-rw-r--r--fs/dlm/ast.c74
-rw-r--r--fs/dlm/ast.h4
-rw-r--r--fs/dlm/config.c25
-rw-r--r--fs/dlm/debug_fs.c5
-rw-r--r--fs/dlm/dir.c7
-rw-r--r--fs/dlm/dlm_internal.h11
-rw-r--r--fs/dlm/lock.c127
-rw-r--r--fs/dlm/lockspace.c31
-rw-r--r--fs/dlm/lowcomms.c7
-rw-r--r--fs/dlm/member.c10
-rw-r--r--fs/dlm/memory.c6
-rw-r--r--fs/dlm/netlink.c3
-rw-r--r--fs/dlm/plock.c9
-rw-r--r--fs/dlm/rcom.c2
-rw-r--r--fs/dlm/requestqueue.c2
-rw-r--r--fs/dlm/user.c23
-rw-r--r--fs/dlm/user.h4
17 files changed, 236 insertions, 114 deletions
diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c
index dc2ad6008b2d..4314f0d48d85 100644
--- a/fs/dlm/ast.c
+++ b/fs/dlm/ast.c
@@ -2,7 +2,7 @@
2******************************************************************************* 2*******************************************************************************
3** 3**
4** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 4** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
5** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 5** Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
6** 6**
7** This copyrighted material is made available to anyone wishing to use, 7** This copyrighted material is made available to anyone wishing to use,
8** modify, copy, or redistribute it subject to the terms and conditions 8** modify, copy, or redistribute it subject to the terms and conditions
@@ -33,10 +33,10 @@ void dlm_del_ast(struct dlm_lkb *lkb)
33 spin_unlock(&ast_queue_lock); 33 spin_unlock(&ast_queue_lock);
34} 34}
35 35
36void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode) 36void dlm_add_ast(struct dlm_lkb *lkb, int type, int mode)
37{ 37{
38 if (lkb->lkb_flags & DLM_IFL_USER) { 38 if (lkb->lkb_flags & DLM_IFL_USER) {
39 dlm_user_add_ast(lkb, type, bastmode); 39 dlm_user_add_ast(lkb, type, mode);
40 return; 40 return;
41 } 41 }
42 42
@@ -44,10 +44,21 @@ void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode)
44 if (!(lkb->lkb_ast_type & (AST_COMP | AST_BAST))) { 44 if (!(lkb->lkb_ast_type & (AST_COMP | AST_BAST))) {
45 kref_get(&lkb->lkb_ref); 45 kref_get(&lkb->lkb_ref);
46 list_add_tail(&lkb->lkb_astqueue, &ast_queue); 46 list_add_tail(&lkb->lkb_astqueue, &ast_queue);
47 lkb->lkb_ast_first = type;
47 } 48 }
49
50 /* sanity check, this should not happen */
51
52 if ((type == AST_COMP) && (lkb->lkb_ast_type & AST_COMP))
53 log_print("repeat cast %d castmode %d lock %x %s",
54 mode, lkb->lkb_castmode,
55 lkb->lkb_id, lkb->lkb_resource->res_name);
56
48 lkb->lkb_ast_type |= type; 57 lkb->lkb_ast_type |= type;
49 if (bastmode) 58 if (type == AST_BAST)
50 lkb->lkb_bastmode = bastmode; 59 lkb->lkb_bastmode = mode;
60 else
61 lkb->lkb_castmode = mode;
51 spin_unlock(&ast_queue_lock); 62 spin_unlock(&ast_queue_lock);
52 63
53 set_bit(WAKE_ASTS, &astd_wakeflags); 64 set_bit(WAKE_ASTS, &astd_wakeflags);
@@ -59,9 +70,9 @@ static void process_asts(void)
59 struct dlm_ls *ls = NULL; 70 struct dlm_ls *ls = NULL;
60 struct dlm_rsb *r = NULL; 71 struct dlm_rsb *r = NULL;
61 struct dlm_lkb *lkb; 72 struct dlm_lkb *lkb;
62 void (*cast) (void *astparam); 73 void (*castfn) (void *astparam);
63 void (*bast) (void *astparam, int mode); 74 void (*bastfn) (void *astparam, int mode);
64 int type = 0, bastmode; 75 int type, first, bastmode, castmode, do_bast, do_cast, last_castmode;
65 76
66repeat: 77repeat:
67 spin_lock(&ast_queue_lock); 78 spin_lock(&ast_queue_lock);
@@ -75,17 +86,48 @@ repeat:
75 list_del(&lkb->lkb_astqueue); 86 list_del(&lkb->lkb_astqueue);
76 type = lkb->lkb_ast_type; 87 type = lkb->lkb_ast_type;
77 lkb->lkb_ast_type = 0; 88 lkb->lkb_ast_type = 0;
89 first = lkb->lkb_ast_first;
90 lkb->lkb_ast_first = 0;
78 bastmode = lkb->lkb_bastmode; 91 bastmode = lkb->lkb_bastmode;
79 92 castmode = lkb->lkb_castmode;
93 castfn = lkb->lkb_astfn;
94 bastfn = lkb->lkb_bastfn;
80 spin_unlock(&ast_queue_lock); 95 spin_unlock(&ast_queue_lock);
81 cast = lkb->lkb_astfn;
82 bast = lkb->lkb_bastfn;
83
84 if ((type & AST_COMP) && cast)
85 cast(lkb->lkb_astparam);
86 96
87 if ((type & AST_BAST) && bast) 97 do_cast = (type & AST_COMP) && castfn;
88 bast(lkb->lkb_astparam, bastmode); 98 do_bast = (type & AST_BAST) && bastfn;
99
100 /* Skip a bast if its blocking mode is compatible with the
101 granted mode of the preceding cast. */
102
103 if (do_bast) {
104 if (first == AST_COMP)
105 last_castmode = castmode;
106 else
107 last_castmode = lkb->lkb_castmode_done;
108 if (dlm_modes_compat(bastmode, last_castmode))
109 do_bast = 0;
110 }
111
112 if (first == AST_COMP) {
113 if (do_cast)
114 castfn(lkb->lkb_astparam);
115 if (do_bast)
116 bastfn(lkb->lkb_astparam, bastmode);
117 } else if (first == AST_BAST) {
118 if (do_bast)
119 bastfn(lkb->lkb_astparam, bastmode);
120 if (do_cast)
121 castfn(lkb->lkb_astparam);
122 } else {
123 log_error(ls, "bad ast_first %d ast_type %d",
124 first, type);
125 }
126
127 if (do_cast)
128 lkb->lkb_castmode_done = castmode;
129 if (do_bast)
130 lkb->lkb_bastmode_done = bastmode;
89 131
90 /* this removes the reference added by dlm_add_ast 132 /* this removes the reference added by dlm_add_ast
91 and may result in the lkb being freed */ 133 and may result in the lkb being freed */
diff --git a/fs/dlm/ast.h b/fs/dlm/ast.h
index 1b5fc5f428fd..bcb1aaba519d 100644
--- a/fs/dlm/ast.h
+++ b/fs/dlm/ast.h
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2******************************************************************************* 2*******************************************************************************
3** 3**
4** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. 4** Copyright (C) 2005-2010 Red Hat, Inc. All rights reserved.
5** 5**
6** This copyrighted material is made available to anyone wishing to use, 6** This copyrighted material is made available to anyone wishing to use,
7** modify, copy, or redistribute it subject to the terms and conditions 7** modify, copy, or redistribute it subject to the terms and conditions
@@ -13,7 +13,7 @@
13#ifndef __ASTD_DOT_H__ 13#ifndef __ASTD_DOT_H__
14#define __ASTD_DOT_H__ 14#define __ASTD_DOT_H__
15 15
16void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode); 16void dlm_add_ast(struct dlm_lkb *lkb, int type, int mode);
17void dlm_del_ast(struct dlm_lkb *lkb); 17void dlm_del_ast(struct dlm_lkb *lkb);
18 18
19void dlm_astd_wake(void); 19void dlm_astd_wake(void);
diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index fd9859f92fad..b54bca03d92f 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -14,6 +14,7 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/configfs.h> 16#include <linux/configfs.h>
17#include <linux/slab.h>
17#include <linux/in.h> 18#include <linux/in.h>
18#include <linux/in6.h> 19#include <linux/in6.h>
19#include <net/ipv6.h> 20#include <net/ipv6.h>
@@ -410,10 +411,10 @@ static struct config_group *make_cluster(struct config_group *g,
410 struct dlm_comms *cms = NULL; 411 struct dlm_comms *cms = NULL;
411 void *gps = NULL; 412 void *gps = NULL;
412 413
413 cl = kzalloc(sizeof(struct dlm_cluster), GFP_KERNEL); 414 cl = kzalloc(sizeof(struct dlm_cluster), GFP_NOFS);
414 gps = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL); 415 gps = kcalloc(3, sizeof(struct config_group *), GFP_NOFS);
415 sps = kzalloc(sizeof(struct dlm_spaces), GFP_KERNEL); 416 sps = kzalloc(sizeof(struct dlm_spaces), GFP_NOFS);
416 cms = kzalloc(sizeof(struct dlm_comms), GFP_KERNEL); 417 cms = kzalloc(sizeof(struct dlm_comms), GFP_NOFS);
417 418
418 if (!cl || !gps || !sps || !cms) 419 if (!cl || !gps || !sps || !cms)
419 goto fail; 420 goto fail;
@@ -482,9 +483,9 @@ static struct config_group *make_space(struct config_group *g, const char *name)
482 struct dlm_nodes *nds = NULL; 483 struct dlm_nodes *nds = NULL;
483 void *gps = NULL; 484 void *gps = NULL;
484 485
485 sp = kzalloc(sizeof(struct dlm_space), GFP_KERNEL); 486 sp = kzalloc(sizeof(struct dlm_space), GFP_NOFS);
486 gps = kcalloc(2, sizeof(struct config_group *), GFP_KERNEL); 487 gps = kcalloc(2, sizeof(struct config_group *), GFP_NOFS);
487 nds = kzalloc(sizeof(struct dlm_nodes), GFP_KERNEL); 488 nds = kzalloc(sizeof(struct dlm_nodes), GFP_NOFS);
488 489
489 if (!sp || !gps || !nds) 490 if (!sp || !gps || !nds)
490 goto fail; 491 goto fail;
@@ -536,7 +537,7 @@ static struct config_item *make_comm(struct config_group *g, const char *name)
536{ 537{
537 struct dlm_comm *cm; 538 struct dlm_comm *cm;
538 539
539 cm = kzalloc(sizeof(struct dlm_comm), GFP_KERNEL); 540 cm = kzalloc(sizeof(struct dlm_comm), GFP_NOFS);
540 if (!cm) 541 if (!cm)
541 return ERR_PTR(-ENOMEM); 542 return ERR_PTR(-ENOMEM);
542 543
@@ -569,7 +570,7 @@ static struct config_item *make_node(struct config_group *g, const char *name)
569 struct dlm_space *sp = config_item_to_space(g->cg_item.ci_parent); 570 struct dlm_space *sp = config_item_to_space(g->cg_item.ci_parent);
570 struct dlm_node *nd; 571 struct dlm_node *nd;
571 572
572 nd = kzalloc(sizeof(struct dlm_node), GFP_KERNEL); 573 nd = kzalloc(sizeof(struct dlm_node), GFP_NOFS);
573 if (!nd) 574 if (!nd)
574 return ERR_PTR(-ENOMEM); 575 return ERR_PTR(-ENOMEM);
575 576
@@ -705,7 +706,7 @@ static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf, size_t len)
705 if (cm->addr_count >= DLM_MAX_ADDR_COUNT) 706 if (cm->addr_count >= DLM_MAX_ADDR_COUNT)
706 return -ENOSPC; 707 return -ENOSPC;
707 708
708 addr = kzalloc(sizeof(*addr), GFP_KERNEL); 709 addr = kzalloc(sizeof(*addr), GFP_NOFS);
709 if (!addr) 710 if (!addr)
710 return -ENOMEM; 711 return -ENOMEM;
711 712
@@ -868,7 +869,7 @@ int dlm_nodeid_list(char *lsname, int **ids_out, int *ids_count_out,
868 869
869 ids_count = sp->members_count; 870 ids_count = sp->members_count;
870 871
871 ids = kcalloc(ids_count, sizeof(int), GFP_KERNEL); 872 ids = kcalloc(ids_count, sizeof(int), GFP_NOFS);
872 if (!ids) { 873 if (!ids) {
873 rv = -ENOMEM; 874 rv = -ENOMEM;
874 goto out; 875 goto out;
@@ -886,7 +887,7 @@ int dlm_nodeid_list(char *lsname, int **ids_out, int *ids_count_out,
886 if (!new_count) 887 if (!new_count)
887 goto out_ids; 888 goto out_ids;
888 889
889 new = kcalloc(new_count, sizeof(int), GFP_KERNEL); 890 new = kcalloc(new_count, sizeof(int), GFP_NOFS);
890 if (!new) { 891 if (!new) {
891 kfree(ids); 892 kfree(ids);
892 rv = -ENOMEM; 893 rv = -ENOMEM;
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index 1c8bb8c3a82e..c6cf25158746 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -15,6 +15,7 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/ctype.h> 16#include <linux/ctype.h>
17#include <linux/debugfs.h> 17#include <linux/debugfs.h>
18#include <linux/slab.h>
18 19
19#include "dlm_internal.h" 20#include "dlm_internal.h"
20#include "lock.h" 21#include "lock.h"
@@ -256,7 +257,7 @@ static int print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb,
256 lkb->lkb_status, 257 lkb->lkb_status,
257 lkb->lkb_grmode, 258 lkb->lkb_grmode,
258 lkb->lkb_rqmode, 259 lkb->lkb_rqmode,
259 lkb->lkb_highbast, 260 lkb->lkb_bastmode,
260 rsb_lookup, 261 rsb_lookup,
261 lkb->lkb_wait_type, 262 lkb->lkb_wait_type,
262 lkb->lkb_lvbseq, 263 lkb->lkb_lvbseq,
@@ -404,7 +405,7 @@ static void *table_seq_start(struct seq_file *seq, loff_t *pos)
404 if (bucket >= ls->ls_rsbtbl_size) 405 if (bucket >= ls->ls_rsbtbl_size)
405 return NULL; 406 return NULL;
406 407
407 ri = kzalloc(sizeof(struct rsbtbl_iter), GFP_KERNEL); 408 ri = kzalloc(sizeof(struct rsbtbl_iter), GFP_NOFS);
408 if (!ri) 409 if (!ri)
409 return NULL; 410 return NULL;
410 if (n == 0) 411 if (n == 0)
diff --git a/fs/dlm/dir.c b/fs/dlm/dir.c
index c4dfa1dcc86f..7b84c1dbc82e 100644
--- a/fs/dlm/dir.c
+++ b/fs/dlm/dir.c
@@ -49,8 +49,7 @@ static struct dlm_direntry *get_free_de(struct dlm_ls *ls, int len)
49 spin_unlock(&ls->ls_recover_list_lock); 49 spin_unlock(&ls->ls_recover_list_lock);
50 50
51 if (!found) 51 if (!found)
52 de = kzalloc(sizeof(struct dlm_direntry) + len, 52 de = kzalloc(sizeof(struct dlm_direntry) + len, GFP_NOFS);
53 ls->ls_allocation);
54 return de; 53 return de;
55} 54}
56 55
@@ -212,7 +211,7 @@ int dlm_recover_directory(struct dlm_ls *ls)
212 211
213 dlm_dir_clear(ls); 212 dlm_dir_clear(ls);
214 213
215 last_name = kmalloc(DLM_RESNAME_MAXLEN, ls->ls_allocation); 214 last_name = kmalloc(DLM_RESNAME_MAXLEN, GFP_NOFS);
216 if (!last_name) 215 if (!last_name)
217 goto out; 216 goto out;
218 217
@@ -323,7 +322,7 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name,
323 if (namelen > DLM_RESNAME_MAXLEN) 322 if (namelen > DLM_RESNAME_MAXLEN)
324 return -EINVAL; 323 return -EINVAL;
325 324
326 de = kzalloc(sizeof(struct dlm_direntry) + namelen, ls->ls_allocation); 325 de = kzalloc(sizeof(struct dlm_direntry) + namelen, GFP_NOFS);
327 if (!de) 326 if (!de)
328 return -ENOMEM; 327 return -ENOMEM;
329 328
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
index d01ca0a711db..f632b58cd222 100644
--- a/fs/dlm/dlm_internal.h
+++ b/fs/dlm/dlm_internal.h
@@ -2,7 +2,7 @@
2******************************************************************************* 2*******************************************************************************
3** 3**
4** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 4** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
5** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 5** Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
6** 6**
7** This copyrighted material is made available to anyone wishing to use, 7** This copyrighted material is made available to anyone wishing to use,
8** modify, copy, or redistribute it subject to the terms and conditions 8** modify, copy, or redistribute it subject to the terms and conditions
@@ -232,11 +232,17 @@ struct dlm_lkb {
232 int8_t lkb_status; /* granted, waiting, convert */ 232 int8_t lkb_status; /* granted, waiting, convert */
233 int8_t lkb_rqmode; /* requested lock mode */ 233 int8_t lkb_rqmode; /* requested lock mode */
234 int8_t lkb_grmode; /* granted lock mode */ 234 int8_t lkb_grmode; /* granted lock mode */
235 int8_t lkb_bastmode; /* requested mode */
236 int8_t lkb_highbast; /* highest mode bast sent for */ 235 int8_t lkb_highbast; /* highest mode bast sent for */
236
237 int8_t lkb_wait_type; /* type of reply waiting for */ 237 int8_t lkb_wait_type; /* type of reply waiting for */
238 int8_t lkb_wait_count; 238 int8_t lkb_wait_count;
239 int8_t lkb_ast_type; /* type of ast queued for */ 239 int8_t lkb_ast_type; /* type of ast queued for */
240 int8_t lkb_ast_first; /* type of first ast queued */
241
242 int8_t lkb_bastmode; /* req mode of queued bast */
243 int8_t lkb_castmode; /* gr mode of queued cast */
244 int8_t lkb_bastmode_done; /* last delivered bastmode */
245 int8_t lkb_castmode_done; /* last delivered castmode */
240 246
241 struct list_head lkb_idtbl_list; /* lockspace lkbtbl */ 247 struct list_head lkb_idtbl_list; /* lockspace lkbtbl */
242 struct list_head lkb_statequeue; /* rsb g/c/w list */ 248 struct list_head lkb_statequeue; /* rsb g/c/w list */
@@ -473,7 +479,6 @@ struct dlm_ls {
473 int ls_low_nodeid; 479 int ls_low_nodeid;
474 int ls_total_weight; 480 int ls_total_weight;
475 int *ls_node_array; 481 int *ls_node_array;
476 gfp_t ls_allocation;
477 482
478 struct dlm_rsb ls_stub_rsb; /* for returning errors */ 483 struct dlm_rsb ls_stub_rsb; /* for returning errors */
479 struct dlm_lkb ls_stub_lkb; /* for returning errors */ 484 struct dlm_lkb ls_stub_lkb; /* for returning errors */
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index eb507c453c5f..17903b491298 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2******************************************************************************* 2*******************************************************************************
3** 3**
4** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. 4** Copyright (C) 2005-2010 Red Hat, Inc. All rights reserved.
5** 5**
6** This copyrighted material is made available to anyone wishing to use, 6** This copyrighted material is made available to anyone wishing to use,
7** modify, copy, or redistribute it subject to the terms and conditions 7** modify, copy, or redistribute it subject to the terms and conditions
@@ -56,6 +56,7 @@
56 L: receive_xxxx_reply() <- R: send_xxxx_reply() 56 L: receive_xxxx_reply() <- R: send_xxxx_reply()
57*/ 57*/
58#include <linux/types.h> 58#include <linux/types.h>
59#include <linux/slab.h>
59#include "dlm_internal.h" 60#include "dlm_internal.h"
60#include <linux/dlm_device.h> 61#include <linux/dlm_device.h>
61#include "memory.h" 62#include "memory.h"
@@ -307,7 +308,7 @@ static void queue_cast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rv)
307 lkb->lkb_lksb->sb_status = rv; 308 lkb->lkb_lksb->sb_status = rv;
308 lkb->lkb_lksb->sb_flags = lkb->lkb_sbflags; 309 lkb->lkb_lksb->sb_flags = lkb->lkb_sbflags;
309 310
310 dlm_add_ast(lkb, AST_COMP, 0); 311 dlm_add_ast(lkb, AST_COMP, lkb->lkb_grmode);
311} 312}
312 313
313static inline void queue_cast_overlap(struct dlm_rsb *r, struct dlm_lkb *lkb) 314static inline void queue_cast_overlap(struct dlm_rsb *r, struct dlm_lkb *lkb)
@@ -320,10 +321,12 @@ static void queue_bast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rqmode)
320{ 321{
321 lkb->lkb_time_bast = ktime_get(); 322 lkb->lkb_time_bast = ktime_get();
322 323
323 if (is_master_copy(lkb)) 324 if (is_master_copy(lkb)) {
325 lkb->lkb_bastmode = rqmode; /* printed by debugfs */
324 send_bast(r, lkb, rqmode); 326 send_bast(r, lkb, rqmode);
325 else 327 } else {
326 dlm_add_ast(lkb, AST_BAST, rqmode); 328 dlm_add_ast(lkb, AST_BAST, rqmode);
329 }
327} 330}
328 331
329/* 332/*
@@ -2280,20 +2283,30 @@ static int do_request(struct dlm_rsb *r, struct dlm_lkb *lkb)
2280 if (can_be_queued(lkb)) { 2283 if (can_be_queued(lkb)) {
2281 error = -EINPROGRESS; 2284 error = -EINPROGRESS;
2282 add_lkb(r, lkb, DLM_LKSTS_WAITING); 2285 add_lkb(r, lkb, DLM_LKSTS_WAITING);
2283 send_blocking_asts(r, lkb);
2284 add_timeout(lkb); 2286 add_timeout(lkb);
2285 goto out; 2287 goto out;
2286 } 2288 }
2287 2289
2288 error = -EAGAIN; 2290 error = -EAGAIN;
2289 if (force_blocking_asts(lkb))
2290 send_blocking_asts_all(r, lkb);
2291 queue_cast(r, lkb, -EAGAIN); 2291 queue_cast(r, lkb, -EAGAIN);
2292
2293 out: 2292 out:
2294 return error; 2293 return error;
2295} 2294}
2296 2295
2296static void do_request_effects(struct dlm_rsb *r, struct dlm_lkb *lkb,
2297 int error)
2298{
2299 switch (error) {
2300 case -EAGAIN:
2301 if (force_blocking_asts(lkb))
2302 send_blocking_asts_all(r, lkb);
2303 break;
2304 case -EINPROGRESS:
2305 send_blocking_asts(r, lkb);
2306 break;
2307 }
2308}
2309
2297static int do_convert(struct dlm_rsb *r, struct dlm_lkb *lkb) 2310static int do_convert(struct dlm_rsb *r, struct dlm_lkb *lkb)
2298{ 2311{
2299 int error = 0; 2312 int error = 0;
@@ -2304,7 +2317,6 @@ static int do_convert(struct dlm_rsb *r, struct dlm_lkb *lkb)
2304 if (can_be_granted(r, lkb, 1, &deadlk)) { 2317 if (can_be_granted(r, lkb, 1, &deadlk)) {
2305 grant_lock(r, lkb); 2318 grant_lock(r, lkb);
2306 queue_cast(r, lkb, 0); 2319 queue_cast(r, lkb, 0);
2307 grant_pending_locks(r);
2308 goto out; 2320 goto out;
2309 } 2321 }
2310 2322
@@ -2334,7 +2346,6 @@ static int do_convert(struct dlm_rsb *r, struct dlm_lkb *lkb)
2334 if (_can_be_granted(r, lkb, 1)) { 2346 if (_can_be_granted(r, lkb, 1)) {
2335 grant_lock(r, lkb); 2347 grant_lock(r, lkb);
2336 queue_cast(r, lkb, 0); 2348 queue_cast(r, lkb, 0);
2337 grant_pending_locks(r);
2338 goto out; 2349 goto out;
2339 } 2350 }
2340 /* else fall through and move to convert queue */ 2351 /* else fall through and move to convert queue */
@@ -2344,28 +2355,47 @@ static int do_convert(struct dlm_rsb *r, struct dlm_lkb *lkb)
2344 error = -EINPROGRESS; 2355 error = -EINPROGRESS;
2345 del_lkb(r, lkb); 2356 del_lkb(r, lkb);
2346 add_lkb(r, lkb, DLM_LKSTS_CONVERT); 2357 add_lkb(r, lkb, DLM_LKSTS_CONVERT);
2347 send_blocking_asts(r, lkb);
2348 add_timeout(lkb); 2358 add_timeout(lkb);
2349 goto out; 2359 goto out;
2350 } 2360 }
2351 2361
2352 error = -EAGAIN; 2362 error = -EAGAIN;
2353 if (force_blocking_asts(lkb))
2354 send_blocking_asts_all(r, lkb);
2355 queue_cast(r, lkb, -EAGAIN); 2363 queue_cast(r, lkb, -EAGAIN);
2356
2357 out: 2364 out:
2358 return error; 2365 return error;
2359} 2366}
2360 2367
2368static void do_convert_effects(struct dlm_rsb *r, struct dlm_lkb *lkb,
2369 int error)
2370{
2371 switch (error) {
2372 case 0:
2373 grant_pending_locks(r);
2374 /* grant_pending_locks also sends basts */
2375 break;
2376 case -EAGAIN:
2377 if (force_blocking_asts(lkb))
2378 send_blocking_asts_all(r, lkb);
2379 break;
2380 case -EINPROGRESS:
2381 send_blocking_asts(r, lkb);
2382 break;
2383 }
2384}
2385
2361static int do_unlock(struct dlm_rsb *r, struct dlm_lkb *lkb) 2386static int do_unlock(struct dlm_rsb *r, struct dlm_lkb *lkb)
2362{ 2387{
2363 remove_lock(r, lkb); 2388 remove_lock(r, lkb);
2364 queue_cast(r, lkb, -DLM_EUNLOCK); 2389 queue_cast(r, lkb, -DLM_EUNLOCK);
2365 grant_pending_locks(r);
2366 return -DLM_EUNLOCK; 2390 return -DLM_EUNLOCK;
2367} 2391}
2368 2392
2393static void do_unlock_effects(struct dlm_rsb *r, struct dlm_lkb *lkb,
2394 int error)
2395{
2396 grant_pending_locks(r);
2397}
2398
2369/* returns: 0 did nothing, -DLM_ECANCEL canceled lock */ 2399/* returns: 0 did nothing, -DLM_ECANCEL canceled lock */
2370 2400
2371static int do_cancel(struct dlm_rsb *r, struct dlm_lkb *lkb) 2401static int do_cancel(struct dlm_rsb *r, struct dlm_lkb *lkb)
@@ -2375,12 +2405,18 @@ static int do_cancel(struct dlm_rsb *r, struct dlm_lkb *lkb)
2375 error = revert_lock(r, lkb); 2405 error = revert_lock(r, lkb);
2376 if (error) { 2406 if (error) {
2377 queue_cast(r, lkb, -DLM_ECANCEL); 2407 queue_cast(r, lkb, -DLM_ECANCEL);
2378 grant_pending_locks(r);
2379 return -DLM_ECANCEL; 2408 return -DLM_ECANCEL;
2380 } 2409 }
2381 return 0; 2410 return 0;
2382} 2411}
2383 2412
2413static void do_cancel_effects(struct dlm_rsb *r, struct dlm_lkb *lkb,
2414 int error)
2415{
2416 if (error)
2417 grant_pending_locks(r);
2418}
2419
2384/* 2420/*
2385 * Four stage 3 varieties: 2421 * Four stage 3 varieties:
2386 * _request_lock(), _convert_lock(), _unlock_lock(), _cancel_lock() 2422 * _request_lock(), _convert_lock(), _unlock_lock(), _cancel_lock()
@@ -2402,11 +2438,15 @@ static int _request_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
2402 goto out; 2438 goto out;
2403 } 2439 }
2404 2440
2405 if (is_remote(r)) 2441 if (is_remote(r)) {
2406 /* receive_request() calls do_request() on remote node */ 2442 /* receive_request() calls do_request() on remote node */
2407 error = send_request(r, lkb); 2443 error = send_request(r, lkb);
2408 else 2444 } else {
2409 error = do_request(r, lkb); 2445 error = do_request(r, lkb);
2446 /* for remote locks the request_reply is sent
2447 between do_request and do_request_effects */
2448 do_request_effects(r, lkb, error);
2449 }
2410 out: 2450 out:
2411 return error; 2451 return error;
2412} 2452}
@@ -2417,11 +2457,15 @@ static int _convert_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
2417{ 2457{
2418 int error; 2458 int error;
2419 2459
2420 if (is_remote(r)) 2460 if (is_remote(r)) {
2421 /* receive_convert() calls do_convert() on remote node */ 2461 /* receive_convert() calls do_convert() on remote node */
2422 error = send_convert(r, lkb); 2462 error = send_convert(r, lkb);
2423 else 2463 } else {
2424 error = do_convert(r, lkb); 2464 error = do_convert(r, lkb);
2465 /* for remote locks the convert_reply is sent
2466 between do_convert and do_convert_effects */
2467 do_convert_effects(r, lkb, error);
2468 }
2425 2469
2426 return error; 2470 return error;
2427} 2471}
@@ -2432,11 +2476,15 @@ static int _unlock_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
2432{ 2476{
2433 int error; 2477 int error;
2434 2478
2435 if (is_remote(r)) 2479 if (is_remote(r)) {
2436 /* receive_unlock() calls do_unlock() on remote node */ 2480 /* receive_unlock() calls do_unlock() on remote node */
2437 error = send_unlock(r, lkb); 2481 error = send_unlock(r, lkb);
2438 else 2482 } else {
2439 error = do_unlock(r, lkb); 2483 error = do_unlock(r, lkb);
2484 /* for remote locks the unlock_reply is sent
2485 between do_unlock and do_unlock_effects */
2486 do_unlock_effects(r, lkb, error);
2487 }
2440 2488
2441 return error; 2489 return error;
2442} 2490}
@@ -2447,11 +2495,15 @@ static int _cancel_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
2447{ 2495{
2448 int error; 2496 int error;
2449 2497
2450 if (is_remote(r)) 2498 if (is_remote(r)) {
2451 /* receive_cancel() calls do_cancel() on remote node */ 2499 /* receive_cancel() calls do_cancel() on remote node */
2452 error = send_cancel(r, lkb); 2500 error = send_cancel(r, lkb);
2453 else 2501 } else {
2454 error = do_cancel(r, lkb); 2502 error = do_cancel(r, lkb);
2503 /* for remote locks the cancel_reply is sent
2504 between do_cancel and do_cancel_effects */
2505 do_cancel_effects(r, lkb, error);
2506 }
2455 2507
2456 return error; 2508 return error;
2457} 2509}
@@ -2689,7 +2741,7 @@ static int _create_message(struct dlm_ls *ls, int mb_len,
2689 pass into lowcomms_commit and a message buffer (mb) that we 2741 pass into lowcomms_commit and a message buffer (mb) that we
2690 write our data into */ 2742 write our data into */
2691 2743
2692 mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, ls->ls_allocation, &mb); 2744 mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, GFP_NOFS, &mb);
2693 if (!mh) 2745 if (!mh)
2694 return -ENOBUFS; 2746 return -ENOBUFS;
2695 2747
@@ -3191,6 +3243,7 @@ static void receive_request(struct dlm_ls *ls, struct dlm_message *ms)
3191 attach_lkb(r, lkb); 3243 attach_lkb(r, lkb);
3192 error = do_request(r, lkb); 3244 error = do_request(r, lkb);
3193 send_request_reply(r, lkb, error); 3245 send_request_reply(r, lkb, error);
3246 do_request_effects(r, lkb, error);
3194 3247
3195 unlock_rsb(r); 3248 unlock_rsb(r);
3196 put_rsb(r); 3249 put_rsb(r);
@@ -3226,15 +3279,19 @@ static void receive_convert(struct dlm_ls *ls, struct dlm_message *ms)
3226 goto out; 3279 goto out;
3227 3280
3228 receive_flags(lkb, ms); 3281 receive_flags(lkb, ms);
3282
3229 error = receive_convert_args(ls, lkb, ms); 3283 error = receive_convert_args(ls, lkb, ms);
3230 if (error) 3284 if (error) {
3231 goto out_reply; 3285 send_convert_reply(r, lkb, error);
3286 goto out;
3287 }
3288
3232 reply = !down_conversion(lkb); 3289 reply = !down_conversion(lkb);
3233 3290
3234 error = do_convert(r, lkb); 3291 error = do_convert(r, lkb);
3235 out_reply:
3236 if (reply) 3292 if (reply)
3237 send_convert_reply(r, lkb, error); 3293 send_convert_reply(r, lkb, error);
3294 do_convert_effects(r, lkb, error);
3238 out: 3295 out:
3239 unlock_rsb(r); 3296 unlock_rsb(r);
3240 put_rsb(r); 3297 put_rsb(r);
@@ -3266,13 +3323,16 @@ static void receive_unlock(struct dlm_ls *ls, struct dlm_message *ms)
3266 goto out; 3323 goto out;
3267 3324
3268 receive_flags(lkb, ms); 3325 receive_flags(lkb, ms);
3326
3269 error = receive_unlock_args(ls, lkb, ms); 3327 error = receive_unlock_args(ls, lkb, ms);
3270 if (error) 3328 if (error) {
3271 goto out_reply; 3329 send_unlock_reply(r, lkb, error);
3330 goto out;
3331 }
3272 3332
3273 error = do_unlock(r, lkb); 3333 error = do_unlock(r, lkb);
3274 out_reply:
3275 send_unlock_reply(r, lkb, error); 3334 send_unlock_reply(r, lkb, error);
3335 do_unlock_effects(r, lkb, error);
3276 out: 3336 out:
3277 unlock_rsb(r); 3337 unlock_rsb(r);
3278 put_rsb(r); 3338 put_rsb(r);
@@ -3307,6 +3367,7 @@ static void receive_cancel(struct dlm_ls *ls, struct dlm_message *ms)
3307 3367
3308 error = do_cancel(r, lkb); 3368 error = do_cancel(r, lkb);
3309 send_cancel_reply(r, lkb, error); 3369 send_cancel_reply(r, lkb, error);
3370 do_cancel_effects(r, lkb, error);
3310 out: 3371 out:
3311 unlock_rsb(r); 3372 unlock_rsb(r);
3312 put_rsb(r); 3373 put_rsb(r);
@@ -4512,7 +4573,7 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
4512 } 4573 }
4513 4574
4514 if (flags & DLM_LKF_VALBLK) { 4575 if (flags & DLM_LKF_VALBLK) {
4515 ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_KERNEL); 4576 ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_NOFS);
4516 if (!ua->lksb.sb_lvbptr) { 4577 if (!ua->lksb.sb_lvbptr) {
4517 kfree(ua); 4578 kfree(ua);
4518 __put_lkb(ls, lkb); 4579 __put_lkb(ls, lkb);
@@ -4582,7 +4643,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4582 ua = lkb->lkb_ua; 4643 ua = lkb->lkb_ua;
4583 4644
4584 if (flags & DLM_LKF_VALBLK && !ua->lksb.sb_lvbptr) { 4645 if (flags & DLM_LKF_VALBLK && !ua->lksb.sb_lvbptr) {
4585 ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_KERNEL); 4646 ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_NOFS);
4586 if (!ua->lksb.sb_lvbptr) { 4647 if (!ua->lksb.sb_lvbptr) {
4587 error = -ENOMEM; 4648 error = -ENOMEM;
4588 goto out_put; 4649 goto out_put;
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index d489fcc86713..f994a7dfda85 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -148,7 +148,7 @@ static void lockspace_kobj_release(struct kobject *k)
148 kfree(ls); 148 kfree(ls);
149} 149}
150 150
151static struct sysfs_ops dlm_attr_ops = { 151static const struct sysfs_ops dlm_attr_ops = {
152 .show = dlm_attr_show, 152 .show = dlm_attr_show,
153 .store = dlm_attr_store, 153 .store = dlm_attr_store,
154}; 154};
@@ -191,6 +191,18 @@ static int do_uevent(struct dlm_ls *ls, int in)
191 return error; 191 return error;
192} 192}
193 193
194static int dlm_uevent(struct kset *kset, struct kobject *kobj,
195 struct kobj_uevent_env *env)
196{
197 struct dlm_ls *ls = container_of(kobj, struct dlm_ls, ls_kobj);
198
199 add_uevent_var(env, "LOCKSPACE=%s", ls->ls_name);
200 return 0;
201}
202
203static struct kset_uevent_ops dlm_uevent_ops = {
204 .uevent = dlm_uevent,
205};
194 206
195int __init dlm_lockspace_init(void) 207int __init dlm_lockspace_init(void)
196{ 208{
@@ -199,7 +211,7 @@ int __init dlm_lockspace_init(void)
199 INIT_LIST_HEAD(&lslist); 211 INIT_LIST_HEAD(&lslist);
200 spin_lock_init(&lslist_lock); 212 spin_lock_init(&lslist_lock);
201 213
202 dlm_kset = kset_create_and_add("dlm", NULL, kernel_kobj); 214 dlm_kset = kset_create_and_add("dlm", &dlm_uevent_ops, kernel_kobj);
203 if (!dlm_kset) { 215 if (!dlm_kset) {
204 printk(KERN_WARNING "%s: can not create kset\n", __func__); 216 printk(KERN_WARNING "%s: can not create kset\n", __func__);
205 return -ENOMEM; 217 return -ENOMEM;
@@ -430,7 +442,7 @@ static int new_lockspace(const char *name, int namelen, void **lockspace,
430 442
431 error = -ENOMEM; 443 error = -ENOMEM;
432 444
433 ls = kzalloc(sizeof(struct dlm_ls) + namelen, GFP_KERNEL); 445 ls = kzalloc(sizeof(struct dlm_ls) + namelen, GFP_NOFS);
434 if (!ls) 446 if (!ls)
435 goto out; 447 goto out;
436 memcpy(ls->ls_name, name, namelen); 448 memcpy(ls->ls_name, name, namelen);
@@ -443,11 +455,6 @@ static int new_lockspace(const char *name, int namelen, void **lockspace,
443 if (flags & DLM_LSFL_TIMEWARN) 455 if (flags & DLM_LSFL_TIMEWARN)
444 set_bit(LSFL_TIMEWARN, &ls->ls_flags); 456 set_bit(LSFL_TIMEWARN, &ls->ls_flags);
445 457
446 if (flags & DLM_LSFL_FS)
447 ls->ls_allocation = GFP_NOFS;
448 else
449 ls->ls_allocation = GFP_KERNEL;
450
451 /* ls_exflags are forced to match among nodes, and we don't 458 /* ls_exflags are forced to match among nodes, and we don't
452 need to require all nodes to have some flags set */ 459 need to require all nodes to have some flags set */
453 ls->ls_exflags = (flags & ~(DLM_LSFL_TIMEWARN | DLM_LSFL_FS | 460 ls->ls_exflags = (flags & ~(DLM_LSFL_TIMEWARN | DLM_LSFL_FS |
@@ -456,7 +463,7 @@ static int new_lockspace(const char *name, int namelen, void **lockspace,
456 size = dlm_config.ci_rsbtbl_size; 463 size = dlm_config.ci_rsbtbl_size;
457 ls->ls_rsbtbl_size = size; 464 ls->ls_rsbtbl_size = size;
458 465
459 ls->ls_rsbtbl = kmalloc(sizeof(struct dlm_rsbtable) * size, GFP_KERNEL); 466 ls->ls_rsbtbl = kmalloc(sizeof(struct dlm_rsbtable) * size, GFP_NOFS);
460 if (!ls->ls_rsbtbl) 467 if (!ls->ls_rsbtbl)
461 goto out_lsfree; 468 goto out_lsfree;
462 for (i = 0; i < size; i++) { 469 for (i = 0; i < size; i++) {
@@ -468,7 +475,7 @@ static int new_lockspace(const char *name, int namelen, void **lockspace,
468 size = dlm_config.ci_lkbtbl_size; 475 size = dlm_config.ci_lkbtbl_size;
469 ls->ls_lkbtbl_size = size; 476 ls->ls_lkbtbl_size = size;
470 477
471 ls->ls_lkbtbl = kmalloc(sizeof(struct dlm_lkbtable) * size, GFP_KERNEL); 478 ls->ls_lkbtbl = kmalloc(sizeof(struct dlm_lkbtable) * size, GFP_NOFS);
472 if (!ls->ls_lkbtbl) 479 if (!ls->ls_lkbtbl)
473 goto out_rsbfree; 480 goto out_rsbfree;
474 for (i = 0; i < size; i++) { 481 for (i = 0; i < size; i++) {
@@ -480,7 +487,7 @@ static int new_lockspace(const char *name, int namelen, void **lockspace,
480 size = dlm_config.ci_dirtbl_size; 487 size = dlm_config.ci_dirtbl_size;
481 ls->ls_dirtbl_size = size; 488 ls->ls_dirtbl_size = size;
482 489
483 ls->ls_dirtbl = kmalloc(sizeof(struct dlm_dirtable) * size, GFP_KERNEL); 490 ls->ls_dirtbl = kmalloc(sizeof(struct dlm_dirtable) * size, GFP_NOFS);
484 if (!ls->ls_dirtbl) 491 if (!ls->ls_dirtbl)
485 goto out_lkbfree; 492 goto out_lkbfree;
486 for (i = 0; i < size; i++) { 493 for (i = 0; i < size; i++) {
@@ -527,7 +534,7 @@ static int new_lockspace(const char *name, int namelen, void **lockspace,
527 mutex_init(&ls->ls_requestqueue_mutex); 534 mutex_init(&ls->ls_requestqueue_mutex);
528 mutex_init(&ls->ls_clear_proc_locks); 535 mutex_init(&ls->ls_clear_proc_locks);
529 536
530 ls->ls_recover_buf = kmalloc(dlm_config.ci_buffer_size, GFP_KERNEL); 537 ls->ls_recover_buf = kmalloc(dlm_config.ci_buffer_size, GFP_NOFS);
531 if (!ls->ls_recover_buf) 538 if (!ls->ls_recover_buf)
532 goto out_dirfree; 539 goto out_dirfree;
533 540
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 70736eb4b516..c0d35c620526 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -51,6 +51,7 @@
51#include <linux/file.h> 51#include <linux/file.h>
52#include <linux/mutex.h> 52#include <linux/mutex.h>
53#include <linux/sctp.h> 53#include <linux/sctp.h>
54#include <linux/slab.h>
54#include <net/sctp/user.h> 55#include <net/sctp/user.h>
55#include <net/ipv6.h> 56#include <net/ipv6.h>
56 57
@@ -1060,7 +1061,7 @@ static void init_local(void)
1060 if (dlm_our_addr(&sas, i)) 1061 if (dlm_our_addr(&sas, i))
1061 break; 1062 break;
1062 1063
1063 addr = kmalloc(sizeof(*addr), GFP_KERNEL); 1064 addr = kmalloc(sizeof(*addr), GFP_NOFS);
1064 if (!addr) 1065 if (!addr)
1065 break; 1066 break;
1066 memcpy(addr, &sas, sizeof(*addr)); 1067 memcpy(addr, &sas, sizeof(*addr));
@@ -1099,7 +1100,7 @@ static int sctp_listen_for_all(void)
1099 struct sockaddr_storage localaddr; 1100 struct sockaddr_storage localaddr;
1100 struct sctp_event_subscribe subscribe; 1101 struct sctp_event_subscribe subscribe;
1101 int result = -EINVAL, num = 1, i, addr_len; 1102 int result = -EINVAL, num = 1, i, addr_len;
1102 struct connection *con = nodeid2con(0, GFP_KERNEL); 1103 struct connection *con = nodeid2con(0, GFP_NOFS);
1103 int bufsize = NEEDED_RMEM; 1104 int bufsize = NEEDED_RMEM;
1104 1105
1105 if (!con) 1106 if (!con)
@@ -1171,7 +1172,7 @@ out:
1171static int tcp_listen_for_all(void) 1172static int tcp_listen_for_all(void)
1172{ 1173{
1173 struct socket *sock = NULL; 1174 struct socket *sock = NULL;
1174 struct connection *con = nodeid2con(0, GFP_KERNEL); 1175 struct connection *con = nodeid2con(0, GFP_NOFS);
1175 int result = -EINVAL; 1176 int result = -EINVAL;
1176 1177
1177 if (!con) 1178 if (!con)
diff --git a/fs/dlm/member.c b/fs/dlm/member.c
index b128775913b2..b12532e553f8 100644
--- a/fs/dlm/member.c
+++ b/fs/dlm/member.c
@@ -48,7 +48,7 @@ static int dlm_add_member(struct dlm_ls *ls, int nodeid)
48 struct dlm_member *memb; 48 struct dlm_member *memb;
49 int w, error; 49 int w, error;
50 50
51 memb = kzalloc(sizeof(struct dlm_member), ls->ls_allocation); 51 memb = kzalloc(sizeof(struct dlm_member), GFP_NOFS);
52 if (!memb) 52 if (!memb)
53 return -ENOMEM; 53 return -ENOMEM;
54 54
@@ -143,7 +143,7 @@ static void make_member_array(struct dlm_ls *ls)
143 143
144 ls->ls_total_weight = total; 144 ls->ls_total_weight = total;
145 145
146 array = kmalloc(sizeof(int) * total, ls->ls_allocation); 146 array = kmalloc(sizeof(int) * total, GFP_NOFS);
147 if (!array) 147 if (!array)
148 return; 148 return;
149 149
@@ -226,7 +226,7 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out)
226 continue; 226 continue;
227 log_debug(ls, "new nodeid %d is a re-added member", rv->new[i]); 227 log_debug(ls, "new nodeid %d is a re-added member", rv->new[i]);
228 228
229 memb = kzalloc(sizeof(struct dlm_member), ls->ls_allocation); 229 memb = kzalloc(sizeof(struct dlm_member), GFP_NOFS);
230 if (!memb) 230 if (!memb)
231 return -ENOMEM; 231 return -ENOMEM;
232 memb->nodeid = rv->new[i]; 232 memb->nodeid = rv->new[i];
@@ -312,7 +312,7 @@ int dlm_ls_stop(struct dlm_ls *ls)
312 /* 312 /*
313 * This in_recovery lock does two things: 313 * This in_recovery lock does two things:
314 * 1) Keeps this function from returning until all threads are out 314 * 1) Keeps this function from returning until all threads are out
315 * of locking routines and locking is truely stopped. 315 * of locking routines and locking is truly stopped.
316 * 2) Keeps any new requests from being processed until it's unlocked 316 * 2) Keeps any new requests from being processed until it's unlocked
317 * when recovery is complete. 317 * when recovery is complete.
318 */ 318 */
@@ -341,7 +341,7 @@ int dlm_ls_start(struct dlm_ls *ls)
341 int *ids = NULL, *new = NULL; 341 int *ids = NULL, *new = NULL;
342 int error, ids_count = 0, new_count = 0; 342 int error, ids_count = 0, new_count = 0;
343 343
344 rv = kzalloc(sizeof(struct dlm_recover), ls->ls_allocation); 344 rv = kzalloc(sizeof(struct dlm_recover), GFP_NOFS);
345 if (!rv) 345 if (!rv)
346 return -ENOMEM; 346 return -ENOMEM;
347 347
diff --git a/fs/dlm/memory.c b/fs/dlm/memory.c
index c1775b84ebab..8e0d00db004f 100644
--- a/fs/dlm/memory.c
+++ b/fs/dlm/memory.c
@@ -39,7 +39,7 @@ char *dlm_allocate_lvb(struct dlm_ls *ls)
39{ 39{
40 char *p; 40 char *p;
41 41
42 p = kzalloc(ls->ls_lvblen, ls->ls_allocation); 42 p = kzalloc(ls->ls_lvblen, GFP_NOFS);
43 return p; 43 return p;
44} 44}
45 45
@@ -57,7 +57,7 @@ struct dlm_rsb *dlm_allocate_rsb(struct dlm_ls *ls, int namelen)
57 57
58 DLM_ASSERT(namelen <= DLM_RESNAME_MAXLEN,); 58 DLM_ASSERT(namelen <= DLM_RESNAME_MAXLEN,);
59 59
60 r = kzalloc(sizeof(*r) + namelen, ls->ls_allocation); 60 r = kzalloc(sizeof(*r) + namelen, GFP_NOFS);
61 return r; 61 return r;
62} 62}
63 63
@@ -72,7 +72,7 @@ struct dlm_lkb *dlm_allocate_lkb(struct dlm_ls *ls)
72{ 72{
73 struct dlm_lkb *lkb; 73 struct dlm_lkb *lkb;
74 74
75 lkb = kmem_cache_zalloc(lkb_cache, ls->ls_allocation); 75 lkb = kmem_cache_zalloc(lkb_cache, GFP_NOFS);
76 return lkb; 76 return lkb;
77} 77}
78 78
diff --git a/fs/dlm/netlink.c b/fs/dlm/netlink.c
index 55ea369f43a9..2c6ad518100d 100644
--- a/fs/dlm/netlink.c
+++ b/fs/dlm/netlink.c
@@ -9,6 +9,7 @@
9#include <net/genetlink.h> 9#include <net/genetlink.h>
10#include <linux/dlm.h> 10#include <linux/dlm.h>
11#include <linux/dlm_netlink.h> 11#include <linux/dlm_netlink.h>
12#include <linux/gfp.h>
12 13
13#include "dlm_internal.h" 14#include "dlm_internal.h"
14 15
@@ -26,7 +27,7 @@ static int prepare_data(u8 cmd, struct sk_buff **skbp, size_t size)
26 struct sk_buff *skb; 27 struct sk_buff *skb;
27 void *data; 28 void *data;
28 29
29 skb = genlmsg_new(size, GFP_KERNEL); 30 skb = genlmsg_new(size, GFP_NOFS);
30 if (!skb) 31 if (!skb)
31 return -ENOMEM; 32 return -ENOMEM;
32 33
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index 16f682e26c07..d45c02db6943 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -11,6 +11,7 @@
11#include <linux/poll.h> 11#include <linux/poll.h>
12#include <linux/dlm.h> 12#include <linux/dlm.h>
13#include <linux/dlm_plock.h> 13#include <linux/dlm_plock.h>
14#include <linux/slab.h>
14 15
15#include "dlm_internal.h" 16#include "dlm_internal.h"
16#include "lockspace.h" 17#include "lockspace.h"
@@ -82,7 +83,7 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
82 if (!ls) 83 if (!ls)
83 return -EINVAL; 84 return -EINVAL;
84 85
85 xop = kzalloc(sizeof(*xop), GFP_KERNEL); 86 xop = kzalloc(sizeof(*xop), GFP_NOFS);
86 if (!xop) { 87 if (!xop) {
87 rv = -ENOMEM; 88 rv = -ENOMEM;
88 goto out; 89 goto out;
@@ -143,7 +144,7 @@ out:
143} 144}
144EXPORT_SYMBOL_GPL(dlm_posix_lock); 145EXPORT_SYMBOL_GPL(dlm_posix_lock);
145 146
146/* Returns failure iff a succesful lock operation should be canceled */ 147/* Returns failure iff a successful lock operation should be canceled */
147static int dlm_plock_callback(struct plock_op *op) 148static int dlm_plock_callback(struct plock_op *op)
148{ 149{
149 struct file *file; 150 struct file *file;
@@ -211,7 +212,7 @@ int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
211 if (!ls) 212 if (!ls)
212 return -EINVAL; 213 return -EINVAL;
213 214
214 op = kzalloc(sizeof(*op), GFP_KERNEL); 215 op = kzalloc(sizeof(*op), GFP_NOFS);
215 if (!op) { 216 if (!op) {
216 rv = -ENOMEM; 217 rv = -ENOMEM;
217 goto out; 218 goto out;
@@ -266,7 +267,7 @@ int dlm_posix_get(dlm_lockspace_t *lockspace, u64 number, struct file *file,
266 if (!ls) 267 if (!ls)
267 return -EINVAL; 268 return -EINVAL;
268 269
269 op = kzalloc(sizeof(*op), GFP_KERNEL); 270 op = kzalloc(sizeof(*op), GFP_NOFS);
270 if (!op) { 271 if (!op) {
271 rv = -ENOMEM; 272 rv = -ENOMEM;
272 goto out; 273 goto out;
diff --git a/fs/dlm/rcom.c b/fs/dlm/rcom.c
index 67522c268c14..3c83a49a48a3 100644
--- a/fs/dlm/rcom.c
+++ b/fs/dlm/rcom.c
@@ -38,7 +38,7 @@ static int create_rcom(struct dlm_ls *ls, int to_nodeid, int type, int len,
38 char *mb; 38 char *mb;
39 int mb_len = sizeof(struct dlm_rcom) + len; 39 int mb_len = sizeof(struct dlm_rcom) + len;
40 40
41 mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, ls->ls_allocation, &mb); 41 mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, GFP_NOFS, &mb);
42 if (!mh) { 42 if (!mh) {
43 log_print("create_rcom to %d type %d len %d ENOBUFS", 43 log_print("create_rcom to %d type %d len %d ENOBUFS",
44 to_nodeid, type, len); 44 to_nodeid, type, len);
diff --git a/fs/dlm/requestqueue.c b/fs/dlm/requestqueue.c
index 7a2307c08911..a44fa22890e1 100644
--- a/fs/dlm/requestqueue.c
+++ b/fs/dlm/requestqueue.c
@@ -35,7 +35,7 @@ void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_message *ms)
35 struct rq_entry *e; 35 struct rq_entry *e;
36 int length = ms->m_header.h_length - sizeof(struct dlm_message); 36 int length = ms->m_header.h_length - sizeof(struct dlm_message);
37 37
38 e = kmalloc(sizeof(struct rq_entry) + length, ls->ls_allocation); 38 e = kmalloc(sizeof(struct rq_entry) + length, GFP_NOFS);
39 if (!e) { 39 if (!e) {
40 log_print("dlm_add_requestqueue: out of memory len %d", length); 40 log_print("dlm_add_requestqueue: out of memory len %d", length);
41 return; 41 return;
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index ebce994ab0b7..8b6e73c47435 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2006-2009 Red Hat, Inc. All rights reserved. 2 * Copyright (C) 2006-2010 Red Hat, Inc. All rights reserved.
3 * 3 *
4 * This copyrighted material is made available to anyone wishing to use, 4 * This copyrighted material is made available to anyone wishing to use,
5 * modify, copy, or redistribute it subject to the terms and conditions 5 * modify, copy, or redistribute it subject to the terms and conditions
@@ -17,6 +17,7 @@
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <linux/dlm.h> 18#include <linux/dlm.h>
19#include <linux/dlm_device.h> 19#include <linux/dlm_device.h>
20#include <linux/slab.h>
20 21
21#include "dlm_internal.h" 22#include "dlm_internal.h"
22#include "lockspace.h" 23#include "lockspace.h"
@@ -173,7 +174,7 @@ static int lkb_is_endoflife(struct dlm_lkb *lkb, int sb_status, int type)
173/* we could possibly check if the cancel of an orphan has resulted in the lkb 174/* we could possibly check if the cancel of an orphan has resulted in the lkb
174 being removed and then remove that lkb from the orphans list and free it */ 175 being removed and then remove that lkb from the orphans list and free it */
175 176
176void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int bastmode) 177void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int mode)
177{ 178{
178 struct dlm_ls *ls; 179 struct dlm_ls *ls;
179 struct dlm_user_args *ua; 180 struct dlm_user_args *ua;
@@ -206,8 +207,10 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int bastmode)
206 207
207 ast_type = lkb->lkb_ast_type; 208 ast_type = lkb->lkb_ast_type;
208 lkb->lkb_ast_type |= type; 209 lkb->lkb_ast_type |= type;
209 if (bastmode) 210 if (type == AST_BAST)
210 lkb->lkb_bastmode = bastmode; 211 lkb->lkb_bastmode = mode;
212 else
213 lkb->lkb_castmode = mode;
211 214
212 if (!ast_type) { 215 if (!ast_type) {
213 kref_get(&lkb->lkb_ref); 216 kref_get(&lkb->lkb_ref);
@@ -267,7 +270,7 @@ static int device_user_lock(struct dlm_user_proc *proc,
267 goto out; 270 goto out;
268 } 271 }
269 272
270 ua = kzalloc(sizeof(struct dlm_user_args), GFP_KERNEL); 273 ua = kzalloc(sizeof(struct dlm_user_args), GFP_NOFS);
271 if (!ua) 274 if (!ua)
272 goto out; 275 goto out;
273 ua->proc = proc; 276 ua->proc = proc;
@@ -307,7 +310,7 @@ static int device_user_unlock(struct dlm_user_proc *proc,
307 if (!ls) 310 if (!ls)
308 return -ENOENT; 311 return -ENOENT;
309 312
310 ua = kzalloc(sizeof(struct dlm_user_args), GFP_KERNEL); 313 ua = kzalloc(sizeof(struct dlm_user_args), GFP_NOFS);
311 if (!ua) 314 if (!ua)
312 goto out; 315 goto out;
313 ua->proc = proc; 316 ua->proc = proc;
@@ -352,7 +355,7 @@ static int dlm_device_register(struct dlm_ls *ls, char *name)
352 355
353 error = -ENOMEM; 356 error = -ENOMEM;
354 len = strlen(name) + strlen(name_prefix) + 2; 357 len = strlen(name) + strlen(name_prefix) + 2;
355 ls->ls_device.name = kzalloc(len, GFP_KERNEL); 358 ls->ls_device.name = kzalloc(len, GFP_NOFS);
356 if (!ls->ls_device.name) 359 if (!ls->ls_device.name)
357 goto fail; 360 goto fail;
358 361
@@ -520,7 +523,7 @@ static ssize_t device_write(struct file *file, const char __user *buf,
520#endif 523#endif
521 return -EINVAL; 524 return -EINVAL;
522 525
523 kbuf = kzalloc(count + 1, GFP_KERNEL); 526 kbuf = kzalloc(count + 1, GFP_NOFS);
524 if (!kbuf) 527 if (!kbuf)
525 return -ENOMEM; 528 return -ENOMEM;
526 529
@@ -546,7 +549,7 @@ static ssize_t device_write(struct file *file, const char __user *buf,
546 549
547 /* add 1 after namelen so that the name string is terminated */ 550 /* add 1 after namelen so that the name string is terminated */
548 kbuf = kzalloc(sizeof(struct dlm_write_request) + namelen + 1, 551 kbuf = kzalloc(sizeof(struct dlm_write_request) + namelen + 1,
549 GFP_KERNEL); 552 GFP_NOFS);
550 if (!kbuf) { 553 if (!kbuf) {
551 kfree(k32buf); 554 kfree(k32buf);
552 return -ENOMEM; 555 return -ENOMEM;
@@ -648,7 +651,7 @@ static int device_open(struct inode *inode, struct file *file)
648 if (!ls) 651 if (!ls)
649 return -ENOENT; 652 return -ENOENT;
650 653
651 proc = kzalloc(sizeof(struct dlm_user_proc), GFP_KERNEL); 654 proc = kzalloc(sizeof(struct dlm_user_proc), GFP_NOFS);
652 if (!proc) { 655 if (!proc) {
653 dlm_put_lockspace(ls); 656 dlm_put_lockspace(ls);
654 return -ENOMEM; 657 return -ENOMEM;
diff --git a/fs/dlm/user.h b/fs/dlm/user.h
index 1c9686492286..f196091dd7ff 100644
--- a/fs/dlm/user.h
+++ b/fs/dlm/user.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2006-2008 Red Hat, Inc. All rights reserved. 2 * Copyright (C) 2006-2010 Red Hat, Inc. All rights reserved.
3 * 3 *
4 * This copyrighted material is made available to anyone wishing to use, 4 * This copyrighted material is made available to anyone wishing to use,
5 * modify, copy, or redistribute it subject to the terms and conditions 5 * modify, copy, or redistribute it subject to the terms and conditions
@@ -9,7 +9,7 @@
9#ifndef __USER_DOT_H__ 9#ifndef __USER_DOT_H__
10#define __USER_DOT_H__ 10#define __USER_DOT_H__
11 11
12void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int bastmode); 12void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int mode);
13int dlm_user_init(void); 13int dlm_user_init(void);
14void dlm_user_exit(void); 14void dlm_user_exit(void);
15int dlm_device_deregister(struct dlm_ls *ls); 15int dlm_device_deregister(struct dlm_ls *ls);