Commit 464dbfca authored by NeilBrown's avatar NeilBrown Committed by Greg Kroah-Hartman

staging: lustre: more LIBCFS_ALLOC conversions to GFP_KERNEL allocations.

None of these need GFP_NOFS so allocate directly.
Change matching LIBCFS_FREE() to kfree() or kvfree().
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 343fb6af
...@@ -93,11 +93,7 @@ cfs_cpt_table_free(struct cfs_cpt_table *cptab) ...@@ -93,11 +93,7 @@ cfs_cpt_table_free(struct cfs_cpt_table *cptab)
{ {
int i; int i;
if (cptab->ctb_cpu2cpt) { kvfree(cptab->ctb_cpu2cpt);
LIBCFS_FREE(cptab->ctb_cpu2cpt,
num_possible_cpus() *
sizeof(cptab->ctb_cpu2cpt[0]));
}
for (i = 0; cptab->ctb_parts && i < cptab->ctb_nparts; i++) { for (i = 0; cptab->ctb_parts && i < cptab->ctb_nparts; i++) {
struct cfs_cpu_partition *part = &cptab->ctb_parts[i]; struct cfs_cpu_partition *part = &cptab->ctb_parts[i];
...@@ -106,10 +102,7 @@ cfs_cpt_table_free(struct cfs_cpt_table *cptab) ...@@ -106,10 +102,7 @@ cfs_cpt_table_free(struct cfs_cpt_table *cptab)
free_cpumask_var(part->cpt_cpumask); free_cpumask_var(part->cpt_cpumask);
} }
if (cptab->ctb_parts) { kvfree(cptab->ctb_parts);
LIBCFS_FREE(cptab->ctb_parts,
cptab->ctb_nparts * sizeof(cptab->ctb_parts[0]));
}
kfree(cptab->ctb_nodemask); kfree(cptab->ctb_nodemask);
free_cpumask_var(cptab->ctb_cpumask); free_cpumask_var(cptab->ctb_cpumask);
...@@ -136,15 +129,17 @@ cfs_cpt_table_alloc(unsigned int ncpt) ...@@ -136,15 +129,17 @@ cfs_cpt_table_alloc(unsigned int ncpt)
!cptab->ctb_nodemask) !cptab->ctb_nodemask)
goto failed; goto failed;
LIBCFS_ALLOC(cptab->ctb_cpu2cpt, cptab->ctb_cpu2cpt = kvmalloc_array(num_possible_cpus(),
num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0])); sizeof(cptab->ctb_cpu2cpt[0]),
GFP_KERNEL);
if (!cptab->ctb_cpu2cpt) if (!cptab->ctb_cpu2cpt)
goto failed; goto failed;
memset(cptab->ctb_cpu2cpt, -1, memset(cptab->ctb_cpu2cpt, -1,
num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0])); num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0]));
LIBCFS_ALLOC(cptab->ctb_parts, ncpt * sizeof(cptab->ctb_parts[0])); cptab->ctb_parts = kvmalloc_array(ncpt, sizeof(cptab->ctb_parts[0]),
GFP_KERNEL);
if (!cptab->ctb_parts) if (!cptab->ctb_parts)
goto failed; goto failed;
......
...@@ -95,7 +95,8 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, ...@@ -95,7 +95,8 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback,
return -ENOMEM; return -ENOMEM;
if (count) { if (count) {
LIBCFS_ALLOC(eq->eq_events, count * sizeof(struct lnet_event)); eq->eq_events = kvmalloc_array(count, sizeof(struct lnet_event),
GFP_KERNEL | __GFP_ZERO);
if (!eq->eq_events) if (!eq->eq_events)
goto failed; goto failed;
/* /*
...@@ -132,8 +133,7 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, ...@@ -132,8 +133,7 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback,
return 0; return 0;
failed: failed:
if (eq->eq_events) kvfree(eq->eq_events);
LIBCFS_FREE(eq->eq_events, count * sizeof(struct lnet_event));
if (eq->eq_refs) if (eq->eq_refs)
cfs_percpt_free(eq->eq_refs); cfs_percpt_free(eq->eq_refs);
...@@ -202,8 +202,7 @@ LNetEQFree(struct lnet_handle_eq eqh) ...@@ -202,8 +202,7 @@ LNetEQFree(struct lnet_handle_eq eqh)
lnet_eq_wait_unlock(); lnet_eq_wait_unlock();
lnet_res_unlock(LNET_LOCK_EX); lnet_res_unlock(LNET_LOCK_EX);
if (events) kvfree(events);
LIBCFS_FREE(events, size * sizeof(struct lnet_event));
if (refs) if (refs)
cfs_percpt_free(refs); cfs_percpt_free(refs);
......
...@@ -170,7 +170,7 @@ lnet_ipif_enumerate(char ***namesp) ...@@ -170,7 +170,7 @@ lnet_ipif_enumerate(char ***namesp)
nalloc); nalloc);
} }
LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr)); ifr = kzalloc(nalloc * sizeof(*ifr), GFP_KERNEL);
if (!ifr) { if (!ifr) {
CERROR("ENOMEM enumerating up to %d interfaces\n", CERROR("ENOMEM enumerating up to %d interfaces\n",
nalloc); nalloc);
...@@ -195,14 +195,14 @@ lnet_ipif_enumerate(char ***namesp) ...@@ -195,14 +195,14 @@ lnet_ipif_enumerate(char ***namesp)
if (nfound < nalloc || toobig) if (nfound < nalloc || toobig)
break; break;
LIBCFS_FREE(ifr, nalloc * sizeof(*ifr)); kfree(ifr);
nalloc *= 2; nalloc *= 2;
} }
if (!nfound) if (!nfound)
goto out1; goto out1;
LIBCFS_ALLOC(names, nfound * sizeof(*names)); names = kzalloc(nfound * sizeof(*names), GFP_KERNEL);
if (!names) { if (!names) {
rc = -ENOMEM; rc = -ENOMEM;
goto out1; goto out1;
...@@ -218,7 +218,7 @@ lnet_ipif_enumerate(char ***namesp) ...@@ -218,7 +218,7 @@ lnet_ipif_enumerate(char ***namesp)
goto out2; goto out2;
} }
LIBCFS_ALLOC(names[i], IFNAMSIZ); names[i] = kmalloc(IFNAMSIZ, GFP_KERNEL);
if (!names[i]) { if (!names[i]) {
rc = -ENOMEM; rc = -ENOMEM;
goto out2; goto out2;
...@@ -235,7 +235,7 @@ lnet_ipif_enumerate(char ***namesp) ...@@ -235,7 +235,7 @@ lnet_ipif_enumerate(char ***namesp)
if (rc < 0) if (rc < 0)
lnet_ipif_free_enumeration(names, nfound); lnet_ipif_free_enumeration(names, nfound);
out1: out1:
LIBCFS_FREE(ifr, nalloc * sizeof(*ifr)); kfree(ifr);
out0: out0:
return rc; return rc;
} }
...@@ -249,9 +249,9 @@ lnet_ipif_free_enumeration(char **names, int n) ...@@ -249,9 +249,9 @@ lnet_ipif_free_enumeration(char **names, int n)
LASSERT(n > 0); LASSERT(n > 0);
for (i = 0; i < n && names[i]; i++) for (i = 0; i < n && names[i]; i++)
LIBCFS_FREE(names[i], IFNAMSIZ); kfree(names[i]);
LIBCFS_FREE(names, n * sizeof(*names)); kfree(names);
} }
EXPORT_SYMBOL(lnet_ipif_free_enumeration); EXPORT_SYMBOL(lnet_ipif_free_enumeration);
......
...@@ -648,7 +648,7 @@ static int lst_test_add_ioctl(struct lstio_test_args *args) ...@@ -648,7 +648,7 @@ static int lst_test_add_ioctl(struct lstio_test_args *args)
return -EINVAL; return -EINVAL;
if (args->lstio_tes_param) { if (args->lstio_tes_param) {
LIBCFS_ALLOC(param, args->lstio_tes_param_len); param = kmalloc(args->lstio_tes_param_len, GFP_KERNEL);
if (!param) if (!param)
goto out; goto out;
if (copy_from_user(param, args->lstio_tes_param, if (copy_from_user(param, args->lstio_tes_param,
...@@ -678,8 +678,7 @@ static int lst_test_add_ioctl(struct lstio_test_args *args) ...@@ -678,8 +678,7 @@ static int lst_test_add_ioctl(struct lstio_test_args *args)
rc = (copy_to_user(args->lstio_tes_retp, &ret, rc = (copy_to_user(args->lstio_tes_retp, &ret,
sizeof(ret))) ? -EFAULT : 0; sizeof(ret))) ? -EFAULT : 0;
out: out:
if (param) kfree(param);
LIBCFS_FREE(param, args->lstio_tes_param_len);
return rc; return rc;
} }
...@@ -702,13 +701,13 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) ...@@ -702,13 +701,13 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr)
if (data->ioc_plen1 > PAGE_SIZE) if (data->ioc_plen1 > PAGE_SIZE)
return -EINVAL; return -EINVAL;
LIBCFS_ALLOC(buf, data->ioc_plen1); buf = kmalloc(data->ioc_plen1, GFP_KERNEL);
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
/* copy in parameter */ /* copy in parameter */
if (copy_from_user(buf, data->ioc_pbuf1, data->ioc_plen1)) { if (copy_from_user(buf, data->ioc_pbuf1, data->ioc_plen1)) {
LIBCFS_FREE(buf, data->ioc_plen1); kfree(buf);
return -EFAULT; return -EFAULT;
} }
...@@ -798,7 +797,7 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) ...@@ -798,7 +797,7 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr)
out: out:
mutex_unlock(&console_session.ses_mutex); mutex_unlock(&console_session.ses_mutex);
LIBCFS_FREE(buf, data->ioc_plen1); kfree(buf);
return rc; return rc;
} }
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