Commit 2e651013 authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman

Staging: lustre: fld: Use kzalloc and kfree

Replace OBD_ALLOC, OBD_ALLOC_WAIT, OBD_ALLOC_PTR, and OBD_ALLOC_PTR_WAIT by
kalloc/kcalloc, and OBD_FREE and OBD_FREE_PTR by kfree.

A simplified version of the semantic patch that makes these changes is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@ expression ptr,size; @@
- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@ expression ptr, size; @@
- OBD_FREE(ptr, size);
+ kfree(ptr);
// </smpl>
Signed-off-by: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5a56474a
...@@ -69,7 +69,7 @@ struct fld_cache *fld_cache_init(const char *name, ...@@ -69,7 +69,7 @@ struct fld_cache *fld_cache_init(const char *name,
LASSERT(name != NULL); LASSERT(name != NULL);
LASSERT(cache_threshold < cache_size); LASSERT(cache_threshold < cache_size);
OBD_ALLOC_PTR(cache); cache = kzalloc(sizeof(*cache), GFP_NOFS);
if (cache == NULL) if (cache == NULL)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -116,7 +116,7 @@ void fld_cache_fini(struct fld_cache *cache) ...@@ -116,7 +116,7 @@ void fld_cache_fini(struct fld_cache *cache)
CDEBUG(D_INFO, " Cache reqs: %llu\n", cache->fci_stat.fst_cache); CDEBUG(D_INFO, " Cache reqs: %llu\n", cache->fci_stat.fst_cache);
CDEBUG(D_INFO, " Cache hits: %llu%%\n", pct); CDEBUG(D_INFO, " Cache hits: %llu%%\n", pct);
OBD_FREE_PTR(cache); kfree(cache);
} }
/** /**
...@@ -128,7 +128,7 @@ void fld_cache_entry_delete(struct fld_cache *cache, ...@@ -128,7 +128,7 @@ void fld_cache_entry_delete(struct fld_cache *cache,
list_del(&node->fce_list); list_del(&node->fce_list);
list_del(&node->fce_lru); list_del(&node->fce_lru);
cache->fci_cache_count--; cache->fci_cache_count--;
OBD_FREE_PTR(node); kfree(node);
} }
/** /**
...@@ -268,7 +268,7 @@ static void fld_cache_punch_hole(struct fld_cache *cache, ...@@ -268,7 +268,7 @@ static void fld_cache_punch_hole(struct fld_cache *cache,
OBD_ALLOC_GFP(fldt, sizeof(*fldt), GFP_ATOMIC); OBD_ALLOC_GFP(fldt, sizeof(*fldt), GFP_ATOMIC);
if (!fldt) { if (!fldt) {
OBD_FREE_PTR(f_new); kfree(f_new);
/* overlap is not allowed, so dont mess up list. */ /* overlap is not allowed, so dont mess up list. */
return; return;
} }
...@@ -315,7 +315,7 @@ static void fld_cache_overlap_handle(struct fld_cache *cache, ...@@ -315,7 +315,7 @@ static void fld_cache_overlap_handle(struct fld_cache *cache,
f_curr->fce_range.lsr_end = max(f_curr->fce_range.lsr_end, f_curr->fce_range.lsr_end = max(f_curr->fce_range.lsr_end,
new_end); new_end);
OBD_FREE_PTR(f_new); kfree(f_new);
fld_fix_new_list(cache); fld_fix_new_list(cache);
} else if (new_start <= f_curr->fce_range.lsr_start && } else if (new_start <= f_curr->fce_range.lsr_start &&
...@@ -324,7 +324,7 @@ static void fld_cache_overlap_handle(struct fld_cache *cache, ...@@ -324,7 +324,7 @@ static void fld_cache_overlap_handle(struct fld_cache *cache,
* e.g. whole range migrated. update fld cache entry */ * e.g. whole range migrated. update fld cache entry */
f_curr->fce_range = *range; f_curr->fce_range = *range;
OBD_FREE_PTR(f_new); kfree(f_new);
fld_fix_new_list(cache); fld_fix_new_list(cache);
} else if (f_curr->fce_range.lsr_start < new_start && } else if (f_curr->fce_range.lsr_start < new_start &&
...@@ -364,7 +364,7 @@ struct fld_cache_entry ...@@ -364,7 +364,7 @@ struct fld_cache_entry
LASSERT(range_is_sane(range)); LASSERT(range_is_sane(range));
OBD_ALLOC_PTR(f_new); f_new = kzalloc(sizeof(*f_new), GFP_NOFS);
if (!f_new) if (!f_new)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -440,7 +440,7 @@ int fld_cache_insert(struct fld_cache *cache, ...@@ -440,7 +440,7 @@ int fld_cache_insert(struct fld_cache *cache,
rc = fld_cache_insert_nolock(cache, flde); rc = fld_cache_insert_nolock(cache, flde);
write_unlock(&cache->fci_lock); write_unlock(&cache->fci_lock);
if (rc) if (rc)
OBD_FREE_PTR(flde); kfree(flde);
return rc; return rc;
} }
......
...@@ -221,7 +221,7 @@ int fld_client_add_target(struct lu_client_fld *fld, ...@@ -221,7 +221,7 @@ int fld_client_add_target(struct lu_client_fld *fld,
CDEBUG(D_INFO, "%s: Adding target %s (idx %llu)\n", CDEBUG(D_INFO, "%s: Adding target %s (idx %llu)\n",
fld->lcf_name, name, tar->ft_idx); fld->lcf_name, name, tar->ft_idx);
OBD_ALLOC_PTR(target); target = kzalloc(sizeof(*target), GFP_NOFS);
if (target == NULL) if (target == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -229,7 +229,7 @@ int fld_client_add_target(struct lu_client_fld *fld, ...@@ -229,7 +229,7 @@ int fld_client_add_target(struct lu_client_fld *fld,
list_for_each_entry(tmp, &fld->lcf_targets, ft_chain) { list_for_each_entry(tmp, &fld->lcf_targets, ft_chain) {
if (tmp->ft_idx == tar->ft_idx) { if (tmp->ft_idx == tar->ft_idx) {
spin_unlock(&fld->lcf_lock); spin_unlock(&fld->lcf_lock);
OBD_FREE_PTR(target); kfree(target);
CERROR("Target %s exists in FLD and known as %s:#%llu\n", CERROR("Target %s exists in FLD and known as %s:#%llu\n",
name, fld_target_name(tmp), tmp->ft_idx); name, fld_target_name(tmp), tmp->ft_idx);
return -EEXIST; return -EEXIST;
...@@ -268,7 +268,7 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx) ...@@ -268,7 +268,7 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx)
if (target->ft_exp != NULL) if (target->ft_exp != NULL)
class_export_put(target->ft_exp); class_export_put(target->ft_exp);
OBD_FREE_PTR(target); kfree(target);
return 0; return 0;
} }
} }
...@@ -396,7 +396,7 @@ void fld_client_fini(struct lu_client_fld *fld) ...@@ -396,7 +396,7 @@ void fld_client_fini(struct lu_client_fld *fld)
list_del(&target->ft_chain); list_del(&target->ft_chain);
if (target->ft_exp != NULL) if (target->ft_exp != NULL)
class_export_put(target->ft_exp); class_export_put(target->ft_exp);
OBD_FREE_PTR(target); kfree(target);
} }
spin_unlock(&fld->lcf_lock); spin_unlock(&fld->lcf_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment