Skip to content

Commit 1169788

Browse files
Alexander Aringteigland
authored andcommitted
dlm: cleanup memory allocation helpers
This patch removes a unnecessary parameter from DLM memory allocation helpers and reduce some functions by just directly reply the pointer address of the allocated memory. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent de9c2c6 commit 1169788

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

fs/dlm/lock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ static int get_rsb_struct(struct dlm_ls *ls, const void *name, int len,
600600
{
601601
struct dlm_rsb *r;
602602

603-
r = dlm_allocate_rsb(ls);
603+
r = dlm_allocate_rsb();
604604
if (!r)
605605
return -ENOMEM;
606606

@@ -1497,7 +1497,7 @@ static int _create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret,
14971497
limit.max = end;
14981498
limit.min = start;
14991499

1500-
lkb = dlm_allocate_lkb(ls);
1500+
lkb = dlm_allocate_lkb();
15011501
if (!lkb)
15021502
return -ENOMEM;
15031503

fs/dlm/memory.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,17 @@ void dlm_memory_exit(void)
8484

8585
char *dlm_allocate_lvb(struct dlm_ls *ls)
8686
{
87-
char *p;
88-
89-
p = kzalloc(ls->ls_lvblen, GFP_ATOMIC);
90-
return p;
87+
return kzalloc(ls->ls_lvblen, GFP_ATOMIC);
9188
}
9289

9390
void dlm_free_lvb(char *p)
9491
{
9592
kfree(p);
9693
}
9794

98-
struct dlm_rsb *dlm_allocate_rsb(struct dlm_ls *ls)
95+
struct dlm_rsb *dlm_allocate_rsb(void)
9996
{
100-
struct dlm_rsb *r;
101-
102-
r = kmem_cache_zalloc(rsb_cache, GFP_ATOMIC);
103-
return r;
97+
return kmem_cache_zalloc(rsb_cache, GFP_ATOMIC);
10498
}
10599

106100
static void __free_rsb_rcu(struct rcu_head *rcu)
@@ -116,12 +110,9 @@ void dlm_free_rsb(struct dlm_rsb *r)
116110
call_rcu(&r->rcu, __free_rsb_rcu);
117111
}
118112

119-
struct dlm_lkb *dlm_allocate_lkb(struct dlm_ls *ls)
113+
struct dlm_lkb *dlm_allocate_lkb(void)
120114
{
121-
struct dlm_lkb *lkb;
122-
123-
lkb = kmem_cache_zalloc(lkb_cache, GFP_ATOMIC);
124-
return lkb;
115+
return kmem_cache_zalloc(lkb_cache, GFP_ATOMIC);
125116
}
126117

127118
void dlm_free_lkb(struct dlm_lkb *lkb)

fs/dlm/memory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
int dlm_memory_init(void);
1616
void dlm_memory_exit(void);
17-
struct dlm_rsb *dlm_allocate_rsb(struct dlm_ls *ls);
17+
struct dlm_rsb *dlm_allocate_rsb(void);
1818
void dlm_free_rsb(struct dlm_rsb *r);
19-
struct dlm_lkb *dlm_allocate_lkb(struct dlm_ls *ls);
19+
struct dlm_lkb *dlm_allocate_lkb(void);
2020
void dlm_free_lkb(struct dlm_lkb *l);
2121
char *dlm_allocate_lvb(struct dlm_ls *ls);
2222
void dlm_free_lvb(char *l);

0 commit comments

Comments
 (0)