diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 03920576302149b978ef729fb3c9ec6220749919..392793582956c88c262349887468ecebc0539b08 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -112,8 +112,6 @@ static inline void *__container_of(void *ptr, unsigned long shift) #define _LIBCFS_H -void *libcfs_kvzalloc(size_t size, gfp_t flags); - extern struct miscdevice libcfs_dev; /** * The path of debug log dump upcall script. diff --git a/drivers/staging/lustre/lnet/libcfs/Makefile b/drivers/staging/lustre/lnet/libcfs/Makefile index a51a8b0b9921c1393d878455515ca6e81add85e2..b7dc7ac11cc5312fd822ae17b6c60ffbc1d39ec1 100644 --- a/drivers/staging/lustre/lnet/libcfs/Makefile +++ b/drivers/staging/lustre/lnet/libcfs/Makefile @@ -9,7 +9,6 @@ libcfs-linux-objs += linux-cpu.o libcfs-linux-objs += linux-module.o libcfs-linux-objs += linux-crypto.o libcfs-linux-objs += linux-crypto-adler.o -libcfs-linux-objs += linux-mem.o libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs)) diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c deleted file mode 100644 index f2c001bac30370cc54c96919e1dfdfd067520dd4..0000000000000000000000000000000000000000 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c +++ /dev/null @@ -1,44 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - */ -/* - * This file creates a memory allocation primitive for Lustre, that - * allows to fallback to vmalloc allocations should regular kernel allocations - * fail due to size or system memory fragmentation. - * - * Author: Oleg Drokin - * - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Seagate Technology. - */ -#include -#include - -#include - -void *libcfs_kvzalloc(size_t size, gfp_t flags) -{ - void *ret; - - ret = kzalloc(size, flags | __GFP_NOWARN); - if (!ret) - ret = __vmalloc(size, flags | __GFP_ZERO, PAGE_KERNEL); - return ret; -} -EXPORT_SYMBOL(libcfs_kvzalloc); diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 002a56793e89ba8acaadca76390401689ab800b7..ca5faea13b7e599e254c452bcfd7a88dc2f357c0 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -3361,7 +3361,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) goto out; } - lvbdata = libcfs_kvzalloc(lmmsize, GFP_NOFS); + lvbdata = kvzalloc(lmmsize, GFP_NOFS); if (!lvbdata) { rc = -ENOMEM; goto out; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index c2c57f65431e92c2786ad7837acf48350e8ebd87..179651531862fb2bf6fe401c46dfc2ab48dcdcb4 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1035,7 +1035,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, reqlen = offsetof(typeof(*hur), hur_user_item[nr]) + hur->hur_request.hr_data_len; - req = libcfs_kvzalloc(reqlen, GFP_NOFS); + req = kvzalloc(reqlen, GFP_NOFS); if (!req) return -ENOMEM; @@ -2733,7 +2733,7 @@ static int lmv_unpackmd(struct obd_export *exp, struct lmv_stripe_md **lsmp, lsm_size = lmv_stripe_md_size(0); if (!lsm) { - lsm = libcfs_kvzalloc(lsm_size, GFP_NOFS); + lsm = kvzalloc(lsm_size, GFP_NOFS); if (!lsm) return -ENOMEM; allocated = true; diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index d563dd73343acdd8571def4eee08600717f0df2a..c56a971745e8d76c6421817ddcbd391fc4724fc7 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -89,7 +89,7 @@ struct lov_stripe_md *lsm_alloc_plain(u16 stripe_count) oinfo_ptrs_size = sizeof(struct lov_oinfo *) * stripe_count; lsm_size = sizeof(*lsm) + oinfo_ptrs_size; - lsm = libcfs_kvzalloc(lsm_size, GFP_NOFS); + lsm = kvzalloc(lsm_size, GFP_NOFS); if (!lsm) return NULL; diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index c5f5d1b106dc01ae191e13bccbeef76f83d0b300..c0dbf6cd53b406c818bf99add302cdcc6958a286 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -243,7 +243,7 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio, * when writing a page. -jay */ lio->lis_subs = - libcfs_kvzalloc(lsm->lsm_stripe_count * + kvzalloc(lsm->lsm_stripe_count * sizeof(lio->lis_subs[0]), GFP_NOFS); if (lio->lis_subs) { diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index 2fcdeb707ff90e7cae28c97df831f3cf0ebb42ab..b0292100bf2637e30e1b341d47e1db93b793e3a1 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -145,7 +145,7 @@ static struct lov_lock *lov_lock_sub_init(const struct lu_env *env, nr++; } LASSERT(nr > 0); - lovlck = libcfs_kvzalloc(offsetof(struct lov_lock, lls_sub[nr]), + lovlck = kvzalloc(offsetof(struct lov_lock, lls_sub[nr]), GFP_NOFS); if (!lovlck) return ERR_PTR(-ENOMEM); diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index 86cd4f9fbd0c4a29a7edc5529df3cc819499fa62..16cf9d584bbc58a1c5dc11ce4a4a6d65be12991e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -242,7 +242,7 @@ static int lov_init_raid0(const struct lu_env *env, struct lov_device *dev, r0->lo_nr = lsm->lsm_stripe_count; LASSERT(r0->lo_nr <= lov_targets_nr(dev)); - r0->lo_sub = libcfs_kvzalloc(r0->lo_nr * sizeof(r0->lo_sub[0]), + r0->lo_sub = kvzalloc(r0->lo_nr * sizeof(r0->lo_sub[0]), GFP_NOFS); if (r0->lo_sub) { int psz = 0; @@ -1375,7 +1375,7 @@ static int lov_object_fiemap(const struct lu_env *env, struct cl_object *obj, if (fiemap_count_to_size(fiemap->fm_extent_count) < buffer_size) buffer_size = fiemap_count_to_size(fiemap->fm_extent_count); - fm_local = libcfs_kvzalloc(buffer_size, GFP_NOFS); + fm_local = kvzalloc(buffer_size, GFP_NOFS); if (!fm_local) { rc = -ENOMEM; goto out; diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index e5b11c4085a93b5b4832cac929f37e3035db9aa4..b1060d02a164a83405f9a22207433a224246f38f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -333,7 +333,7 @@ int lov_getstripe(struct lov_object *obj, struct lov_stripe_md *lsm, lmmk_size = lov_mds_md_size(stripe_count, lsm->lsm_magic); - lmmk = libcfs_kvzalloc(lmmk_size, GFP_NOFS); + lmmk = kvzalloc(lmmk_size, GFP_NOFS); if (!lmmk) { rc = -ENOMEM; goto out; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 3114907ac5fff3391ece423c2c66295aff7355e7..695ef44532cfa5d453fb3358509079931c032723 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -660,7 +660,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, LDLM_DEBUG(lock, "layout lock returned by: %s, lvb_len: %d", ldlm_it2str(it->it_op), lvb_len); - lmm = libcfs_kvzalloc(lvb_len, GFP_NOFS); + lmm = kvzalloc(lvb_len, GFP_NOFS); if (!lmm) { LDLM_LOCK_PUT(lock); return -ENOMEM; diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index f8967fd4436391eab83eed97b27935f26a3cd6e1..7bceee7f121e68744910a3144f4fe88d712f54fe 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -180,7 +180,7 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg) * obdfilter-survey is an example, which relies on ioctl. So we'd * better avoid vmalloc on ioctl path. LU-66 */ - *buf = libcfs_kvzalloc(hdr.ioc_len, GFP_KERNEL); + *buf = kvzalloc(hdr.ioc_len, GFP_KERNEL); if (!*buf) { CERROR("Cannot allocate control buffer of len %d\n", hdr.ioc_len); diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index ed310696a95da676da84d79fc7dbbc40700a84df..693e1129f1f98f61e2812f4e61b78ef44022f8e0 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -155,7 +155,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle, LASSERT(!handle->lgh_hdr); LASSERT(chunk_size >= LLOG_MIN_CHUNK_SIZE); - llh = libcfs_kvzalloc(sizeof(*llh), GFP_KERNEL); + llh = kvzalloc(sizeof(*llh), GFP_KERNEL); if (!llh) return -ENOMEM; handle->lgh_hdr = llh; @@ -240,7 +240,7 @@ static int llog_process_thread(void *arg) /* expect chunk_size to be power of two */ LASSERT(is_power_of_2(chunk_size)); - buf = libcfs_kvzalloc(chunk_size, GFP_NOFS); + buf = kvzalloc(chunk_size, GFP_NOFS); if (!buf) { lpi->lpi_rc = -ENOMEM; return 0; diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 9a6377502ae4521bef9f545cd4d6780139a47e2e..f53b1a3c342e16537382e39db095c29d9a29bc37 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -184,7 +184,7 @@ int class_handle_init(void) LASSERT(!handle_hash); - handle_hash = libcfs_kvzalloc(sizeof(*bucket) * HANDLE_HASH_SIZE, + handle_hash = kvzalloc(sizeof(*bucket) * HANDLE_HASH_SIZE, GFP_KERNEL); if (!handle_hash) return -ENOMEM; diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 781462621d92c359abc2363d3eb293eb50c55507..d4c641d2480c1517e6f4541384f712a8fd2bc1fa 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -547,7 +547,7 @@ int ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq) req = ptlrpc_request_cache_alloc(GFP_KERNEL); if (!req) return i; - msg = libcfs_kvzalloc(size, GFP_KERNEL); + msg = kvzalloc(size, GFP_KERNEL); if (!msg) { ptlrpc_request_cache_free(req); return i; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 90e3b302210696aebc2557f951639c486952cd44..f152ba1af0fc7a272c037b4ce49008b36e0c88c7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -442,7 +442,7 @@ int sptlrpc_req_ctx_switch(struct ptlrpc_request *req, /* save request message */ reqmsg_size = req->rq_reqlen; if (reqmsg_size != 0) { - reqmsg = libcfs_kvzalloc(reqmsg_size, GFP_NOFS); + reqmsg = kvzalloc(reqmsg_size, GFP_NOFS); if (!reqmsg) return -ENOMEM; memcpy(reqmsg, req->rq_reqmsg, reqmsg_size); @@ -1089,7 +1089,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, early_size = req->rq_nob_received; early_bufsz = size_roundup_power2(early_size); - early_buf = libcfs_kvzalloc(early_bufsz, GFP_NOFS); + early_buf = kvzalloc(early_bufsz, GFP_NOFS); if (!early_buf) { rc = -ENOMEM; goto err_req; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 134ee727e8b72dfb4e9b67b3e75dab9e21854660..2184022ed724dd68dec60fbd1efaeeabfb496c81 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -375,7 +375,7 @@ static inline void enc_pools_alloc(void) { LASSERT(page_pools.epp_max_pools); page_pools.epp_pools = - libcfs_kvzalloc(page_pools.epp_max_pools * + kvzalloc(page_pools.epp_max_pools * sizeof(*page_pools.epp_pools), GFP_NOFS); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c index 80cea0b24693bb02f316ee590486ca0ff5302cf7..ecc387d1b9b4e789525d6423bac1de5b05dd7bed 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c @@ -158,7 +158,7 @@ int null_alloc_reqbuf(struct ptlrpc_sec *sec, int alloc_size = size_roundup_power2(msgsize); LASSERT(!req->rq_pool); - req->rq_reqbuf = libcfs_kvzalloc(alloc_size, GFP_NOFS); + req->rq_reqbuf = kvzalloc(alloc_size, GFP_NOFS); if (!req->rq_reqbuf) return -ENOMEM; @@ -201,7 +201,7 @@ int null_alloc_repbuf(struct ptlrpc_sec *sec, msgsize = size_roundup_power2(msgsize); - req->rq_repbuf = libcfs_kvzalloc(msgsize, GFP_NOFS); + req->rq_repbuf = kvzalloc(msgsize, GFP_NOFS); if (!req->rq_repbuf) return -ENOMEM; @@ -246,7 +246,7 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, if (req->rq_reqbuf_len < newmsg_size) { alloc_size = size_roundup_power2(newmsg_size); - newbuf = libcfs_kvzalloc(alloc_size, GFP_NOFS); + newbuf = kvzalloc(alloc_size, GFP_NOFS); if (!newbuf) return -ENOMEM; @@ -317,7 +317,7 @@ int null_alloc_rs(struct ptlrpc_request *req, int msgsize) /* pre-allocated */ LASSERT(rs->rs_size >= rs_size); } else { - rs = libcfs_kvzalloc(rs_size, GFP_NOFS); + rs = kvzalloc(rs_size, GFP_NOFS); if (!rs) return -ENOMEM; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index 44e34056515beb9d5574f86a4a9207a5718ba8ac..ec3d9af76b17a89befff4a37d3c54f1978b1eba8 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -562,7 +562,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec, LASSERT(!req->rq_pool); alloc_len = size_roundup_power2(alloc_len); - req->rq_reqbuf = libcfs_kvzalloc(alloc_len, GFP_NOFS); + req->rq_reqbuf = kvzalloc(alloc_len, GFP_NOFS); if (!req->rq_reqbuf) return -ENOMEM; @@ -620,7 +620,7 @@ int plain_alloc_repbuf(struct ptlrpc_sec *sec, alloc_len = size_roundup_power2(alloc_len); - req->rq_repbuf = libcfs_kvzalloc(alloc_len, GFP_NOFS); + req->rq_repbuf = kvzalloc(alloc_len, GFP_NOFS); if (!req->rq_repbuf) return -ENOMEM; @@ -671,7 +671,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, if (req->rq_reqbuf_len < newbuf_size) { newbuf_size = size_roundup_power2(newbuf_size); - newbuf = libcfs_kvzalloc(newbuf_size, GFP_NOFS); + newbuf = kvzalloc(newbuf_size, GFP_NOFS); if (!newbuf) return -ENOMEM; @@ -808,7 +808,7 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) /* pre-allocated */ LASSERT(rs->rs_size >= rs_size); } else { - rs = libcfs_kvzalloc(rs_size, GFP_NOFS); + rs = kvzalloc(rs_size, GFP_NOFS); if (!rs) return -ENOMEM; diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 57e41e2cd30ae701fe6b5860750ba180b3d442db..79d9f386002216c3b804c26570ffc7008c99c9d9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -1068,7 +1068,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) reqcopy = ptlrpc_request_cache_alloc(GFP_NOFS); if (!reqcopy) return -ENOMEM; - reqmsg = libcfs_kvzalloc(req->rq_reqlen, GFP_NOFS); + reqmsg = kvzalloc(req->rq_reqlen, GFP_NOFS); if (!reqmsg) { rc = -ENOMEM; goto out_free; @@ -2077,7 +2077,7 @@ static int ptlrpc_main(void *arg) } /* Alloc reply state structure for this one */ - rs = libcfs_kvzalloc(svc->srv_max_reply_size, GFP_NOFS); + rs = kvzalloc(svc->srv_max_reply_size, GFP_NOFS); if (!rs) { rc = -ENOMEM; goto out_srv_fini;