diff options
author | NeilBrown <neilb@suse.com> | 2018-01-08 20:19:38 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-01-09 09:41:57 -0500 |
commit | 464dbfcaa2d581c6bc03e87c73af1dc403336b85 (patch) | |
tree | 56328d5739523b3da697f000b10be207896f5611 | |
parent | 343fb6af089cc7afc4041556a1cc27029a8eb2a0 (diff) |
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: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | 19 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/lib-eq.c | 9 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/lnet/lib-socket.c | 14 | ||||
-rw-r--r-- | drivers/staging/lustre/lnet/selftest/conctl.c | 11 |
4 files changed, 23 insertions, 30 deletions
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c index 51196fda2a32..c07165e0ad95 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c | |||
@@ -93,11 +93,7 @@ cfs_cpt_table_free(struct cfs_cpt_table *cptab) | |||
93 | { | 93 | { |
94 | int i; | 94 | int i; |
95 | 95 | ||
96 | if (cptab->ctb_cpu2cpt) { | 96 | kvfree(cptab->ctb_cpu2cpt); |
97 | LIBCFS_FREE(cptab->ctb_cpu2cpt, | ||
98 | num_possible_cpus() * | ||
99 | sizeof(cptab->ctb_cpu2cpt[0])); | ||
100 | } | ||
101 | 97 | ||
102 | for (i = 0; cptab->ctb_parts && i < cptab->ctb_nparts; i++) { | 98 | for (i = 0; cptab->ctb_parts && i < cptab->ctb_nparts; i++) { |
103 | struct cfs_cpu_partition *part = &cptab->ctb_parts[i]; | 99 | struct cfs_cpu_partition *part = &cptab->ctb_parts[i]; |
@@ -106,10 +102,7 @@ cfs_cpt_table_free(struct cfs_cpt_table *cptab) | |||
106 | free_cpumask_var(part->cpt_cpumask); | 102 | free_cpumask_var(part->cpt_cpumask); |
107 | } | 103 | } |
108 | 104 | ||
109 | if (cptab->ctb_parts) { | 105 | kvfree(cptab->ctb_parts); |
110 | LIBCFS_FREE(cptab->ctb_parts, | ||
111 | cptab->ctb_nparts * sizeof(cptab->ctb_parts[0])); | ||
112 | } | ||
113 | 106 | ||
114 | kfree(cptab->ctb_nodemask); | 107 | kfree(cptab->ctb_nodemask); |
115 | free_cpumask_var(cptab->ctb_cpumask); | 108 | free_cpumask_var(cptab->ctb_cpumask); |
@@ -136,15 +129,17 @@ cfs_cpt_table_alloc(unsigned int ncpt) | |||
136 | !cptab->ctb_nodemask) | 129 | !cptab->ctb_nodemask) |
137 | goto failed; | 130 | goto failed; |
138 | 131 | ||
139 | LIBCFS_ALLOC(cptab->ctb_cpu2cpt, | 132 | cptab->ctb_cpu2cpt = kvmalloc_array(num_possible_cpus(), |
140 | num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0])); | 133 | sizeof(cptab->ctb_cpu2cpt[0]), |
134 | GFP_KERNEL); | ||
141 | if (!cptab->ctb_cpu2cpt) | 135 | if (!cptab->ctb_cpu2cpt) |
142 | goto failed; | 136 | goto failed; |
143 | 137 | ||
144 | memset(cptab->ctb_cpu2cpt, -1, | 138 | memset(cptab->ctb_cpu2cpt, -1, |
145 | num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0])); | 139 | num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0])); |
146 | 140 | ||
147 | LIBCFS_ALLOC(cptab->ctb_parts, ncpt * sizeof(cptab->ctb_parts[0])); | 141 | cptab->ctb_parts = kvmalloc_array(ncpt, sizeof(cptab->ctb_parts[0]), |
142 | GFP_KERNEL); | ||
148 | if (!cptab->ctb_parts) | 143 | if (!cptab->ctb_parts) |
149 | goto failed; | 144 | goto failed; |
150 | 145 | ||
diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index 7a4d1f7a693e..a173b69e2f92 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c | |||
@@ -95,7 +95,8 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, | |||
95 | return -ENOMEM; | 95 | return -ENOMEM; |
96 | 96 | ||
97 | if (count) { | 97 | if (count) { |
98 | LIBCFS_ALLOC(eq->eq_events, count * sizeof(struct lnet_event)); | 98 | eq->eq_events = kvmalloc_array(count, sizeof(struct lnet_event), |
99 | GFP_KERNEL | __GFP_ZERO); | ||
99 | if (!eq->eq_events) | 100 | if (!eq->eq_events) |
100 | goto failed; | 101 | goto failed; |
101 | /* | 102 | /* |
@@ -132,8 +133,7 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, | |||
132 | return 0; | 133 | return 0; |
133 | 134 | ||
134 | failed: | 135 | failed: |
135 | if (eq->eq_events) | 136 | kvfree(eq->eq_events); |
136 | LIBCFS_FREE(eq->eq_events, count * sizeof(struct lnet_event)); | ||
137 | 137 | ||
138 | if (eq->eq_refs) | 138 | if (eq->eq_refs) |
139 | cfs_percpt_free(eq->eq_refs); | 139 | cfs_percpt_free(eq->eq_refs); |
@@ -202,8 +202,7 @@ LNetEQFree(struct lnet_handle_eq eqh) | |||
202 | lnet_eq_wait_unlock(); | 202 | lnet_eq_wait_unlock(); |
203 | lnet_res_unlock(LNET_LOCK_EX); | 203 | lnet_res_unlock(LNET_LOCK_EX); |
204 | 204 | ||
205 | if (events) | 205 | kvfree(events); |
206 | LIBCFS_FREE(events, size * sizeof(struct lnet_event)); | ||
207 | if (refs) | 206 | if (refs) |
208 | cfs_percpt_free(refs); | 207 | cfs_percpt_free(refs); |
209 | 208 | ||
diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c index 7d49d4865298..fcd9d1b7c619 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c | |||
@@ -170,7 +170,7 @@ lnet_ipif_enumerate(char ***namesp) | |||
170 | nalloc); | 170 | nalloc); |
171 | } | 171 | } |
172 | 172 | ||
173 | LIBCFS_ALLOC(ifr, nalloc * sizeof(*ifr)); | 173 | ifr = kzalloc(nalloc * sizeof(*ifr), GFP_KERNEL); |
174 | if (!ifr) { | 174 | if (!ifr) { |
175 | CERROR("ENOMEM enumerating up to %d interfaces\n", | 175 | CERROR("ENOMEM enumerating up to %d interfaces\n", |
176 | nalloc); | 176 | nalloc); |
@@ -195,14 +195,14 @@ lnet_ipif_enumerate(char ***namesp) | |||
195 | if (nfound < nalloc || toobig) | 195 | if (nfound < nalloc || toobig) |
196 | break; | 196 | break; |
197 | 197 | ||
198 | LIBCFS_FREE(ifr, nalloc * sizeof(*ifr)); | 198 | kfree(ifr); |
199 | nalloc *= 2; | 199 | nalloc *= 2; |
200 | } | 200 | } |
201 | 201 | ||
202 | if (!nfound) | 202 | if (!nfound) |
203 | goto out1; | 203 | goto out1; |
204 | 204 | ||
205 | LIBCFS_ALLOC(names, nfound * sizeof(*names)); | 205 | names = kzalloc(nfound * sizeof(*names), GFP_KERNEL); |
206 | if (!names) { | 206 | if (!names) { |
207 | rc = -ENOMEM; | 207 | rc = -ENOMEM; |
208 | goto out1; | 208 | goto out1; |
@@ -218,7 +218,7 @@ lnet_ipif_enumerate(char ***namesp) | |||
218 | goto out2; | 218 | goto out2; |
219 | } | 219 | } |
220 | 220 | ||
221 | LIBCFS_ALLOC(names[i], IFNAMSIZ); | 221 | names[i] = kmalloc(IFNAMSIZ, GFP_KERNEL); |
222 | if (!names[i]) { | 222 | if (!names[i]) { |
223 | rc = -ENOMEM; | 223 | rc = -ENOMEM; |
224 | goto out2; | 224 | goto out2; |
@@ -235,7 +235,7 @@ out2: | |||
235 | if (rc < 0) | 235 | if (rc < 0) |
236 | lnet_ipif_free_enumeration(names, nfound); | 236 | lnet_ipif_free_enumeration(names, nfound); |
237 | out1: | 237 | out1: |
238 | LIBCFS_FREE(ifr, nalloc * sizeof(*ifr)); | 238 | kfree(ifr); |
239 | out0: | 239 | out0: |
240 | return rc; | 240 | return rc; |
241 | } | 241 | } |
@@ -249,9 +249,9 @@ lnet_ipif_free_enumeration(char **names, int n) | |||
249 | LASSERT(n > 0); | 249 | LASSERT(n > 0); |
250 | 250 | ||
251 | for (i = 0; i < n && names[i]; i++) | 251 | for (i = 0; i < n && names[i]; i++) |
252 | LIBCFS_FREE(names[i], IFNAMSIZ); | 252 | kfree(names[i]); |
253 | 253 | ||
254 | LIBCFS_FREE(names, n * sizeof(*names)); | 254 | kfree(names); |
255 | } | 255 | } |
256 | EXPORT_SYMBOL(lnet_ipif_free_enumeration); | 256 | EXPORT_SYMBOL(lnet_ipif_free_enumeration); |
257 | 257 | ||
diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c index 442a18ddd41f..34ba440b3c02 100644 --- a/drivers/staging/lustre/lnet/selftest/conctl.c +++ b/drivers/staging/lustre/lnet/selftest/conctl.c | |||
@@ -648,7 +648,7 @@ static int lst_test_add_ioctl(struct lstio_test_args *args) | |||
648 | return -EINVAL; | 648 | return -EINVAL; |
649 | 649 | ||
650 | if (args->lstio_tes_param) { | 650 | if (args->lstio_tes_param) { |
651 | LIBCFS_ALLOC(param, args->lstio_tes_param_len); | 651 | param = kmalloc(args->lstio_tes_param_len, GFP_KERNEL); |
652 | if (!param) | 652 | if (!param) |
653 | goto out; | 653 | goto out; |
654 | if (copy_from_user(param, args->lstio_tes_param, | 654 | 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 | rc = (copy_to_user(args->lstio_tes_retp, &ret, | 678 | rc = (copy_to_user(args->lstio_tes_retp, &ret, |
679 | sizeof(ret))) ? -EFAULT : 0; | 679 | sizeof(ret))) ? -EFAULT : 0; |
680 | out: | 680 | out: |
681 | if (param) | 681 | kfree(param); |
682 | LIBCFS_FREE(param, args->lstio_tes_param_len); | ||
683 | 682 | ||
684 | return rc; | 683 | return rc; |
685 | } | 684 | } |
@@ -702,13 +701,13 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) | |||
702 | if (data->ioc_plen1 > PAGE_SIZE) | 701 | if (data->ioc_plen1 > PAGE_SIZE) |
703 | return -EINVAL; | 702 | return -EINVAL; |
704 | 703 | ||
705 | LIBCFS_ALLOC(buf, data->ioc_plen1); | 704 | buf = kmalloc(data->ioc_plen1, GFP_KERNEL); |
706 | if (!buf) | 705 | if (!buf) |
707 | return -ENOMEM; | 706 | return -ENOMEM; |
708 | 707 | ||
709 | /* copy in parameter */ | 708 | /* copy in parameter */ |
710 | if (copy_from_user(buf, data->ioc_pbuf1, data->ioc_plen1)) { | 709 | if (copy_from_user(buf, data->ioc_pbuf1, data->ioc_plen1)) { |
711 | LIBCFS_FREE(buf, data->ioc_plen1); | 710 | kfree(buf); |
712 | return -EFAULT; | 711 | return -EFAULT; |
713 | } | 712 | } |
714 | 713 | ||
@@ -798,7 +797,7 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) | |||
798 | out: | 797 | out: |
799 | mutex_unlock(&console_session.ses_mutex); | 798 | mutex_unlock(&console_session.ses_mutex); |
800 | 799 | ||
801 | LIBCFS_FREE(buf, data->ioc_plen1); | 800 | kfree(buf); |
802 | 801 | ||
803 | return rc; | 802 | return rc; |
804 | } | 803 | } |