Commit c90e1718 authored by NeilBrown's avatar NeilBrown Committed by Greg Kroah-Hartman
Browse files

staging: lustre: discard libcfs_kvzalloc and linux-mem.c



The only interesting difference between libcfs_kvzalloc()
and kvzalloc() is that the former appears to work
with GFP_NOFS, which the latter gives a WARN_ON_ONCE()
when that is attempted.

Each libcfs_kvzalloc() should really be analysed
and either converted to a kzalloc() call if the size is never
more than a page, or to use GFP_KERNEL if no locks are held.

If there is ever a case where locks are held and a large allocation
is needed, then some other technique should be used.

It might be nice to not always blindly zero pages too...

For now, just convert libcfs_kvzalloc() calls to
kvzalloc(), and let the warning remind us that there is work to do.

Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 033085ff
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -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.
+0 −1
Original line number Diff line number Diff line
@@ -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))

+0 −44
Original line number Diff line number Diff line
// 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 <green@linuxhacker.ru>
 *
 */
/*
 * This file is part of Lustre, http://www.lustre.org/
 * Lustre is a trademark of Seagate Technology.
 */
#include <linux/slab.h>
#include <linux/vmalloc.h>

#include <linux/libcfs/libcfs.h>

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);
+1 −1
Original line number Diff line number Diff line
@@ -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;
+2 −2
Original line number Diff line number Diff line
@@ -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;
Loading