Commit 52bda2b5bab87c388848bbc0f4d28d04858d5a7d
1 parent
11b2498ba7
Exists in
master
and in
4 other branches
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>
Showing 6 changed files with 39 additions and 57 deletions Side-by-side Diff
fs/dlm/dir.c
... | ... | @@ -49,7 +49,7 @@ |
49 | 49 | spin_unlock(&ls->ls_recover_list_lock); |
50 | 50 | |
51 | 51 | if (!found) |
52 | - de = allocate_direntry(ls, len); | |
52 | + de = kzalloc(sizeof(struct dlm_direntry) + len, GFP_KERNEL); | |
53 | 53 | return de; |
54 | 54 | } |
55 | 55 | |
... | ... | @@ -62,7 +62,7 @@ |
62 | 62 | de = list_entry(ls->ls_recover_list.next, struct dlm_direntry, |
63 | 63 | list); |
64 | 64 | list_del(&de->list); |
65 | - free_direntry(de); | |
65 | + kfree(de); | |
66 | 66 | } |
67 | 67 | spin_unlock(&ls->ls_recover_list_lock); |
68 | 68 | } |
... | ... | @@ -171,7 +171,7 @@ |
171 | 171 | } |
172 | 172 | |
173 | 173 | list_del(&de->list); |
174 | - free_direntry(de); | |
174 | + kfree(de); | |
175 | 175 | out: |
176 | 176 | write_unlock(&ls->ls_dirtbl[bucket].lock); |
177 | 177 | } |
... | ... | @@ -302,7 +302,7 @@ |
302 | 302 | |
303 | 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 | 306 | if (!de) |
307 | 307 | return -ENOMEM; |
308 | 308 | |
... | ... | @@ -313,7 +313,7 @@ |
313 | 313 | write_lock(&ls->ls_dirtbl[bucket].lock); |
314 | 314 | tmp = search_bucket(ls, name, namelen, bucket); |
315 | 315 | if (tmp) { |
316 | - free_direntry(de); | |
316 | + kfree(de); | |
317 | 317 | de = tmp; |
318 | 318 | } else { |
319 | 319 | list_add_tail(&de->list, &ls->ls_dirtbl[bucket].list); |
fs/dlm/lock.c
... | ... | @@ -334,7 +334,7 @@ |
334 | 334 | { |
335 | 335 | struct dlm_rsb *r; |
336 | 336 | |
337 | - r = allocate_rsb(ls, len); | |
337 | + r = dlm_allocate_rsb(ls, len); | |
338 | 338 | if (!r) |
339 | 339 | return NULL; |
340 | 340 | |
... | ... | @@ -477,7 +477,7 @@ |
477 | 477 | error = _search_rsb(ls, name, namelen, bucket, 0, &tmp); |
478 | 478 | if (!error) { |
479 | 479 | write_unlock(&ls->ls_rsbtbl[bucket].lock); |
480 | - free_rsb(r); | |
480 | + dlm_free_rsb(r); | |
481 | 481 | r = tmp; |
482 | 482 | goto out; |
483 | 483 | } |
... | ... | @@ -518,7 +518,7 @@ |
518 | 518 | list_move(&r->res_hashchain, &ls->ls_rsbtbl[r->res_bucket].toss); |
519 | 519 | r->res_toss_time = jiffies; |
520 | 520 | if (r->res_lvbptr) { |
521 | - free_lvb(r->res_lvbptr); | |
521 | + dlm_free_lvb(r->res_lvbptr); | |
522 | 522 | r->res_lvbptr = NULL; |
523 | 523 | } |
524 | 524 | } |
... | ... | @@ -588,7 +588,7 @@ |
588 | 588 | uint32_t lkid = 0; |
589 | 589 | uint16_t bucket; |
590 | 590 | |
591 | - lkb = allocate_lkb(ls); | |
591 | + lkb = dlm_allocate_lkb(ls); | |
592 | 592 | if (!lkb) |
593 | 593 | return -ENOMEM; |
594 | 594 | |
... | ... | @@ -682,8 +682,8 @@ |
682 | 682 | |
683 | 683 | /* for local/process lkbs, lvbptr points to caller's lksb */ |
684 | 684 | if (lkb->lkb_lvbptr && is_master_copy(lkb)) |
685 | - free_lvb(lkb->lkb_lvbptr); | |
686 | - free_lkb(lkb); | |
685 | + dlm_free_lvb(lkb->lkb_lvbptr); | |
686 | + dlm_free_lkb(lkb); | |
687 | 687 | return 1; |
688 | 688 | } else { |
689 | 689 | write_unlock(&ls->ls_lkbtbl[bucket].lock); |
... | ... | @@ -987,7 +987,7 @@ |
987 | 987 | |
988 | 988 | if (is_master(r)) |
989 | 989 | dir_remove(r); |
990 | - free_rsb(r); | |
990 | + dlm_free_rsb(r); | |
991 | 991 | count++; |
992 | 992 | } else { |
993 | 993 | write_unlock(&ls->ls_rsbtbl[b].lock); |
... | ... | @@ -1170,7 +1170,7 @@ |
1170 | 1170 | return; |
1171 | 1171 | |
1172 | 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 | 1175 | if (!r->res_lvbptr) |
1176 | 1176 | return; |
... | ... | @@ -1202,7 +1202,7 @@ |
1202 | 1202 | return; |
1203 | 1203 | |
1204 | 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 | 1207 | if (!r->res_lvbptr) |
1208 | 1208 | return; |
... | ... | @@ -2985,7 +2985,7 @@ |
2985 | 2985 | |
2986 | 2986 | if (lkb->lkb_exflags & DLM_LKF_VALBLK) { |
2987 | 2987 | if (!lkb->lkb_lvbptr) |
2988 | - lkb->lkb_lvbptr = allocate_lvb(ls); | |
2988 | + lkb->lkb_lvbptr = dlm_allocate_lvb(ls); | |
2989 | 2989 | if (!lkb->lkb_lvbptr) |
2990 | 2990 | return -ENOMEM; |
2991 | 2991 | len = receive_extralen(ms); |
... | ... | @@ -3009,7 +3009,7 @@ |
3009 | 3009 | |
3010 | 3010 | if (lkb->lkb_exflags & DLM_LKF_VALBLK) { |
3011 | 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 | 3013 | if (!lkb->lkb_lvbptr) |
3014 | 3014 | return -ENOMEM; |
3015 | 3015 | } |
... | ... | @@ -4183,7 +4183,7 @@ |
4183 | 4183 | lkb->lkb_astaddr = (void *) (long) (rl->rl_asts & AST_COMP); |
4184 | 4184 | |
4185 | 4185 | if (lkb->lkb_exflags & DLM_LKF_VALBLK) { |
4186 | - lkb->lkb_lvbptr = allocate_lvb(ls); | |
4186 | + lkb->lkb_lvbptr = dlm_allocate_lvb(ls); | |
4187 | 4187 | if (!lkb->lkb_lvbptr) |
4188 | 4188 | return -ENOMEM; |
4189 | 4189 | lvblen = rc->rc_header.h_length - sizeof(struct dlm_rcom) - |
... | ... | @@ -4341,7 +4341,7 @@ |
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 | 4345 | When DLM_IFL_USER is set, the dlm knows that this is a userspace |
4346 | 4346 | lock and that lkb_astparam is the dlm_user_args structure. */ |
4347 | 4347 |
fs/dlm/lockspace.c
... | ... | @@ -676,9 +676,9 @@ |
676 | 676 | dlm_del_ast(lkb); |
677 | 677 | |
678 | 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 | 684 | dlm_astd_resume(); |
... | ... | @@ -696,7 +696,7 @@ |
696 | 696 | res_hashchain); |
697 | 697 | |
698 | 698 | list_del(&rsb->res_hashchain); |
699 | - free_rsb(rsb); | |
699 | + dlm_free_rsb(rsb); | |
700 | 700 | } |
701 | 701 | |
702 | 702 | head = &ls->ls_rsbtbl[i].toss; |
... | ... | @@ -704,7 +704,7 @@ |
704 | 704 | rsb = list_entry(head->next, struct dlm_rsb, |
705 | 705 | res_hashchain); |
706 | 706 | list_del(&rsb->res_hashchain); |
707 | - free_rsb(rsb); | |
707 | + dlm_free_rsb(rsb); | |
708 | 708 | } |
709 | 709 | } |
710 | 710 |
fs/dlm/memory.c
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | ******************************************************************************* |
3 | 3 | ** |
4 | 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 | 7 | ** This copyrighted material is made available to anyone wishing to use, |
8 | 8 | ** modify, copy, or redistribute it subject to the terms and conditions |
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 | kmem_cache_destroy(lkb_cache); |
36 | 36 | } |
37 | 37 | |
38 | -char *allocate_lvb(struct dlm_ls *ls) | |
38 | +char *dlm_allocate_lvb(struct dlm_ls *ls) | |
39 | 39 | { |
40 | 40 | char *p; |
41 | 41 | |
... | ... | @@ -43,7 +43,7 @@ |
43 | 43 | return p; |
44 | 44 | } |
45 | 45 | |
46 | -void free_lvb(char *p) | |
46 | +void dlm_free_lvb(char *p) | |
47 | 47 | { |
48 | 48 | kfree(p); |
49 | 49 | } |
... | ... | @@ -51,7 +51,7 @@ |
51 | 51 | /* FIXME: have some minimal space built-in to rsb for the name and |
52 | 52 | kmalloc a separate name if needed, like dentries are done */ |
53 | 53 | |
54 | -struct dlm_rsb *allocate_rsb(struct dlm_ls *ls, int namelen) | |
54 | +struct dlm_rsb *dlm_allocate_rsb(struct dlm_ls *ls, int namelen) | |
55 | 55 | { |
56 | 56 | struct dlm_rsb *r; |
57 | 57 | |
58 | 58 | |
59 | 59 | |
... | ... | @@ -61,14 +61,14 @@ |
61 | 61 | return r; |
62 | 62 | } |
63 | 63 | |
64 | -void free_rsb(struct dlm_rsb *r) | |
64 | +void dlm_free_rsb(struct dlm_rsb *r) | |
65 | 65 | { |
66 | 66 | if (r->res_lvbptr) |
67 | - free_lvb(r->res_lvbptr); | |
67 | + dlm_free_lvb(r->res_lvbptr); | |
68 | 68 | kfree(r); |
69 | 69 | } |
70 | 70 | |
71 | -struct dlm_lkb *allocate_lkb(struct dlm_ls *ls) | |
71 | +struct dlm_lkb *dlm_allocate_lkb(struct dlm_ls *ls) | |
72 | 72 | { |
73 | 73 | struct dlm_lkb *lkb; |
74 | 74 | |
... | ... | @@ -76,7 +76,7 @@ |
76 | 76 | return lkb; |
77 | 77 | } |
78 | 78 | |
79 | -void free_lkb(struct dlm_lkb *lkb) | |
79 | +void dlm_free_lkb(struct dlm_lkb *lkb) | |
80 | 80 | { |
81 | 81 | if (lkb->lkb_flags & DLM_IFL_USER) { |
82 | 82 | struct dlm_user_args *ua; |
... | ... | @@ -88,21 +88,5 @@ |
88 | 88 | } |
89 | 89 | } |
90 | 90 | kmem_cache_free(lkb_cache, lkb); |
91 | -} | |
92 | - | |
93 | -struct 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 | - | |
104 | -void free_direntry(struct dlm_direntry *de) | |
105 | -{ | |
106 | - kfree(de); | |
107 | 91 | } |
fs/dlm/memory.h
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | ******************************************************************************* |
3 | 3 | ** |
4 | 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 | 7 | ** This copyrighted material is made available to anyone wishing to use, |
8 | 8 | ** modify, copy, or redistribute it subject to the terms and conditions |
... | ... | @@ -16,14 +16,12 @@ |
16 | 16 | |
17 | 17 | int dlm_memory_init(void); |
18 | 18 | void dlm_memory_exit(void); |
19 | -struct dlm_rsb *allocate_rsb(struct dlm_ls *ls, int namelen); | |
20 | -void free_rsb(struct dlm_rsb *r); | |
21 | -struct dlm_lkb *allocate_lkb(struct dlm_ls *ls); | |
22 | -void free_lkb(struct dlm_lkb *l); | |
23 | -struct dlm_direntry *allocate_direntry(struct dlm_ls *ls, int namelen); | |
24 | -void free_direntry(struct dlm_direntry *de); | |
25 | -char *allocate_lvb(struct dlm_ls *ls); | |
26 | -void free_lvb(char *l); | |
19 | +struct dlm_rsb *dlm_allocate_rsb(struct dlm_ls *ls, int namelen); | |
20 | +void dlm_free_rsb(struct dlm_rsb *r); | |
21 | +struct dlm_lkb *dlm_allocate_lkb(struct dlm_ls *ls); | |
22 | +void dlm_free_lkb(struct dlm_lkb *l); | |
23 | +char *dlm_allocate_lvb(struct dlm_ls *ls); | |
24 | +void dlm_free_lvb(char *l); | |
27 | 25 | |
28 | 26 | #endif /* __MEMORY_DOT_H__ */ |
fs/dlm/recover.c
... | ... | @@ -629,7 +629,7 @@ |
629 | 629 | goto out; |
630 | 630 | |
631 | 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 | 633 | if (!r->res_lvbptr) |
634 | 634 | goto out; |
635 | 635 | } |
... | ... | @@ -760,7 +760,7 @@ |
760 | 760 | list_for_each_entry_safe(r, safe, &ls->ls_rsbtbl[i].toss, |
761 | 761 | res_hashchain) { |
762 | 762 | list_del(&r->res_hashchain); |
763 | - free_rsb(r); | |
763 | + dlm_free_rsb(r); | |
764 | 764 | } |
765 | 765 | write_unlock(&ls->ls_rsbtbl[i].lock); |
766 | 766 | } |