Commit 033085ff authored by NeilBrown's avatar NeilBrown Committed by Greg Kroah-Hartman

staging: lustre: improve some libcfs_kvzalloc calls.

Using vmalloc with GFP_NOFS is not supported as vmalloc
performs some internal allocations with GFP_KERNEL.

So in cases where the size passed to libcfs_kvzalloc()
is clearly at most 1 page, convert to kzalloc().
In cases where the call clearly doesn't hold any
filesystem locks, convert to GFP_KERNEL.

Unfortunately there are many more that are not easy to fix.
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c23d6d0e
...@@ -1497,7 +1497,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1497,7 +1497,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
if (totalsize >= MDS_MAXREQSIZE / 3) if (totalsize >= MDS_MAXREQSIZE / 3)
return -E2BIG; return -E2BIG;
hur = libcfs_kvzalloc(totalsize, GFP_NOFS); hur = kzalloc(totalsize, GFP_NOFS);
if (!hur) if (!hur)
return -ENOMEM; return -ENOMEM;
......
...@@ -1318,7 +1318,7 @@ static int ll_lov_setea(struct inode *inode, struct file *file, ...@@ -1318,7 +1318,7 @@ static int ll_lov_setea(struct inode *inode, struct file *file,
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
lump = libcfs_kvzalloc(lum_size, GFP_NOFS); lump = kzalloc(lum_size, GFP_NOFS);
if (!lump) if (!lump)
return -ENOMEM; return -ENOMEM;
...@@ -2998,7 +2998,7 @@ static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -2998,7 +2998,7 @@ static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
num_bytes = sizeof(*fiemap) + (extent_count * num_bytes = sizeof(*fiemap) + (extent_count *
sizeof(struct fiemap_extent)); sizeof(struct fiemap_extent));
fiemap = libcfs_kvzalloc(num_bytes, GFP_NOFS); fiemap = kvzalloc(num_bytes, GFP_KERNEL);
if (!fiemap) if (!fiemap)
return -ENOMEM; return -ENOMEM;
......
...@@ -180,7 +180,7 @@ int obd_ioctl_getdata(char **buf, int *len, void __user *arg) ...@@ -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 * obdfilter-survey is an example, which relies on ioctl. So we'd
* better avoid vmalloc on ioctl path. LU-66 * better avoid vmalloc on ioctl path. LU-66
*/ */
*buf = libcfs_kvzalloc(hdr.ioc_len, GFP_NOFS); *buf = libcfs_kvzalloc(hdr.ioc_len, GFP_KERNEL);
if (!*buf) { if (!*buf) {
CERROR("Cannot allocate control buffer of len %d\n", CERROR("Cannot allocate control buffer of len %d\n",
hdr.ioc_len); hdr.ioc_len);
......
...@@ -155,7 +155,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle, ...@@ -155,7 +155,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
LASSERT(!handle->lgh_hdr); LASSERT(!handle->lgh_hdr);
LASSERT(chunk_size >= LLOG_MIN_CHUNK_SIZE); LASSERT(chunk_size >= LLOG_MIN_CHUNK_SIZE);
llh = libcfs_kvzalloc(sizeof(*llh), GFP_NOFS); llh = libcfs_kvzalloc(sizeof(*llh), GFP_KERNEL);
if (!llh) if (!llh)
return -ENOMEM; return -ENOMEM;
handle->lgh_hdr = llh; handle->lgh_hdr = llh;
......
...@@ -185,7 +185,7 @@ int class_handle_init(void) ...@@ -185,7 +185,7 @@ int class_handle_init(void)
LASSERT(!handle_hash); LASSERT(!handle_hash);
handle_hash = libcfs_kvzalloc(sizeof(*bucket) * HANDLE_HASH_SIZE, handle_hash = libcfs_kvzalloc(sizeof(*bucket) * HANDLE_HASH_SIZE,
GFP_NOFS); GFP_KERNEL);
if (!handle_hash) if (!handle_hash)
return -ENOMEM; return -ENOMEM;
......
...@@ -544,10 +544,10 @@ int ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq) ...@@ -544,10 +544,10 @@ int ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
struct lustre_msg *msg; struct lustre_msg *msg;
spin_unlock(&pool->prp_lock); spin_unlock(&pool->prp_lock);
req = ptlrpc_request_cache_alloc(GFP_NOFS); req = ptlrpc_request_cache_alloc(GFP_KERNEL);
if (!req) if (!req)
return i; return i;
msg = libcfs_kvzalloc(size, GFP_NOFS); msg = libcfs_kvzalloc(size, GFP_KERNEL);
if (!msg) { if (!msg) {
ptlrpc_request_cache_free(req); ptlrpc_request_cache_free(req);
return i; return i;
......
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