aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dlm
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2007-11-07 10:06:49 -0500
committerDavid Teigland <teigland@redhat.com>2008-01-29 18:17:19 -0500
commit52bda2b5bab87c388848bbc0f4d28d04858d5a7d (patch)
treefeccf9f201d21fa3891884cfb7a46883b1adfea6 /fs/dlm
parent11b2498ba7c88343d91630d679c8f2aeb8d57c48 (diff)
dlm: use dlm prefix on alloc and free functions
The dlm functions in memory.c should use the dlm_ prefix. Also, use kzalloc/kfree directly for dlm_direntry's, removing the wrapper functions. Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs/dlm')
-rw-r--r--fs/dlm/dir.c10
-rw-r--r--fs/dlm/lock.c26
-rw-r--r--fs/dlm/lockspace.c8
-rw-r--r--fs/dlm/memory.c32
-rw-r--r--fs/dlm/memory.h16
-rw-r--r--fs/dlm/recover.c4
6 files changed, 39 insertions, 57 deletions
diff --git a/fs/dlm/dir.c b/fs/dlm/dir.c
index 46754553fdcc..600bb1d1a9b6 100644
--- a/fs/dlm/dir.c
+++ b/fs/dlm/dir.c
@@ -49,7 +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 = allocate_direntry(ls, len); 52 de = kzalloc(sizeof(struct dlm_direntry) + len, GFP_KERNEL);
53 return de; 53 return de;
54} 54}
55 55
@@ -62,7 +62,7 @@ void dlm_clear_free_entries(struct dlm_ls *ls)
62 de = list_entry(ls->ls_recover_list.next, struct dlm_direntry, 62 de = list_entry(ls->ls_recover_list.next, struct dlm_direntry,
63 list); 63 list);
64 list_del(&de->list); 64 list_del(&de->list);
65 free_direntry(de); 65 kfree(de);
66 } 66 }
67 spin_unlock(&ls->ls_recover_list_lock); 67 spin_unlock(&ls->ls_recover_list_lock);
68} 68}
@@ -171,7 +171,7 @@ void dlm_dir_remove_entry(struct dlm_ls *ls, int nodeid, char *name, int namelen
171 } 171 }
172 172
173 list_del(&de->list); 173 list_del(&de->list);
174 free_direntry(de); 174 kfree(de);
175 out: 175 out:
176 write_unlock(&ls->ls_dirtbl[bucket].lock); 176 write_unlock(&ls->ls_dirtbl[bucket].lock);
177} 177}
@@ -302,7 +302,7 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name,
302 302
303 write_unlock(&ls->ls_dirtbl[bucket].lock); 303 write_unlock(&ls->ls_dirtbl[bucket].lock);
304 304
305 de = allocate_direntry(ls, namelen); 305 de = kzalloc(sizeof(struct dlm_direntry) + namelen, GFP_KERNEL);
306 if (!de) 306 if (!de)
307 return -ENOMEM; 307 return -ENOMEM;
308 308
@@ -313,7 +313,7 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name,
313 write_lock(&ls->ls_dirtbl[bucket].lock); 313 write_lock(&ls->ls_dirtbl[bucket].lock);
314 tmp = search_bucket(ls, name, namelen, bucket); 314 tmp = search_bucket(ls, name, namelen, bucket);
315 if (tmp) { 315 if (tmp) {
316 free_direntry(de); 316 kfree(de);
317 de = tmp; 317 de = tmp;
318 } else { 318 } else {
319 list_add_tail(&de->list, &ls->ls_dirtbl[bucket].list); 319 list_add_tail(&de->list, &ls->ls_dirtbl[bucket].list);
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 63fe74df97c2..ddb46281f34d 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -334,7 +334,7 @@ static struct dlm_rsb *create_rsb(struct dlm_ls *ls, char *name, int len)
334{ 334{
335 struct dlm_rsb *r; 335 struct dlm_rsb *r;
336 336
337 r = allocate_rsb(ls, len); 337 r = dlm_allocate_rsb(ls, len);
338 if (!r) 338 if (!r)
339 return NULL; 339 return NULL;
340 340
@@ -477,7 +477,7 @@ static int find_rsb(struct dlm_ls *ls, char *name, int namelen,
477 error = _search_rsb(ls, name, namelen, bucket, 0, &tmp); 477 error = _search_rsb(ls, name, namelen, bucket, 0, &tmp);
478 if (!error) { 478 if (!error) {
479 write_unlock(&ls->ls_rsbtbl[bucket].lock); 479 write_unlock(&ls->ls_rsbtbl[bucket].lock);
480 free_rsb(r); 480 dlm_free_rsb(r);
481 r = tmp; 481 r = tmp;
482 goto out; 482 goto out;
483 } 483 }
@@ -518,7 +518,7 @@ static void toss_rsb(struct kref *kref)
518 list_move(&r->res_hashchain, &ls->ls_rsbtbl[r->res_bucket].toss); 518 list_move(&r->res_hashchain, &ls->ls_rsbtbl[r->res_bucket].toss);
519 r->res_toss_time = jiffies; 519 r->res_toss_time = jiffies;
520 if (r->res_lvbptr) { 520 if (r->res_lvbptr) {
521 free_lvb(r->res_lvbptr); 521 dlm_free_lvb(r->res_lvbptr);
522 r->res_lvbptr = NULL; 522 r->res_lvbptr = NULL;
523 } 523 }
524} 524}
@@ -588,7 +588,7 @@ static int create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret)
588 uint32_t lkid = 0; 588 uint32_t lkid = 0;
589 uint16_t bucket; 589 uint16_t bucket;
590 590
591 lkb = allocate_lkb(ls); 591 lkb = dlm_allocate_lkb(ls);
592 if (!lkb) 592 if (!lkb)
593 return -ENOMEM; 593 return -ENOMEM;
594 594
@@ -682,8 +682,8 @@ static int __put_lkb(struct dlm_ls *ls, struct dlm_lkb *lkb)
682 682
683 /* for local/process lkbs, lvbptr points to caller's lksb */ 683 /* for local/process lkbs, lvbptr points to caller's lksb */
684 if (lkb->lkb_lvbptr && is_master_copy(lkb)) 684 if (lkb->lkb_lvbptr && is_master_copy(lkb))
685 free_lvb(lkb->lkb_lvbptr); 685 dlm_free_lvb(lkb->lkb_lvbptr);
686 free_lkb(lkb); 686 dlm_free_lkb(lkb);
687 return 1; 687 return 1;
688 } else { 688 } else {
689 write_unlock(&ls->ls_lkbtbl[bucket].lock); 689 write_unlock(&ls->ls_lkbtbl[bucket].lock);
@@ -987,7 +987,7 @@ static int shrink_bucket(struct dlm_ls *ls, int b)
987 987
988 if (is_master(r)) 988 if (is_master(r))
989 dir_remove(r); 989 dir_remove(r);
990 free_rsb(r); 990 dlm_free_rsb(r);
991 count++; 991 count++;
992 } else { 992 } else {
993 write_unlock(&ls->ls_rsbtbl[b].lock); 993 write_unlock(&ls->ls_rsbtbl[b].lock);
@@ -1170,7 +1170,7 @@ static void set_lvb_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
1170 return; 1170 return;
1171 1171
1172 if (!r->res_lvbptr) 1172 if (!r->res_lvbptr)
1173 r->res_lvbptr = allocate_lvb(r->res_ls); 1173 r->res_lvbptr = dlm_allocate_lvb(r->res_ls);
1174 1174
1175 if (!r->res_lvbptr) 1175 if (!r->res_lvbptr)
1176 return; 1176 return;
@@ -1202,7 +1202,7 @@ static void set_lvb_unlock(struct dlm_rsb *r, struct dlm_lkb *lkb)
1202 return; 1202 return;
1203 1203
1204 if (!r->res_lvbptr) 1204 if (!r->res_lvbptr)
1205 r->res_lvbptr = allocate_lvb(r->res_ls); 1205 r->res_lvbptr = dlm_allocate_lvb(r->res_ls);
1206 1206
1207 if (!r->res_lvbptr) 1207 if (!r->res_lvbptr)
1208 return; 1208 return;
@@ -2985,7 +2985,7 @@ static int receive_lvb(struct dlm_ls *ls, struct dlm_lkb *lkb,
2985 2985
2986 if (lkb->lkb_exflags & DLM_LKF_VALBLK) { 2986 if (lkb->lkb_exflags & DLM_LKF_VALBLK) {
2987 if (!lkb->lkb_lvbptr) 2987 if (!lkb->lkb_lvbptr)
2988 lkb->lkb_lvbptr = allocate_lvb(ls); 2988 lkb->lkb_lvbptr = dlm_allocate_lvb(ls);
2989 if (!lkb->lkb_lvbptr) 2989 if (!lkb->lkb_lvbptr)
2990 return -ENOMEM; 2990 return -ENOMEM;
2991 len = receive_extralen(ms); 2991 len = receive_extralen(ms);
@@ -3009,7 +3009,7 @@ static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
3009 3009
3010 if (lkb->lkb_exflags & DLM_LKF_VALBLK) { 3010 if (lkb->lkb_exflags & DLM_LKF_VALBLK) {
3011 /* lkb was just created so there won't be an lvb yet */ 3011 /* lkb was just created so there won't be an lvb yet */
3012 lkb->lkb_lvbptr = allocate_lvb(ls); 3012 lkb->lkb_lvbptr = dlm_allocate_lvb(ls);
3013 if (!lkb->lkb_lvbptr) 3013 if (!lkb->lkb_lvbptr)
3014 return -ENOMEM; 3014 return -ENOMEM;
3015 } 3015 }
@@ -4183,7 +4183,7 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
4183 lkb->lkb_astaddr = (void *) (long) (rl->rl_asts & AST_COMP); 4183 lkb->lkb_astaddr = (void *) (long) (rl->rl_asts & AST_COMP);
4184 4184
4185 if (lkb->lkb_exflags & DLM_LKF_VALBLK) { 4185 if (lkb->lkb_exflags & DLM_LKF_VALBLK) {
4186 lkb->lkb_lvbptr = allocate_lvb(ls); 4186 lkb->lkb_lvbptr = dlm_allocate_lvb(ls);
4187 if (!lkb->lkb_lvbptr) 4187 if (!lkb->lkb_lvbptr)
4188 return -ENOMEM; 4188 return -ENOMEM;
4189 lvblen = rc->rc_header.h_length - sizeof(struct dlm_rcom) - 4189 lvblen = rc->rc_header.h_length - sizeof(struct dlm_rcom) -
@@ -4341,7 +4341,7 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
4341 } 4341 }
4342 } 4342 }
4343 4343
4344 /* After ua is attached to lkb it will be freed by free_lkb(). 4344 /* After ua is attached to lkb it will be freed by dlm_free_lkb().
4345 When DLM_IFL_USER is set, the dlm knows that this is a userspace 4345 When DLM_IFL_USER is set, the dlm knows that this is a userspace
4346 lock and that lkb_astparam is the dlm_user_args structure. */ 4346 lock and that lkb_astparam is the dlm_user_args structure. */
4347 4347
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index a0de1cbc603d..b180fdc51085 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -676,9 +676,9 @@ static int release_lockspace(struct dlm_ls *ls, int force)
676 dlm_del_ast(lkb); 676 dlm_del_ast(lkb);
677 677
678 if (lkb->lkb_lvbptr && lkb->lkb_flags & DLM_IFL_MSTCPY) 678 if (lkb->lkb_lvbptr && lkb->lkb_flags & DLM_IFL_MSTCPY)
679 free_lvb(lkb->lkb_lvbptr); 679 dlm_free_lvb(lkb->lkb_lvbptr);
680 680
681 free_lkb(lkb); 681 dlm_free_lkb(lkb);
682 } 682 }
683 } 683 }
684 dlm_astd_resume(); 684 dlm_astd_resume();
@@ -696,7 +696,7 @@ static int release_lockspace(struct dlm_ls *ls, int force)
696 res_hashchain); 696 res_hashchain);
697 697
698 list_del(&rsb->res_hashchain); 698 list_del(&rsb->res_hashchain);
699 free_rsb(rsb); 699 dlm_free_rsb(rsb);
700 } 700 }
701 701
702 head = &ls->ls_rsbtbl[i].toss; 702 head = &ls->ls_rsbtbl[i].toss;
@@ -704,7 +704,7 @@ static int release_lockspace(struct dlm_ls *ls, int force)
704 rsb = list_entry(head->next, struct dlm_rsb, 704 rsb = list_entry(head->next, struct dlm_rsb,
705 res_hashchain); 705 res_hashchain);
706 list_del(&rsb->res_hashchain); 706 list_del(&rsb->res_hashchain);
707 free_rsb(rsb); 707 dlm_free_rsb(rsb);
708 } 708 }
709 } 709 }
710 710
diff --git a/fs/dlm/memory.c b/fs/dlm/memory.c
index ecf0e5cb2035..f7783867491a 100644
--- a/fs/dlm/memory.c
+++ b/fs/dlm/memory.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-2005 Red Hat, Inc. All rights reserved. 5** Copyright (C) 2004-2007 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
@@ -35,7 +35,7 @@ void dlm_memory_exit(void)
35 kmem_cache_destroy(lkb_cache); 35 kmem_cache_destroy(lkb_cache);
36} 36}
37 37
38char *allocate_lvb(struct dlm_ls *ls) 38char *dlm_allocate_lvb(struct dlm_ls *ls)
39{ 39{
40 char *p; 40 char *p;
41 41
@@ -43,7 +43,7 @@ char *allocate_lvb(struct dlm_ls *ls)
43 return p; 43 return p;
44} 44}
45 45
46void free_lvb(char *p) 46void dlm_free_lvb(char *p)
47{ 47{
48 kfree(p); 48 kfree(p);
49} 49}
@@ -51,7 +51,7 @@ void free_lvb(char *p)
51/* FIXME: have some minimal space built-in to rsb for the name and 51/* FIXME: have some minimal space built-in to rsb for the name and
52 kmalloc a separate name if needed, like dentries are done */ 52 kmalloc a separate name if needed, like dentries are done */
53 53
54struct dlm_rsb *allocate_rsb(struct dlm_ls *ls, int namelen) 54struct dlm_rsb *dlm_allocate_rsb(struct dlm_ls *ls, int namelen)
55{ 55{
56 struct dlm_rsb *r; 56 struct dlm_rsb *r;
57 57
@@ -61,14 +61,14 @@ struct dlm_rsb *allocate_rsb(struct dlm_ls *ls, int namelen)
61 return r; 61 return r;
62} 62}
63 63
64void free_rsb(struct dlm_rsb *r) 64void dlm_free_rsb(struct dlm_rsb *r)
65{ 65{
66 if (r->res_lvbptr) 66 if (r->res_lvbptr)
67 free_lvb(r->res_lvbptr); 67 dlm_free_lvb(r->res_lvbptr);
68 kfree(r); 68 kfree(r);
69} 69}
70 70
71struct dlm_lkb *allocate_lkb(struct dlm_ls *ls) 71struct dlm_lkb *dlm_allocate_lkb(struct dlm_ls *ls)
72{ 72{
73 struct dlm_lkb *lkb; 73 struct dlm_lkb *lkb;
74 74
@@ -76,7 +76,7 @@ struct dlm_lkb *allocate_lkb(struct dlm_ls *ls)
76 return lkb; 76 return lkb;
77} 77}
78 78
79void free_lkb(struct dlm_lkb *lkb) 79void dlm_free_lkb(struct dlm_lkb *lkb)
80{ 80{
81 if (lkb->lkb_flags & DLM_IFL_USER) { 81 if (lkb->lkb_flags & DLM_IFL_USER) {
82 struct dlm_user_args *ua; 82 struct dlm_user_args *ua;
@@ -90,19 +90,3 @@ void free_lkb(struct dlm_lkb *lkb)
90 kmem_cache_free(lkb_cache, lkb); 90 kmem_cache_free(lkb_cache, lkb);
91} 91}
92 92
93struct dlm_direntry *allocate_direntry(struct dlm_ls *ls, int namelen)
94{
95 struct dlm_direntry *de;
96
97 DLM_ASSERT(namelen <= DLM_RESNAME_MAXLEN,
98 printk("namelen = %d\n", namelen););
99
100 de = kzalloc(sizeof(*de) + namelen, GFP_KERNEL);
101 return de;
102}
103
104void free_direntry(struct dlm_direntry *de)
105{
106 kfree(de);
107}
108
diff --git a/fs/dlm/memory.h b/fs/dlm/memory.h
index 6ead158ccc5c..485fb29143bd 100644
--- a/fs/dlm/memory.h
+++ b/fs/dlm/memory.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-2005 Red Hat, Inc. All rights reserved. 5** Copyright (C) 2004-2007 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
@@ -16,14 +16,12 @@
16 16
17int dlm_memory_init(void); 17int dlm_memory_init(void);
18void dlm_memory_exit(void); 18void dlm_memory_exit(void);
19struct dlm_rsb *allocate_rsb(struct dlm_ls *ls, int namelen); 19struct dlm_rsb *dlm_allocate_rsb(struct dlm_ls *ls, int namelen);
20void free_rsb(struct dlm_rsb *r); 20void dlm_free_rsb(struct dlm_rsb *r);
21struct dlm_lkb *allocate_lkb(struct dlm_ls *ls); 21struct dlm_lkb *dlm_allocate_lkb(struct dlm_ls *ls);
22void free_lkb(struct dlm_lkb *l); 22void dlm_free_lkb(struct dlm_lkb *l);
23struct dlm_direntry *allocate_direntry(struct dlm_ls *ls, int namelen); 23char *dlm_allocate_lvb(struct dlm_ls *ls);
24void free_direntry(struct dlm_direntry *de); 24void dlm_free_lvb(char *l);
25char *allocate_lvb(struct dlm_ls *ls);
26void free_lvb(char *l);
27 25
28#endif /* __MEMORY_DOT_H__ */ 26#endif /* __MEMORY_DOT_H__ */
29 27
diff --git a/fs/dlm/recover.c b/fs/dlm/recover.c
index c2cc7694cd16..2f9d9a30df97 100644
--- a/fs/dlm/recover.c
+++ b/fs/dlm/recover.c
@@ -629,7 +629,7 @@ static void recover_lvb(struct dlm_rsb *r)
629 goto out; 629 goto out;
630 630
631 if (!r->res_lvbptr) { 631 if (!r->res_lvbptr) {
632 r->res_lvbptr = allocate_lvb(r->res_ls); 632 r->res_lvbptr = dlm_allocate_lvb(r->res_ls);
633 if (!r->res_lvbptr) 633 if (!r->res_lvbptr)
634 goto out; 634 goto out;
635 } 635 }
@@ -760,7 +760,7 @@ void dlm_clear_toss_list(struct dlm_ls *ls)
760 list_for_each_entry_safe(r, safe, &ls->ls_rsbtbl[i].toss, 760 list_for_each_entry_safe(r, safe, &ls->ls_rsbtbl[i].toss,
761 res_hashchain) { 761 res_hashchain) {
762 list_del(&r->res_hashchain); 762 list_del(&r->res_hashchain);
763 free_rsb(r); 763 dlm_free_rsb(r);
764 } 764 }
765 write_unlock(&ls->ls_rsbtbl[i].lock); 765 write_unlock(&ls->ls_rsbtbl[i].lock);
766 } 766 }