summaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c
diff options
context:
space:
mode:
authorJames Simmons <jsimmons@infradead.org>2016-03-08 17:35:26 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-03-10 17:48:53 -0800
commit71bf3883ae5723f7895226c4b5fafa452c0cd00f (patch)
tree6b142b83bc4f20ec50f4b5858b508bb2a9729835 /drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c
parent708a24c18979af6a55fc3d9a397910af0d47872a (diff)
downloadop-kernel-dev-71bf3883ae5723f7895226c4b5fafa452c0cd00f.zip
op-kernel-dev-71bf3883ae5723f7895226c4b5fafa452c0cd00f.tar.gz
staging: lustre: move libcfs to lnet layer
The lustre file system has a layered architecture with libcfs as the lowest layer and LNet layered on top. Then on top of LNet we run the lustre client. This patch moves the libcfs module code out of lustre into the lnet tree. This fits into the long term goal of eventually merging libcfs into LNet. Signed-off-by: James Simmons <jsimmons@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c')
-rw-r--r--drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c
new file mode 100644
index 0000000..86f32ff
--- /dev/null
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c
@@ -0,0 +1,59 @@
+/*
+ * 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.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ */
+/*
+ * 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 "../../../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);
+
+void *libcfs_kvzalloc_cpt(struct cfs_cpt_table *cptab, int cpt, size_t size,
+ gfp_t flags)
+{
+ void *ret;
+
+ ret = kzalloc_node(size, flags | __GFP_NOWARN,
+ cfs_cpt_spread_node(cptab, cpt));
+ if (!ret) {
+ WARN_ON(!(flags & (__GFP_FS | __GFP_HIGH)));
+ ret = vmalloc_node(size, cfs_cpt_spread_node(cptab, cpt));
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(libcfs_kvzalloc_cpt);
OpenPOWER on IntegriCloud