aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2006-01-20 03:47:07 -0500
committerSteven Whitehouse <steve@chygwyn.com>2006-01-20 03:47:07 -0500
commit901359256b2666f52a3a7d3f31927677e91b3a2a (patch)
tree24d4ee2c1ad63a0e6c3a303ad67eac3342772c4f /fs
parentec5800246607183a1d7fd0bae5f087c12439e9e7 (diff)
[DLM] Update DLM to the latest patch level
Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steve Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/dlm/ast.c16
-rw-r--r--fs/dlm/config.c20
-rw-r--r--fs/dlm/debug_fs.c4
-rw-r--r--fs/dlm/device.c55
-rw-r--r--fs/dlm/dir.c4
-rw-r--r--fs/dlm/dlm_internal.h23
-rw-r--r--fs/dlm/lock.c72
-rw-r--r--fs/dlm/lock.h4
-rw-r--r--fs/dlm/lockspace.c21
-rw-r--r--fs/dlm/member.c17
-rw-r--r--fs/dlm/midcomms.c2
-rw-r--r--fs/dlm/recover.c18
-rw-r--r--fs/dlm/recoverd.c16
-rw-r--r--fs/dlm/requestqueue.c26
14 files changed, 147 insertions, 151 deletions
diff --git a/fs/dlm/ast.c b/fs/dlm/ast.c
index 2bd1c5e1a72c..57bdf09b520a 100644
--- a/fs/dlm/ast.c
+++ b/fs/dlm/ast.c
@@ -21,7 +21,7 @@ static struct list_head ast_queue;
21static spinlock_t ast_queue_lock; 21static spinlock_t ast_queue_lock;
22static struct task_struct * astd_task; 22static struct task_struct * astd_task;
23static unsigned long astd_wakeflags; 23static unsigned long astd_wakeflags;
24static struct semaphore astd_running; 24static struct mutex astd_running;
25 25
26 26
27void dlm_del_ast(struct dlm_lkb *lkb) 27void dlm_del_ast(struct dlm_lkb *lkb)
@@ -56,7 +56,7 @@ static void process_asts(void)
56 int type = 0, found, bmode; 56 int type = 0, found, bmode;
57 57
58 for (;;) { 58 for (;;) {
59 found = FALSE; 59 found = 0;
60 spin_lock(&ast_queue_lock); 60 spin_lock(&ast_queue_lock);
61 list_for_each_entry(lkb, &ast_queue, lkb_astqueue) { 61 list_for_each_entry(lkb, &ast_queue, lkb_astqueue) {
62 r = lkb->lkb_resource; 62 r = lkb->lkb_resource;
@@ -68,7 +68,7 @@ static void process_asts(void)
68 list_del(&lkb->lkb_astqueue); 68 list_del(&lkb->lkb_astqueue);
69 type = lkb->lkb_ast_type; 69 type = lkb->lkb_ast_type;
70 lkb->lkb_ast_type = 0; 70 lkb->lkb_ast_type = 0;
71 found = TRUE; 71 found = 1;
72 break; 72 break;
73 } 73 }
74 spin_unlock(&ast_queue_lock); 74 spin_unlock(&ast_queue_lock);
@@ -117,10 +117,10 @@ static int dlm_astd(void *data)
117 schedule(); 117 schedule();
118 set_current_state(TASK_RUNNING); 118 set_current_state(TASK_RUNNING);
119 119
120 down(&astd_running); 120 mutex_lock(&astd_running);
121 if (test_and_clear_bit(WAKE_ASTS, &astd_wakeflags)) 121 if (test_and_clear_bit(WAKE_ASTS, &astd_wakeflags))
122 process_asts(); 122 process_asts();
123 up(&astd_running); 123 mutex_unlock(&astd_running);
124 } 124 }
125 return 0; 125 return 0;
126} 126}
@@ -140,7 +140,7 @@ int dlm_astd_start(void)
140 140
141 INIT_LIST_HEAD(&ast_queue); 141 INIT_LIST_HEAD(&ast_queue);
142 spin_lock_init(&ast_queue_lock); 142 spin_lock_init(&ast_queue_lock);
143 init_MUTEX(&astd_running); 143 mutex_init(&astd_running);
144 144
145 p = kthread_run(dlm_astd, NULL, "dlm_astd"); 145 p = kthread_run(dlm_astd, NULL, "dlm_astd");
146 if (IS_ERR(p)) 146 if (IS_ERR(p))
@@ -157,11 +157,11 @@ void dlm_astd_stop(void)
157 157
158void dlm_astd_suspend(void) 158void dlm_astd_suspend(void)
159{ 159{
160 down(&astd_running); 160 mutex_lock(&astd_running);
161} 161}
162 162
163void dlm_astd_resume(void) 163void dlm_astd_resume(void)
164{ 164{
165 up(&astd_running); 165 mutex_unlock(&astd_running);
166} 166}
167 167
diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index 024ace9973a8..87df9616415e 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -162,7 +162,7 @@ struct spaces {
162struct space { 162struct space {
163 struct config_group group; 163 struct config_group group;
164 struct list_head members; 164 struct list_head members;
165 struct semaphore members_lock; 165 struct mutex members_lock;
166 int members_count; 166 int members_count;
167}; 167};
168 168
@@ -374,7 +374,7 @@ static struct config_group *make_space(struct config_group *g, const char *name)
374 sp->group.default_groups[1] = NULL; 374 sp->group.default_groups[1] = NULL;
375 375
376 INIT_LIST_HEAD(&sp->members); 376 INIT_LIST_HEAD(&sp->members);
377 init_MUTEX(&sp->members_lock); 377 mutex_init(&sp->members_lock);
378 sp->members_count = 0; 378 sp->members_count = 0;
379 return &sp->group; 379 return &sp->group;
380 380
@@ -453,10 +453,10 @@ static struct config_item *make_node(struct config_group *g, const char *name)
453 nd->nodeid = -1; 453 nd->nodeid = -1;
454 nd->weight = 1; /* default weight of 1 if none is set */ 454 nd->weight = 1; /* default weight of 1 if none is set */
455 455
456 down(&sp->members_lock); 456 mutex_lock(&sp->members_lock);
457 list_add(&nd->list, &sp->members); 457 list_add(&nd->list, &sp->members);
458 sp->members_count++; 458 sp->members_count++;
459 up(&sp->members_lock); 459 mutex_unlock(&sp->members_lock);
460 460
461 return &nd->item; 461 return &nd->item;
462} 462}
@@ -466,10 +466,10 @@ static void drop_node(struct config_group *g, struct config_item *i)
466 struct space *sp = to_space(g->cg_item.ci_parent); 466 struct space *sp = to_space(g->cg_item.ci_parent);
467 struct node *nd = to_node(i); 467 struct node *nd = to_node(i);
468 468
469 down(&sp->members_lock); 469 mutex_lock(&sp->members_lock);
470 list_del(&nd->list); 470 list_del(&nd->list);
471 sp->members_count--; 471 sp->members_count--;
472 up(&sp->members_lock); 472 mutex_unlock(&sp->members_lock);
473 473
474 config_item_put(i); 474 config_item_put(i);
475} 475}
@@ -677,7 +677,7 @@ int dlm_nodeid_list(char *lsname, int **ids_out)
677 if (!sp) 677 if (!sp)
678 return -EEXIST; 678 return -EEXIST;
679 679
680 down(&sp->members_lock); 680 mutex_lock(&sp->members_lock);
681 if (!sp->members_count) { 681 if (!sp->members_count) {
682 rv = 0; 682 rv = 0;
683 goto out; 683 goto out;
@@ -698,7 +698,7 @@ int dlm_nodeid_list(char *lsname, int **ids_out)
698 698
699 *ids_out = ids; 699 *ids_out = ids;
700 out: 700 out:
701 up(&sp->members_lock); 701 mutex_unlock(&sp->members_lock);
702 put_space(sp); 702 put_space(sp);
703 return rv; 703 return rv;
704} 704}
@@ -713,14 +713,14 @@ int dlm_node_weight(char *lsname, int nodeid)
713 if (!sp) 713 if (!sp)
714 goto out; 714 goto out;
715 715
716 down(&sp->members_lock); 716 mutex_lock(&sp->members_lock);
717 list_for_each_entry(nd, &sp->members, list) { 717 list_for_each_entry(nd, &sp->members, list) {
718 if (nd->nodeid != nodeid) 718 if (nd->nodeid != nodeid)
719 continue; 719 continue;
720 w = nd->weight; 720 w = nd->weight;
721 break; 721 break;
722 } 722 }
723 up(&sp->members_lock); 723 mutex_unlock(&sp->members_lock);
724 put_space(sp); 724 put_space(sp);
725 out: 725 out:
726 return w; 726 return w;
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index 98b49a1ece47..5080bbffd586 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -63,12 +63,12 @@ static void print_lock(struct seq_file *s, struct dlm_lkb *lkb,
63 /* FIXME: this warns on Alpha */ 63 /* FIXME: this warns on Alpha */
64 if (lkb->lkb_status == DLM_LKSTS_CONVERT 64 if (lkb->lkb_status == DLM_LKSTS_CONVERT
65 || lkb->lkb_status == DLM_LKSTS_GRANTED) 65 || lkb->lkb_status == DLM_LKSTS_GRANTED)
66 seq_printf(s, " %" PRIx64 "-%" PRIx64, 66 seq_printf(s, " %llx-%llx",
67 lkb->lkb_range[GR_RANGE_START], 67 lkb->lkb_range[GR_RANGE_START],
68 lkb->lkb_range[GR_RANGE_END]); 68 lkb->lkb_range[GR_RANGE_END]);
69 if (lkb->lkb_status == DLM_LKSTS_CONVERT 69 if (lkb->lkb_status == DLM_LKSTS_CONVERT
70 || lkb->lkb_status == DLM_LKSTS_WAITING) 70 || lkb->lkb_status == DLM_LKSTS_WAITING)
71 seq_printf(s, " (%" PRIx64 "-%" PRIx64 ")", 71 seq_printf(s, " (%llx-%llx)",
72 lkb->lkb_range[RQ_RANGE_START], 72 lkb->lkb_range[RQ_RANGE_START],
73 lkb->lkb_range[RQ_RANGE_END]); 73 lkb->lkb_range[RQ_RANGE_END]);
74 } 74 }
diff --git a/fs/dlm/device.c b/fs/dlm/device.c
index a8bf600ed13d..899d4f92a4d7 100644
--- a/fs/dlm/device.c
+++ b/fs/dlm/device.c
@@ -43,7 +43,7 @@
43static struct file_operations _dlm_fops; 43static struct file_operations _dlm_fops;
44static const char *name_prefix="dlm"; 44static const char *name_prefix="dlm";
45static struct list_head user_ls_list; 45static struct list_head user_ls_list;
46static struct semaphore user_ls_lock; 46static struct mutex user_ls_lock;
47 47
48/* Lock infos are stored in here indexed by lock ID */ 48/* Lock infos are stored in here indexed by lock ID */
49static DEFINE_IDR(lockinfo_idr); 49static DEFINE_IDR(lockinfo_idr);
@@ -53,6 +53,7 @@ static rwlock_t lockinfo_lock;
53#define LI_FLAG_COMPLETE 1 53#define LI_FLAG_COMPLETE 1
54#define LI_FLAG_FIRSTLOCK 2 54#define LI_FLAG_FIRSTLOCK 2
55#define LI_FLAG_PERSISTENT 3 55#define LI_FLAG_PERSISTENT 3
56#define LI_FLAG_ONLIST 4
56 57
57/* flags in ls_flags*/ 58/* flags in ls_flags*/
58#define LS_FLAG_DELETED 1 59#define LS_FLAG_DELETED 1
@@ -211,18 +212,18 @@ static struct user_ls *find_lockspace(int minor)
211{ 212{
212 struct user_ls *lsinfo; 213 struct user_ls *lsinfo;
213 214
214 down(&user_ls_lock); 215 mutex_lock(&user_ls_lock);
215 lsinfo = __find_lockspace(minor); 216 lsinfo = __find_lockspace(minor);
216 up(&user_ls_lock); 217 mutex_unlock(&user_ls_lock);
217 218
218 return lsinfo; 219 return lsinfo;
219} 220}
220 221
221static void add_lockspace_to_list(struct user_ls *lsinfo) 222static void add_lockspace_to_list(struct user_ls *lsinfo)
222{ 223{
223 down(&user_ls_lock); 224 mutex_lock(&user_ls_lock);
224 list_add(&lsinfo->ls_list, &user_ls_list); 225 list_add(&lsinfo->ls_list, &user_ls_list);
225 up(&user_ls_lock); 226 mutex_unlock(&user_ls_lock);
226} 227}
227 228
228/* Register a lockspace with the DLM and create a misc 229/* Register a lockspace with the DLM and create a misc
@@ -235,12 +236,11 @@ static int register_lockspace(char *name, struct user_ls **ls, int flags)
235 236
236 namelen = strlen(name)+strlen(name_prefix)+2; 237 namelen = strlen(name)+strlen(name_prefix)+2;
237 238
238 newls = kmalloc(sizeof(struct user_ls), GFP_KERNEL); 239 newls = kzalloc(sizeof(struct user_ls), GFP_KERNEL);
239 if (!newls) 240 if (!newls)
240 return -ENOMEM; 241 return -ENOMEM;
241 memset(newls, 0, sizeof(struct user_ls));
242 242
243 newls->ls_miscinfo.name = kmalloc(namelen, GFP_KERNEL); 243 newls->ls_miscinfo.name = kzalloc(namelen, GFP_KERNEL);
244 if (!newls->ls_miscinfo.name) { 244 if (!newls->ls_miscinfo.name) {
245 kfree(newls); 245 kfree(newls);
246 return -ENOMEM; 246 return -ENOMEM;
@@ -277,7 +277,7 @@ static int register_lockspace(char *name, struct user_ls **ls, int flags)
277 return 0; 277 return 0;
278} 278}
279 279
280/* Called with the user_ls_lock semaphore held */ 280/* Called with the user_ls_lock mutex held */
281static int unregister_lockspace(struct user_ls *lsinfo, int force) 281static int unregister_lockspace(struct user_ls *lsinfo, int force)
282{ 282{
283 int status; 283 int status;
@@ -305,11 +305,10 @@ static int unregister_lockspace(struct user_ls *lsinfo, int force)
305static void add_to_astqueue(struct lock_info *li, void *astaddr, void *astparam, 305static void add_to_astqueue(struct lock_info *li, void *astaddr, void *astparam,
306 int lvb_updated) 306 int lvb_updated)
307{ 307{
308 struct ast_info *ast = kmalloc(sizeof(struct ast_info), GFP_KERNEL); 308 struct ast_info *ast = kzalloc(sizeof(struct ast_info), GFP_KERNEL);
309 if (!ast) 309 if (!ast)
310 return; 310 return;
311 311
312 memset(ast, 0, sizeof(*ast));
313 ast->result.user_astparam = astparam; 312 ast->result.user_astparam = astparam;
314 ast->result.user_astaddr = astaddr; 313 ast->result.user_astaddr = astaddr;
315 ast->result.user_lksb = li->li_user_lksb; 314 ast->result.user_lksb = li->li_user_lksb;
@@ -382,6 +381,7 @@ static void ast_routine(void *param)
382 381
383 spin_lock(&li->li_file->fi_li_lock); 382 spin_lock(&li->li_file->fi_li_lock);
384 list_del(&li->li_ownerqueue); 383 list_del(&li->li_ownerqueue);
384 clear_bit(LI_FLAG_ONLIST, &li->li_flags);
385 spin_unlock(&li->li_file->fi_li_lock); 385 spin_unlock(&li->li_file->fi_li_lock);
386 release_lockinfo(li); 386 release_lockinfo(li);
387 return; 387 return;
@@ -437,7 +437,7 @@ static int dlm_open(struct inode *inode, struct file *file)
437 if (!lsinfo) 437 if (!lsinfo)
438 return -ENOENT; 438 return -ENOENT;
439 439
440 f = kmalloc(sizeof(struct file_info), GFP_KERNEL); 440 f = kzalloc(sizeof(struct file_info), GFP_KERNEL);
441 if (!f) 441 if (!f)
442 return -ENOMEM; 442 return -ENOMEM;
443 443
@@ -570,7 +570,7 @@ static int dlm_close(struct inode *inode, struct file *file)
570 * then free the struct. If it's an AUTOFREE lockspace 570 * then free the struct. If it's an AUTOFREE lockspace
571 * then free the whole thing. 571 * then free the whole thing.
572 */ 572 */
573 down(&user_ls_lock); 573 mutex_lock(&user_ls_lock);
574 if (atomic_dec_and_test(&lsinfo->ls_refcnt)) { 574 if (atomic_dec_and_test(&lsinfo->ls_refcnt)) {
575 575
576 if (lsinfo->ls_lockspace) { 576 if (lsinfo->ls_lockspace) {
@@ -582,7 +582,7 @@ static int dlm_close(struct inode *inode, struct file *file)
582 kfree(lsinfo); 582 kfree(lsinfo);
583 } 583 }
584 } 584 }
585 up(&user_ls_lock); 585 mutex_unlock(&user_ls_lock);
586 put_file_info(f); 586 put_file_info(f);
587 587
588 /* Restore signals */ 588 /* Restore signals */
@@ -620,10 +620,10 @@ static int do_user_remove_lockspace(struct file_info *fi, uint8_t cmd,
620 if (!capable(CAP_SYS_ADMIN)) 620 if (!capable(CAP_SYS_ADMIN))
621 return -EPERM; 621 return -EPERM;
622 622
623 down(&user_ls_lock); 623 mutex_lock(&user_ls_lock);
624 lsinfo = __find_lockspace(kparams->minor); 624 lsinfo = __find_lockspace(kparams->minor);
625 if (!lsinfo) { 625 if (!lsinfo) {
626 up(&user_ls_lock); 626 mutex_unlock(&user_ls_lock);
627 return -EINVAL; 627 return -EINVAL;
628 } 628 }
629 629
@@ -631,7 +631,7 @@ static int do_user_remove_lockspace(struct file_info *fi, uint8_t cmd,
631 force = 2; 631 force = 2;
632 632
633 status = unregister_lockspace(lsinfo, force); 633 status = unregister_lockspace(lsinfo, force);
634 up(&user_ls_lock); 634 mutex_unlock(&user_ls_lock);
635 635
636 return status; 636 return status;
637} 637}
@@ -752,7 +752,7 @@ static struct lock_info *allocate_lockinfo(struct file_info *fi, uint8_t cmd,
752 if (!try_module_get(THIS_MODULE)) 752 if (!try_module_get(THIS_MODULE))
753 return NULL; 753 return NULL;
754 754
755 li = kmalloc(sizeof(struct lock_info), GFP_KERNEL); 755 li = kzalloc(sizeof(struct lock_info), GFP_KERNEL);
756 if (li) { 756 if (li) {
757 li->li_magic = LOCKINFO_MAGIC; 757 li->li_magic = LOCKINFO_MAGIC;
758 li->li_file = fi; 758 li->li_file = fi;
@@ -800,8 +800,10 @@ static int do_user_lock(struct file_info *fi, uint8_t cmd,
800 800
801 /* If this is a persistent lock we will have to create a 801 /* If this is a persistent lock we will have to create a
802 lockinfo again */ 802 lockinfo again */
803 if (!li && DLM_LKF_PERSISTENT) { 803 if (!li && (kparams->flags & DLM_LKF_PERSISTENT)) {
804 li = allocate_lockinfo(fi, cmd, kparams); 804 li = allocate_lockinfo(fi, cmd, kparams);
805 if (!li)
806 return -ENOMEM;
805 807
806 li->li_lksb.sb_lkid = kparams->lkid; 808 li->li_lksb.sb_lkid = kparams->lkid;
807 li->li_castaddr = kparams->castaddr; 809 li->li_castaddr = kparams->castaddr;
@@ -887,6 +889,7 @@ static int do_user_lock(struct file_info *fi, uint8_t cmd,
887 889
888 spin_lock(&fi->fi_li_lock); 890 spin_lock(&fi->fi_li_lock);
889 list_add(&li->li_ownerqueue, &fi->fi_li_list); 891 list_add(&li->li_ownerqueue, &fi->fi_li_list);
892 set_bit(LI_FLAG_ONLIST, &li->li_flags);
890 spin_unlock(&fi->fi_li_lock); 893 spin_unlock(&fi->fi_li_lock);
891 if (add_lockinfo(li)) 894 if (add_lockinfo(li))
892 printk(KERN_WARNING "Add lockinfo failed\n"); 895 printk(KERN_WARNING "Add lockinfo failed\n");
@@ -914,12 +917,13 @@ static int do_user_unlock(struct file_info *fi, uint8_t cmd,
914 li = get_lockinfo(kparams->lkid); 917 li = get_lockinfo(kparams->lkid);
915 if (!li) { 918 if (!li) {
916 li = allocate_lockinfo(fi, cmd, kparams); 919 li = allocate_lockinfo(fi, cmd, kparams);
920 if (!li)
921 return -ENOMEM;
917 spin_lock(&fi->fi_li_lock); 922 spin_lock(&fi->fi_li_lock);
918 list_add(&li->li_ownerqueue, &fi->fi_li_list); 923 list_add(&li->li_ownerqueue, &fi->fi_li_list);
924 set_bit(LI_FLAG_ONLIST, &li->li_flags);
919 spin_unlock(&fi->fi_li_lock); 925 spin_unlock(&fi->fi_li_lock);
920 } 926 }
921 if (!li)
922 return -ENOMEM;
923 927
924 if (li->li_magic != LOCKINFO_MAGIC) 928 if (li->li_magic != LOCKINFO_MAGIC)
925 return -EINVAL; 929 return -EINVAL;
@@ -932,6 +936,12 @@ static int do_user_unlock(struct file_info *fi, uint8_t cmd,
932 if (kparams->flags & DLM_LKF_CANCEL && li->li_grmode != -1) 936 if (kparams->flags & DLM_LKF_CANCEL && li->li_grmode != -1)
933 convert_cancel = 1; 937 convert_cancel = 1;
934 938
939 /* Wait until dlm_lock() has completed */
940 if (!test_bit(LI_FLAG_ONLIST, &li->li_flags)) {
941 down(&li->li_firstlock);
942 up(&li->li_firstlock);
943 }
944
935 /* dlm_unlock() passes a 0 for castaddr which means don't overwrite 945 /* dlm_unlock() passes a 0 for castaddr which means don't overwrite
936 the existing li_castaddr as that's the completion routine for 946 the existing li_castaddr as that's the completion routine for
937 unlocks. dlm_unlock_wait() specifies a new AST routine to be 947 unlocks. dlm_unlock_wait() specifies a new AST routine to be
@@ -947,6 +957,7 @@ static int do_user_unlock(struct file_info *fi, uint8_t cmd,
947 if (!status && !convert_cancel) { 957 if (!status && !convert_cancel) {
948 spin_lock(&fi->fi_li_lock); 958 spin_lock(&fi->fi_li_lock);
949 list_del(&li->li_ownerqueue); 959 list_del(&li->li_ownerqueue);
960 clear_bit(LI_FLAG_ONLIST, &li->li_flags);
950 spin_unlock(&fi->fi_li_lock); 961 spin_unlock(&fi->fi_li_lock);
951 } 962 }
952 963
@@ -1055,7 +1066,7 @@ static int __init dlm_device_init(void)
1055 int r; 1066 int r;
1056 1067
1057 INIT_LIST_HEAD(&user_ls_list); 1068 INIT_LIST_HEAD(&user_ls_list);
1058 init_MUTEX(&user_ls_lock); 1069 mutex_init(&user_ls_lock);
1059 rwlock_init(&lockinfo_lock); 1070 rwlock_init(&lockinfo_lock);
1060 1071
1061 ctl_device.name = "dlm-control"; 1072 ctl_device.name = "dlm-control";
diff --git a/fs/dlm/dir.c b/fs/dlm/dir.c
index 0f1dde54bcd2..46754553fdcc 100644
--- a/fs/dlm/dir.c
+++ b/fs/dlm/dir.c
@@ -33,7 +33,7 @@ static void put_free_de(struct dlm_ls *ls, struct dlm_direntry *de)
33 33
34static struct dlm_direntry *get_free_de(struct dlm_ls *ls, int len) 34static struct dlm_direntry *get_free_de(struct dlm_ls *ls, int len)
35{ 35{
36 int found = FALSE; 36 int found = 0;
37 struct dlm_direntry *de; 37 struct dlm_direntry *de;
38 38
39 spin_lock(&ls->ls_recover_list_lock); 39 spin_lock(&ls->ls_recover_list_lock);
@@ -42,7 +42,7 @@ static struct dlm_direntry *get_free_de(struct dlm_ls *ls, int len)
42 list_del(&de->list); 42 list_del(&de->list);
43 de->master_nodeid = 0; 43 de->master_nodeid = 0;
44 memset(de->name, 0, len); 44 memset(de->name, 0, len);
45 found = TRUE; 45 found = 1;
46 break; 46 break;
47 } 47 }
48 } 48 }
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
index 0020cd07baf7..16f20cfd9197 100644
--- a/fs/dlm/dlm_internal.h
+++ b/fs/dlm/dlm_internal.h
@@ -35,6 +35,7 @@
35#include <linux/kref.h> 35#include <linux/kref.h>
36#include <linux/kernel.h> 36#include <linux/kernel.h>
37#include <linux/jhash.h> 37#include <linux/jhash.h>
38#include <linux/mutex.h>
38#include <asm/semaphore.h> 39#include <asm/semaphore.h>
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
40 41
@@ -42,20 +43,6 @@
42 43
43#define DLM_LOCKSPACE_LEN 64 44#define DLM_LOCKSPACE_LEN 64
44 45
45#ifndef TRUE
46#define TRUE 1
47#endif
48
49#ifndef FALSE
50#define FALSE 0
51#endif
52
53#if (BITS_PER_LONG == 64)
54#define PRIx64 "lx"
55#else
56#define PRIx64 "Lx"
57#endif
58
59/* Size of the temp buffer midcomms allocates on the stack. 46/* Size of the temp buffer midcomms allocates on the stack.
60 We try to make this large enough so most messages fit. 47 We try to make this large enough so most messages fit.
61 FIXME: should sctp make this unnecessary? */ 48 FIXME: should sctp make this unnecessary? */
@@ -266,7 +253,7 @@ struct dlm_lkb {
266struct dlm_rsb { 253struct dlm_rsb {
267 struct dlm_ls *res_ls; /* the lockspace */ 254 struct dlm_ls *res_ls; /* the lockspace */
268 struct kref res_ref; 255 struct kref res_ref;
269 struct semaphore res_sem; 256 struct mutex res_mutex;
270 unsigned long res_flags; 257 unsigned long res_flags;
271 int res_length; /* length of rsb name */ 258 int res_length; /* length of rsb name */
272 int res_nodeid; 259 int res_nodeid;
@@ -449,7 +436,7 @@ struct dlm_ls {
449 struct dlm_dirtable *ls_dirtbl; 436 struct dlm_dirtable *ls_dirtbl;
450 uint32_t ls_dirtbl_size; 437 uint32_t ls_dirtbl_size;
451 438
452 struct semaphore ls_waiters_sem; 439 struct mutex ls_waiters_mutex;
453 struct list_head ls_waiters; /* lkbs needing a reply */ 440 struct list_head ls_waiters; /* lkbs needing a reply */
454 441
455 struct list_head ls_nodes; /* current nodes in ls */ 442 struct list_head ls_nodes; /* current nodes in ls */
@@ -472,14 +459,14 @@ struct dlm_ls {
472 459
473 struct timer_list ls_timer; 460 struct timer_list ls_timer;
474 struct task_struct *ls_recoverd_task; 461 struct task_struct *ls_recoverd_task;
475 struct semaphore ls_recoverd_active; 462 struct mutex ls_recoverd_active;
476 spinlock_t ls_recover_lock; 463 spinlock_t ls_recover_lock;
477 uint32_t ls_recover_status; /* DLM_RS_ */ 464 uint32_t ls_recover_status; /* DLM_RS_ */
478 uint64_t ls_recover_seq; 465 uint64_t ls_recover_seq;
479 struct dlm_recover *ls_recover_args; 466 struct dlm_recover *ls_recover_args;
480 struct rw_semaphore ls_in_recovery; /* block local requests */ 467 struct rw_semaphore ls_in_recovery; /* block local requests */
481 struct list_head ls_requestqueue;/* queue remote requests */ 468 struct list_head ls_requestqueue;/* queue remote requests */
482 struct semaphore ls_requestqueue_lock; 469 struct mutex ls_requestqueue_mutex;
483 char *ls_recover_buf; 470 char *ls_recover_buf;
484 struct list_head ls_recover_list; 471 struct list_head ls_recover_list;
485 spinlock_t ls_recover_list_lock; 472 spinlock_t ls_recover_list_lock;
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 81efb361f95d..29d3b95dbb63 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -215,15 +215,15 @@ static inline int is_master_copy(struct dlm_lkb *lkb)
215{ 215{
216 if (lkb->lkb_flags & DLM_IFL_MSTCPY) 216 if (lkb->lkb_flags & DLM_IFL_MSTCPY)
217 DLM_ASSERT(lkb->lkb_nodeid, dlm_print_lkb(lkb);); 217 DLM_ASSERT(lkb->lkb_nodeid, dlm_print_lkb(lkb););
218 return (lkb->lkb_flags & DLM_IFL_MSTCPY) ? TRUE : FALSE; 218 return (lkb->lkb_flags & DLM_IFL_MSTCPY) ? 1 : 0;
219} 219}
220 220
221static inline int middle_conversion(struct dlm_lkb *lkb) 221static inline int middle_conversion(struct dlm_lkb *lkb)
222{ 222{
223 if ((lkb->lkb_grmode==DLM_LOCK_PR && lkb->lkb_rqmode==DLM_LOCK_CW) || 223 if ((lkb->lkb_grmode==DLM_LOCK_PR && lkb->lkb_rqmode==DLM_LOCK_CW) ||
224 (lkb->lkb_rqmode==DLM_LOCK_PR && lkb->lkb_grmode==DLM_LOCK_CW)) 224 (lkb->lkb_rqmode==DLM_LOCK_PR && lkb->lkb_grmode==DLM_LOCK_CW))
225 return TRUE; 225 return 1;
226 return FALSE; 226 return 0;
227} 227}
228 228
229static inline int down_conversion(struct dlm_lkb *lkb) 229static inline int down_conversion(struct dlm_lkb *lkb)
@@ -269,7 +269,7 @@ static struct dlm_rsb *create_rsb(struct dlm_ls *ls, char *name, int len)
269 r->res_ls = ls; 269 r->res_ls = ls;
270 r->res_length = len; 270 r->res_length = len;
271 memcpy(r->res_name, name, len); 271 memcpy(r->res_name, name, len);
272 init_MUTEX(&r->res_sem); 272 mutex_init(&r->res_mutex);
273 273
274 INIT_LIST_HEAD(&r->res_lookup); 274 INIT_LIST_HEAD(&r->res_lookup);
275 INIT_LIST_HEAD(&r->res_grantqueue); 275 INIT_LIST_HEAD(&r->res_grantqueue);
@@ -712,7 +712,7 @@ static void add_to_waiters(struct dlm_lkb *lkb, int mstype)
712{ 712{
713 struct dlm_ls *ls = lkb->lkb_resource->res_ls; 713 struct dlm_ls *ls = lkb->lkb_resource->res_ls;
714 714
715 down(&ls->ls_waiters_sem); 715 mutex_lock(&ls->ls_waiters_mutex);
716 if (lkb->lkb_wait_type) { 716 if (lkb->lkb_wait_type) {
717 log_print("add_to_waiters error %d", lkb->lkb_wait_type); 717 log_print("add_to_waiters error %d", lkb->lkb_wait_type);
718 goto out; 718 goto out;
@@ -721,7 +721,7 @@ static void add_to_waiters(struct dlm_lkb *lkb, int mstype)
721 kref_get(&lkb->lkb_ref); 721 kref_get(&lkb->lkb_ref);
722 list_add(&lkb->lkb_wait_reply, &ls->ls_waiters); 722 list_add(&lkb->lkb_wait_reply, &ls->ls_waiters);
723 out: 723 out:
724 up(&ls->ls_waiters_sem); 724 mutex_unlock(&ls->ls_waiters_mutex);
725} 725}
726 726
727static int _remove_from_waiters(struct dlm_lkb *lkb) 727static int _remove_from_waiters(struct dlm_lkb *lkb)
@@ -745,9 +745,9 @@ static int remove_from_waiters(struct dlm_lkb *lkb)
745 struct dlm_ls *ls = lkb->lkb_resource->res_ls; 745 struct dlm_ls *ls = lkb->lkb_resource->res_ls;
746 int error; 746 int error;
747 747
748 down(&ls->ls_waiters_sem); 748 mutex_lock(&ls->ls_waiters_mutex);
749 error = _remove_from_waiters(lkb); 749 error = _remove_from_waiters(lkb);
750 up(&ls->ls_waiters_sem); 750 mutex_unlock(&ls->ls_waiters_mutex);
751 return error; 751 return error;
752} 752}
753 753
@@ -775,14 +775,14 @@ static int shrink_bucket(struct dlm_ls *ls, int b)
775 int count = 0, found; 775 int count = 0, found;
776 776
777 for (;;) { 777 for (;;) {
778 found = FALSE; 778 found = 0;
779 write_lock(&ls->ls_rsbtbl[b].lock); 779 write_lock(&ls->ls_rsbtbl[b].lock);
780 list_for_each_entry_reverse(r, &ls->ls_rsbtbl[b].toss, 780 list_for_each_entry_reverse(r, &ls->ls_rsbtbl[b].toss,
781 res_hashchain) { 781 res_hashchain) {
782 if (!time_after_eq(jiffies, r->res_toss_time + 782 if (!time_after_eq(jiffies, r->res_toss_time +
783 dlm_config.toss_secs * HZ)) 783 dlm_config.toss_secs * HZ))
784 continue; 784 continue;
785 found = TRUE; 785 found = 1;
786 break; 786 break;
787 } 787 }
788 788
@@ -1027,9 +1027,9 @@ static inline int first_in_list(struct dlm_lkb *lkb, struct list_head *head)
1027 struct dlm_lkb *first = list_entry(head->next, struct dlm_lkb, 1027 struct dlm_lkb *first = list_entry(head->next, struct dlm_lkb,
1028 lkb_statequeue); 1028 lkb_statequeue);
1029 if (lkb->lkb_id == first->lkb_id) 1029 if (lkb->lkb_id == first->lkb_id)
1030 return TRUE; 1030 return 1;
1031 1031
1032 return FALSE; 1032 return 0;
1033} 1033}
1034 1034
1035/* Return 1 if the locks' ranges overlap. If the lkb has no range then it is 1035/* Return 1 if the locks' ranges overlap. If the lkb has no range then it is
@@ -1038,13 +1038,13 @@ static inline int first_in_list(struct dlm_lkb *lkb, struct list_head *head)
1038static inline int ranges_overlap(struct dlm_lkb *lkb1, struct dlm_lkb *lkb2) 1038static inline int ranges_overlap(struct dlm_lkb *lkb1, struct dlm_lkb *lkb2)
1039{ 1039{
1040 if (!lkb1->lkb_range || !lkb2->lkb_range) 1040 if (!lkb1->lkb_range || !lkb2->lkb_range)
1041 return TRUE; 1041 return 1;
1042 1042
1043 if (lkb1->lkb_range[RQ_RANGE_END] < lkb2->lkb_range[GR_RANGE_START] || 1043 if (lkb1->lkb_range[RQ_RANGE_END] < lkb2->lkb_range[GR_RANGE_START] ||
1044 lkb1->lkb_range[RQ_RANGE_START] > lkb2->lkb_range[GR_RANGE_END]) 1044 lkb1->lkb_range[RQ_RANGE_START] > lkb2->lkb_range[GR_RANGE_END])
1045 return FALSE; 1045 return 0;
1046 1046
1047 return TRUE; 1047 return 1;
1048} 1048}
1049 1049
1050/* Check if the given lkb conflicts with another lkb on the queue. */ 1050/* Check if the given lkb conflicts with another lkb on the queue. */
@@ -1057,9 +1057,9 @@ static int queue_conflict(struct list_head *head, struct dlm_lkb *lkb)
1057 if (this == lkb) 1057 if (this == lkb)
1058 continue; 1058 continue;
1059 if (ranges_overlap(lkb, this) && !modes_compat(this, lkb)) 1059 if (ranges_overlap(lkb, this) && !modes_compat(this, lkb))
1060 return TRUE; 1060 return 1;
1061 } 1061 }
1062 return FALSE; 1062 return 0;
1063} 1063}
1064 1064
1065/* 1065/*
@@ -1103,7 +1103,7 @@ static int conversion_deadlock_detect(struct dlm_rsb *rsb, struct dlm_lkb *lkb)
1103 continue; 1103 continue;
1104 1104
1105 if (!modes_compat(this, lkb) && !modes_compat(lkb, this)) 1105 if (!modes_compat(this, lkb) && !modes_compat(lkb, this))
1106 return TRUE; 1106 return 1;
1107 } 1107 }
1108 1108
1109 /* if lkb is on the convert queue and is preventing the first 1109 /* if lkb is on the convert queue and is preventing the first
@@ -1114,10 +1114,10 @@ static int conversion_deadlock_detect(struct dlm_rsb *rsb, struct dlm_lkb *lkb)
1114 if (self && self != first) { 1114 if (self && self != first) {
1115 if (!modes_compat(lkb, first) && 1115 if (!modes_compat(lkb, first) &&
1116 !queue_conflict(&rsb->res_grantqueue, first)) 1116 !queue_conflict(&rsb->res_grantqueue, first))
1117 return TRUE; 1117 return 1;
1118 } 1118 }
1119 1119
1120 return FALSE; 1120 return 0;
1121} 1121}
1122 1122
1123/* 1123/*
@@ -1157,7 +1157,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1157 */ 1157 */
1158 1158
1159 if (lkb->lkb_exflags & DLM_LKF_EXPEDITE) 1159 if (lkb->lkb_exflags & DLM_LKF_EXPEDITE)
1160 return TRUE; 1160 return 1;
1161 1161
1162 /* 1162 /*
1163 * A shortcut. Without this, !queue_conflict(grantqueue, lkb) would be 1163 * A shortcut. Without this, !queue_conflict(grantqueue, lkb) would be
@@ -1200,7 +1200,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1200 */ 1200 */
1201 1201
1202 if (now && conv && !(lkb->lkb_exflags & DLM_LKF_QUECVT)) 1202 if (now && conv && !(lkb->lkb_exflags & DLM_LKF_QUECVT))
1203 return TRUE; 1203 return 1;
1204 1204
1205 /* 1205 /*
1206 * When using range locks the NOORDER flag is set to avoid the standard 1206 * When using range locks the NOORDER flag is set to avoid the standard
@@ -1208,7 +1208,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1208 */ 1208 */
1209 1209
1210 if (lkb->lkb_exflags & DLM_LKF_NOORDER) 1210 if (lkb->lkb_exflags & DLM_LKF_NOORDER)
1211 return TRUE; 1211 return 1;
1212 1212
1213 /* 1213 /*
1214 * 6-3: Once in that queue [CONVERTING], a conversion request cannot be 1214 * 6-3: Once in that queue [CONVERTING], a conversion request cannot be
@@ -1217,7 +1217,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1217 */ 1217 */
1218 1218
1219 if (!now && conv && first_in_list(lkb, &r->res_convertqueue)) 1219 if (!now && conv && first_in_list(lkb, &r->res_convertqueue))
1220 return TRUE; 1220 return 1;
1221 1221
1222 /* 1222 /*
1223 * 6-4: By default, a new request is immediately granted only if all 1223 * 6-4: By default, a new request is immediately granted only if all
@@ -1232,7 +1232,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1232 1232
1233 if (now && !conv && list_empty(&r->res_convertqueue) && 1233 if (now && !conv && list_empty(&r->res_convertqueue) &&
1234 list_empty(&r->res_waitqueue)) 1234 list_empty(&r->res_waitqueue))
1235 return TRUE; 1235 return 1;
1236 1236
1237 /* 1237 /*
1238 * 6-4: Once a lock request is in the queue of ungranted new requests, 1238 * 6-4: Once a lock request is in the queue of ungranted new requests,
@@ -1244,7 +1244,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1244 1244
1245 if (!now && !conv && list_empty(&r->res_convertqueue) && 1245 if (!now && !conv && list_empty(&r->res_convertqueue) &&
1246 first_in_list(lkb, &r->res_waitqueue)) 1246 first_in_list(lkb, &r->res_waitqueue))
1247 return TRUE; 1247 return 1;
1248 1248
1249 out: 1249 out:
1250 /* 1250 /*
@@ -1257,7 +1257,7 @@ static int _can_be_granted(struct dlm_rsb *r, struct dlm_lkb *lkb, int now)
1257 lkb->lkb_sbflags |= DLM_SBF_DEMOTED; 1257 lkb->lkb_sbflags |= DLM_SBF_DEMOTED;
1258 } 1258 }
1259 1259
1260 return FALSE; 1260 return 0;
1261} 1261}
1262 1262
1263/* 1263/*
@@ -1308,7 +1308,7 @@ static int grant_pending_convert(struct dlm_rsb *r, int high)
1308 1308
1309 list_for_each_entry_safe(lkb, s, &r->res_convertqueue, lkb_statequeue) { 1309 list_for_each_entry_safe(lkb, s, &r->res_convertqueue, lkb_statequeue) {
1310 demoted = is_demoted(lkb); 1310 demoted = is_demoted(lkb);
1311 if (can_be_granted(r, lkb, FALSE)) { 1311 if (can_be_granted(r, lkb, 0)) {
1312 grant_lock_pending(r, lkb); 1312 grant_lock_pending(r, lkb);
1313 grant_restart = 1; 1313 grant_restart = 1;
1314 } else { 1314 } else {
@@ -1333,7 +1333,7 @@ static int grant_pending_wait(struct dlm_rsb *r, int high)
1333 struct dlm_lkb *lkb, *s; 1333 struct dlm_lkb *lkb, *s;
1334 1334
1335 list_for_each_entry_safe(lkb, s, &r->res_waitqueue, lkb_statequeue) { 1335 list_for_each_entry_safe(lkb, s, &r->res_waitqueue, lkb_statequeue) {
1336 if (can_be_granted(r, lkb, FALSE)) 1336 if (can_be_granted(r, lkb, 0))
1337 grant_lock_pending(r, lkb); 1337 grant_lock_pending(r, lkb);
1338 else 1338 else
1339 high = max_t(int, lkb->lkb_rqmode, high); 1339 high = max_t(int, lkb->lkb_rqmode, high);
@@ -1705,7 +1705,7 @@ static int do_request(struct dlm_rsb *r, struct dlm_lkb *lkb)
1705{ 1705{
1706 int error = 0; 1706 int error = 0;
1707 1707
1708 if (can_be_granted(r, lkb, TRUE)) { 1708 if (can_be_granted(r, lkb, 1)) {
1709 grant_lock(r, lkb); 1709 grant_lock(r, lkb);
1710 queue_cast(r, lkb, 0); 1710 queue_cast(r, lkb, 0);
1711 goto out; 1711 goto out;
@@ -1733,7 +1733,7 @@ static int do_convert(struct dlm_rsb *r, struct dlm_lkb *lkb)
1733 1733
1734 /* changing an existing lock may allow others to be granted */ 1734 /* changing an existing lock may allow others to be granted */
1735 1735
1736 if (can_be_granted(r, lkb, TRUE)) { 1736 if (can_be_granted(r, lkb, 1)) {
1737 grant_lock(r, lkb); 1737 grant_lock(r, lkb);
1738 queue_cast(r, lkb, 0); 1738 queue_cast(r, lkb, 0);
1739 grant_pending_locks(r); 1739 grant_pending_locks(r);
@@ -2556,7 +2556,7 @@ static void receive_convert(struct dlm_ls *ls, struct dlm_message *ms)
2556{ 2556{
2557 struct dlm_lkb *lkb; 2557 struct dlm_lkb *lkb;
2558 struct dlm_rsb *r; 2558 struct dlm_rsb *r;
2559 int error, reply = TRUE; 2559 int error, reply = 1;
2560 2560
2561 error = find_lkb(ls, ms->m_remid, &lkb); 2561 error = find_lkb(ls, ms->m_remid, &lkb);
2562 if (error) 2562 if (error)
@@ -3205,7 +3205,7 @@ void dlm_recover_waiters_pre(struct dlm_ls *ls)
3205{ 3205{
3206 struct dlm_lkb *lkb, *safe; 3206 struct dlm_lkb *lkb, *safe;
3207 3207
3208 down(&ls->ls_waiters_sem); 3208 mutex_lock(&ls->ls_waiters_mutex);
3209 3209
3210 list_for_each_entry_safe(lkb, safe, &ls->ls_waiters, lkb_wait_reply) { 3210 list_for_each_entry_safe(lkb, safe, &ls->ls_waiters, lkb_wait_reply) {
3211 log_debug(ls, "pre recover waiter lkid %x type %d flags %x", 3211 log_debug(ls, "pre recover waiter lkid %x type %d flags %x",
@@ -3253,7 +3253,7 @@ void dlm_recover_waiters_pre(struct dlm_ls *ls)
3253 lkb->lkb_wait_type); 3253 lkb->lkb_wait_type);
3254 } 3254 }
3255 } 3255 }
3256 up(&ls->ls_waiters_sem); 3256 mutex_unlock(&ls->ls_waiters_mutex);
3257} 3257}
3258 3258
3259static int remove_resend_waiter(struct dlm_ls *ls, struct dlm_lkb **lkb_ret) 3259static int remove_resend_waiter(struct dlm_ls *ls, struct dlm_lkb **lkb_ret)
@@ -3261,7 +3261,7 @@ static int remove_resend_waiter(struct dlm_ls *ls, struct dlm_lkb **lkb_ret)
3261 struct dlm_lkb *lkb; 3261 struct dlm_lkb *lkb;
3262 int rv = 0; 3262 int rv = 0;
3263 3263
3264 down(&ls->ls_waiters_sem); 3264 mutex_lock(&ls->ls_waiters_mutex);
3265 list_for_each_entry(lkb, &ls->ls_waiters, lkb_wait_reply) { 3265 list_for_each_entry(lkb, &ls->ls_waiters, lkb_wait_reply) {
3266 if (lkb->lkb_flags & DLM_IFL_RESEND) { 3266 if (lkb->lkb_flags & DLM_IFL_RESEND) {
3267 rv = lkb->lkb_wait_type; 3267 rv = lkb->lkb_wait_type;
@@ -3270,7 +3270,7 @@ static int remove_resend_waiter(struct dlm_ls *ls, struct dlm_lkb **lkb_ret)
3270 break; 3270 break;
3271 } 3271 }
3272 } 3272 }
3273 up(&ls->ls_waiters_sem); 3273 mutex_unlock(&ls->ls_waiters_mutex);
3274 3274
3275 if (!rv) 3275 if (!rv)
3276 lkb = NULL; 3276 lkb = NULL;
diff --git a/fs/dlm/lock.h b/fs/dlm/lock.h
index 9e6499f773da..bffab9c88b1d 100644
--- a/fs/dlm/lock.h
+++ b/fs/dlm/lock.h
@@ -38,12 +38,12 @@ static inline int is_master(struct dlm_rsb *r)
38 38
39static inline void lock_rsb(struct dlm_rsb *r) 39static inline void lock_rsb(struct dlm_rsb *r)
40{ 40{
41 down(&r->res_sem); 41 mutex_lock(&r->res_mutex);
42} 42}
43 43
44static inline void unlock_rsb(struct dlm_rsb *r) 44static inline void unlock_rsb(struct dlm_rsb *r)
45{ 45{
46 up(&r->res_sem); 46 mutex_unlock(&r->res_mutex);
47} 47}
48 48
49#endif 49#endif
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index fee4659b6582..d2ff505d51cd 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -31,7 +31,7 @@ static inline void dlm_delete_debug_file(struct dlm_ls *ls) { }
31#endif 31#endif
32 32
33static int ls_count; 33static int ls_count;
34static struct semaphore ls_lock; 34static struct mutex ls_lock;
35static struct list_head lslist; 35static struct list_head lslist;
36static spinlock_t lslist_lock; 36static spinlock_t lslist_lock;
37static struct task_struct * scand_task; 37static struct task_struct * scand_task;
@@ -177,7 +177,7 @@ int dlm_lockspace_init(void)
177 int error; 177 int error;
178 178
179 ls_count = 0; 179 ls_count = 0;
180 init_MUTEX(&ls_lock); 180 mutex_init(&ls_lock);
181 INIT_LIST_HEAD(&lslist); 181 INIT_LIST_HEAD(&lslist);
182 spin_lock_init(&lslist_lock); 182 spin_lock_init(&lslist_lock);
183 183
@@ -351,10 +351,9 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
351 return -EEXIST; 351 return -EEXIST;
352 } 352 }
353 353
354 ls = kmalloc(sizeof(struct dlm_ls) + namelen, GFP_KERNEL); 354 ls = kzalloc(sizeof(struct dlm_ls) + namelen, GFP_KERNEL);
355 if (!ls) 355 if (!ls)
356 goto out; 356 goto out;
357 memset(ls, 0, sizeof(struct dlm_ls) + namelen);
358 memcpy(ls->ls_name, name, namelen); 357 memcpy(ls->ls_name, name, namelen);
359 ls->ls_namelen = namelen; 358 ls->ls_namelen = namelen;
360 ls->ls_exflags = flags; 359 ls->ls_exflags = flags;
@@ -398,7 +397,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
398 } 397 }
399 398
400 INIT_LIST_HEAD(&ls->ls_waiters); 399 INIT_LIST_HEAD(&ls->ls_waiters);
401 init_MUTEX(&ls->ls_waiters_sem); 400 mutex_init(&ls->ls_waiters_mutex);
402 401
403 INIT_LIST_HEAD(&ls->ls_nodes); 402 INIT_LIST_HEAD(&ls->ls_nodes);
404 INIT_LIST_HEAD(&ls->ls_nodes_gone); 403 INIT_LIST_HEAD(&ls->ls_nodes_gone);
@@ -416,14 +415,14 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
416 ls->ls_uevent_result = 0; 415 ls->ls_uevent_result = 0;
417 416
418 ls->ls_recoverd_task = NULL; 417 ls->ls_recoverd_task = NULL;
419 init_MUTEX(&ls->ls_recoverd_active); 418 mutex_init(&ls->ls_recoverd_active);
420 spin_lock_init(&ls->ls_recover_lock); 419 spin_lock_init(&ls->ls_recover_lock);
421 ls->ls_recover_status = 0; 420 ls->ls_recover_status = 0;
422 ls->ls_recover_seq = 0; 421 ls->ls_recover_seq = 0;
423 ls->ls_recover_args = NULL; 422 ls->ls_recover_args = NULL;
424 init_rwsem(&ls->ls_in_recovery); 423 init_rwsem(&ls->ls_in_recovery);
425 INIT_LIST_HEAD(&ls->ls_requestqueue); 424 INIT_LIST_HEAD(&ls->ls_requestqueue);
426 init_MUTEX(&ls->ls_requestqueue_lock); 425 mutex_init(&ls->ls_requestqueue_mutex);
427 426
428 ls->ls_recover_buf = kmalloc(dlm_config.buffer_size, GFP_KERNEL); 427 ls->ls_recover_buf = kmalloc(dlm_config.buffer_size, GFP_KERNEL);
429 if (!ls->ls_recover_buf) 428 if (!ls->ls_recover_buf)
@@ -493,7 +492,7 @@ int dlm_new_lockspace(char *name, int namelen, void **lockspace,
493{ 492{
494 int error = 0; 493 int error = 0;
495 494
496 down(&ls_lock); 495 mutex_lock(&ls_lock);
497 if (!ls_count) 496 if (!ls_count)
498 error = threads_start(); 497 error = threads_start();
499 if (error) 498 if (error)
@@ -503,7 +502,7 @@ int dlm_new_lockspace(char *name, int namelen, void **lockspace,
503 if (!error) 502 if (!error)
504 ls_count++; 503 ls_count++;
505 out: 504 out:
506 up(&ls_lock); 505 mutex_unlock(&ls_lock);
507 return error; 506 return error;
508} 507}
509 508
@@ -629,11 +628,11 @@ static int release_lockspace(struct dlm_ls *ls, int force)
629 kobject_unregister(&ls->ls_kobj); 628 kobject_unregister(&ls->ls_kobj);
630 kfree(ls); 629 kfree(ls);
631 630
632 down(&ls_lock); 631 mutex_lock(&ls_lock);
633 ls_count--; 632 ls_count--;
634 if (!ls_count) 633 if (!ls_count)
635 threads_stop(); 634 threads_stop();
636 up(&ls_lock); 635 mutex_unlock(&ls_lock);
637 636
638 module_put(THIS_MODULE); 637 module_put(THIS_MODULE);
639 return 0; 638 return 0;
diff --git a/fs/dlm/member.c b/fs/dlm/member.c
index 439249b62a57..926cd0cb6bff 100644
--- a/fs/dlm/member.c
+++ b/fs/dlm/member.c
@@ -52,7 +52,7 @@ static int dlm_add_member(struct dlm_ls *ls, int nodeid)
52 struct dlm_member *memb; 52 struct dlm_member *memb;
53 int w; 53 int w;
54 54
55 memb = kmalloc(sizeof(struct dlm_member), GFP_KERNEL); 55 memb = kzalloc(sizeof(struct dlm_member), GFP_KERNEL);
56 if (!memb) 56 if (!memb)
57 return -ENOMEM; 57 return -ENOMEM;
58 58
@@ -79,9 +79,9 @@ static int dlm_is_member(struct dlm_ls *ls, int nodeid)
79 79
80 list_for_each_entry(memb, &ls->ls_nodes, list) { 80 list_for_each_entry(memb, &ls->ls_nodes, list) {
81 if (memb->nodeid == nodeid) 81 if (memb->nodeid == nodeid)
82 return TRUE; 82 return 1;
83 } 83 }
84 return FALSE; 84 return 0;
85} 85}
86 86
87int dlm_is_removed(struct dlm_ls *ls, int nodeid) 87int dlm_is_removed(struct dlm_ls *ls, int nodeid)
@@ -90,9 +90,9 @@ int dlm_is_removed(struct dlm_ls *ls, int nodeid)
90 90
91 list_for_each_entry(memb, &ls->ls_nodes_gone, list) { 91 list_for_each_entry(memb, &ls->ls_nodes_gone, list) {
92 if (memb->nodeid == nodeid) 92 if (memb->nodeid == nodeid)
93 return TRUE; 93 return 1;
94 } 94 }
95 return FALSE; 95 return 0;
96} 96}
97 97
98static void clear_memb_list(struct list_head *head) 98static void clear_memb_list(struct list_head *head)
@@ -178,10 +178,10 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out)
178 /* move departed members from ls_nodes to ls_nodes_gone */ 178 /* move departed members from ls_nodes to ls_nodes_gone */
179 179
180 list_for_each_entry_safe(memb, safe, &ls->ls_nodes, list) { 180 list_for_each_entry_safe(memb, safe, &ls->ls_nodes, list) {
181 found = FALSE; 181 found = 0;
182 for (i = 0; i < rv->node_count; i++) { 182 for (i = 0; i < rv->node_count; i++) {
183 if (memb->nodeid == rv->nodeids[i]) { 183 if (memb->nodeid == rv->nodeids[i]) {
184 found = TRUE; 184 found = 1;
185 break; 185 break;
186 } 186 }
187 } 187 }
@@ -271,10 +271,9 @@ int dlm_ls_start(struct dlm_ls *ls)
271 int *ids = NULL; 271 int *ids = NULL;
272 int error, count; 272 int error, count;
273 273
274 rv = kmalloc(sizeof(struct dlm_recover), GFP_KERNEL); 274 rv = kzalloc(sizeof(struct dlm_recover), GFP_KERNEL);
275 if (!rv) 275 if (!rv)
276 return -ENOMEM; 276 return -ENOMEM;
277 memset(rv, 0, sizeof(struct dlm_recover));
278 277
279 error = count = dlm_nodeid_list(ls->ls_name, &ids); 278 error = count = dlm_nodeid_list(ls->ls_name, &ids);
280 if (error <= 0) 279 if (error <= 0)
diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c
index d96f9bbb407c..c9b1c3d535f4 100644
--- a/fs/dlm/midcomms.c
+++ b/fs/dlm/midcomms.c
@@ -119,7 +119,7 @@ int dlm_process_incoming_buffer(int nodeid, const void *base,
119 119
120 switch (msg->h_cmd) { 120 switch (msg->h_cmd) {
121 case DLM_MSG: 121 case DLM_MSG:
122 dlm_receive_message(msg, nodeid, FALSE); 122 dlm_receive_message(msg, nodeid, 0);
123 break; 123 break;
124 124
125 case DLM_RCOM: 125 case DLM_RCOM:
diff --git a/fs/dlm/recover.c b/fs/dlm/recover.c
index 1712c97bc229..b036ee7dcb32 100644
--- a/fs/dlm/recover.c
+++ b/fs/dlm/recover.c
@@ -420,7 +420,7 @@ int dlm_recover_master_reply(struct dlm_ls *ls, struct dlm_rcom *rc)
420 420
421 r = recover_list_find(ls, rc->rc_id); 421 r = recover_list_find(ls, rc->rc_id);
422 if (!r) { 422 if (!r) {
423 log_error(ls, "dlm_recover_master_reply no id %"PRIx64"", 423 log_error(ls, "dlm_recover_master_reply no id %llx",
424 rc->rc_id); 424 rc->rc_id);
425 goto out; 425 goto out;
426 } 426 }
@@ -477,8 +477,8 @@ static int all_queues_empty(struct dlm_rsb *r)
477 if (!list_empty(&r->res_grantqueue) || 477 if (!list_empty(&r->res_grantqueue) ||
478 !list_empty(&r->res_convertqueue) || 478 !list_empty(&r->res_convertqueue) ||
479 !list_empty(&r->res_waitqueue)) 479 !list_empty(&r->res_waitqueue))
480 return FALSE; 480 return 0;
481 return TRUE; 481 return 1;
482} 482}
483 483
484static int recover_locks(struct dlm_rsb *r) 484static int recover_locks(struct dlm_rsb *r)
@@ -586,18 +586,18 @@ static void recover_lvb(struct dlm_rsb *r)
586{ 586{
587 struct dlm_lkb *lkb, *high_lkb = NULL; 587 struct dlm_lkb *lkb, *high_lkb = NULL;
588 uint32_t high_seq = 0; 588 uint32_t high_seq = 0;
589 int lock_lvb_exists = FALSE; 589 int lock_lvb_exists = 0;
590 int big_lock_exists = FALSE; 590 int big_lock_exists = 0;
591 int lvblen = r->res_ls->ls_lvblen; 591 int lvblen = r->res_ls->ls_lvblen;
592 592
593 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { 593 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) {
594 if (!(lkb->lkb_exflags & DLM_LKF_VALBLK)) 594 if (!(lkb->lkb_exflags & DLM_LKF_VALBLK))
595 continue; 595 continue;
596 596
597 lock_lvb_exists = TRUE; 597 lock_lvb_exists = 1;
598 598
599 if (lkb->lkb_grmode > DLM_LOCK_CR) { 599 if (lkb->lkb_grmode > DLM_LOCK_CR) {
600 big_lock_exists = TRUE; 600 big_lock_exists = 1;
601 goto setflag; 601 goto setflag;
602 } 602 }
603 603
@@ -611,10 +611,10 @@ static void recover_lvb(struct dlm_rsb *r)
611 if (!(lkb->lkb_exflags & DLM_LKF_VALBLK)) 611 if (!(lkb->lkb_exflags & DLM_LKF_VALBLK))
612 continue; 612 continue;
613 613
614 lock_lvb_exists = TRUE; 614 lock_lvb_exists = 1;
615 615
616 if (lkb->lkb_grmode > DLM_LOCK_CR) { 616 if (lkb->lkb_grmode > DLM_LOCK_CR) {
617 big_lock_exists = TRUE; 617 big_lock_exists = 1;
618 goto setflag; 618 goto setflag;
619 } 619 }
620 620
diff --git a/fs/dlm/recoverd.c b/fs/dlm/recoverd.c
index 06e4f7cab6e7..70103533677d 100644
--- a/fs/dlm/recoverd.c
+++ b/fs/dlm/recoverd.c
@@ -45,9 +45,9 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
45 unsigned long start; 45 unsigned long start;
46 int error, neg = 0; 46 int error, neg = 0;
47 47
48 log_debug(ls, "recover %"PRIx64"", rv->seq); 48 log_debug(ls, "recover %llx", rv->seq);
49 49
50 down(&ls->ls_recoverd_active); 50 mutex_lock(&ls->ls_recoverd_active);
51 51
52 /* 52 /*
53 * Suspending and resuming dlm_astd ensures that no lkb's from this ls 53 * Suspending and resuming dlm_astd ensures that no lkb's from this ls
@@ -199,16 +199,16 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
199 199
200 dlm_astd_wake(); 200 dlm_astd_wake();
201 201
202 log_debug(ls, "recover %"PRIx64" done: %u ms", rv->seq, 202 log_debug(ls, "recover %llx done: %u ms", rv->seq,
203 jiffies_to_msecs(jiffies - start)); 203 jiffies_to_msecs(jiffies - start));
204 up(&ls->ls_recoverd_active); 204 mutex_unlock(&ls->ls_recoverd_active);
205 205
206 return 0; 206 return 0;
207 207
208 fail: 208 fail:
209 dlm_release_root_list(ls); 209 dlm_release_root_list(ls);
210 log_debug(ls, "recover %"PRIx64" error %d", rv->seq, error); 210 log_debug(ls, "recover %llx error %d", rv->seq, error);
211 up(&ls->ls_recoverd_active); 211 mutex_unlock(&ls->ls_recoverd_active);
212 return error; 212 return error;
213} 213}
214 214
@@ -275,11 +275,11 @@ void dlm_recoverd_stop(struct dlm_ls *ls)
275 275
276void dlm_recoverd_suspend(struct dlm_ls *ls) 276void dlm_recoverd_suspend(struct dlm_ls *ls)
277{ 277{
278 down(&ls->ls_recoverd_active); 278 mutex_lock(&ls->ls_recoverd_active);
279} 279}
280 280
281void dlm_recoverd_resume(struct dlm_ls *ls) 281void dlm_recoverd_resume(struct dlm_ls *ls)
282{ 282{
283 up(&ls->ls_recoverd_active); 283 mutex_unlock(&ls->ls_recoverd_active);
284} 284}
285 285
diff --git a/fs/dlm/requestqueue.c b/fs/dlm/requestqueue.c
index 36afe99e4f93..7b2b089634a2 100644
--- a/fs/dlm/requestqueue.c
+++ b/fs/dlm/requestqueue.c
@@ -47,9 +47,9 @@ void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd)
47 e->nodeid = nodeid; 47 e->nodeid = nodeid;
48 memcpy(e->request, hd, length); 48 memcpy(e->request, hd, length);
49 49
50 down(&ls->ls_requestqueue_lock); 50 mutex_lock(&ls->ls_requestqueue_mutex);
51 list_add_tail(&e->list, &ls->ls_requestqueue); 51 list_add_tail(&e->list, &ls->ls_requestqueue);
52 up(&ls->ls_requestqueue_lock); 52 mutex_unlock(&ls->ls_requestqueue_mutex);
53} 53}
54 54
55int dlm_process_requestqueue(struct dlm_ls *ls) 55int dlm_process_requestqueue(struct dlm_ls *ls)
@@ -58,19 +58,19 @@ int dlm_process_requestqueue(struct dlm_ls *ls)
58 struct dlm_header *hd; 58 struct dlm_header *hd;
59 int error = 0; 59 int error = 0;
60 60
61 down(&ls->ls_requestqueue_lock); 61 mutex_lock(&ls->ls_requestqueue_mutex);
62 62
63 for (;;) { 63 for (;;) {
64 if (list_empty(&ls->ls_requestqueue)) { 64 if (list_empty(&ls->ls_requestqueue)) {
65 up(&ls->ls_requestqueue_lock); 65 mutex_unlock(&ls->ls_requestqueue_mutex);
66 error = 0; 66 error = 0;
67 break; 67 break;
68 } 68 }
69 e = list_entry(ls->ls_requestqueue.next, struct rq_entry, list); 69 e = list_entry(ls->ls_requestqueue.next, struct rq_entry, list);
70 up(&ls->ls_requestqueue_lock); 70 mutex_unlock(&ls->ls_requestqueue_mutex);
71 71
72 hd = (struct dlm_header *) e->request; 72 hd = (struct dlm_header *) e->request;
73 error = dlm_receive_message(hd, e->nodeid, TRUE); 73 error = dlm_receive_message(hd, e->nodeid, 1);
74 74
75 if (error == -EINTR) { 75 if (error == -EINTR) {
76 /* entry is left on requestqueue */ 76 /* entry is left on requestqueue */
@@ -78,13 +78,13 @@ int dlm_process_requestqueue(struct dlm_ls *ls)
78 break; 78 break;
79 } 79 }
80 80
81 down(&ls->ls_requestqueue_lock); 81 mutex_lock(&ls->ls_requestqueue_mutex);
82 list_del(&e->list); 82 list_del(&e->list);
83 kfree(e); 83 kfree(e);
84 84
85 if (dlm_locking_stopped(ls)) { 85 if (dlm_locking_stopped(ls)) {
86 log_debug(ls, "process_requestqueue abort running"); 86 log_debug(ls, "process_requestqueue abort running");
87 up(&ls->ls_requestqueue_lock); 87 mutex_unlock(&ls->ls_requestqueue_mutex);
88 error = -EINTR; 88 error = -EINTR;
89 break; 89 break;
90 } 90 }
@@ -105,15 +105,15 @@ int dlm_process_requestqueue(struct dlm_ls *ls)
105void dlm_wait_requestqueue(struct dlm_ls *ls) 105void dlm_wait_requestqueue(struct dlm_ls *ls)
106{ 106{
107 for (;;) { 107 for (;;) {
108 down(&ls->ls_requestqueue_lock); 108 mutex_lock(&ls->ls_requestqueue_mutex);
109 if (list_empty(&ls->ls_requestqueue)) 109 if (list_empty(&ls->ls_requestqueue))
110 break; 110 break;
111 if (dlm_locking_stopped(ls)) 111 if (dlm_locking_stopped(ls))
112 break; 112 break;
113 up(&ls->ls_requestqueue_lock); 113 mutex_unlock(&ls->ls_requestqueue_mutex);
114 schedule(); 114 schedule();
115 } 115 }
116 up(&ls->ls_requestqueue_lock); 116 mutex_unlock(&ls->ls_requestqueue_mutex);
117} 117}
118 118
119static int purge_request(struct dlm_ls *ls, struct dlm_message *ms, int nodeid) 119static int purge_request(struct dlm_ls *ls, struct dlm_message *ms, int nodeid)
@@ -170,7 +170,7 @@ void dlm_purge_requestqueue(struct dlm_ls *ls)
170 struct dlm_message *ms; 170 struct dlm_message *ms;
171 struct rq_entry *e, *safe; 171 struct rq_entry *e, *safe;
172 172
173 down(&ls->ls_requestqueue_lock); 173 mutex_lock(&ls->ls_requestqueue_mutex);
174 list_for_each_entry_safe(e, safe, &ls->ls_requestqueue, list) { 174 list_for_each_entry_safe(e, safe, &ls->ls_requestqueue, list) {
175 ms = (struct dlm_message *) e->request; 175 ms = (struct dlm_message *) e->request;
176 176
@@ -179,6 +179,6 @@ void dlm_purge_requestqueue(struct dlm_ls *ls)
179 kfree(e); 179 kfree(e);
180 } 180 }
181 } 181 }
182 up(&ls->ls_requestqueue_lock); 182 mutex_unlock(&ls->ls_requestqueue_mutex);
183} 183}
184 184