staging/lustre: clean up and remove libcfs/linux/linux-mem.c
authorPeng Tao <bergwolf@gmail.com>
Mon, 3 Jun 2013 13:58:22 +0000 (21:58 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Jun 2013 18:32:51 +0000 (11:32 -0700)
Those are simple wrappers for numa allocator. We don't need them.

Signed-off-by: Peng Tao <tao.peng@emc.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
drivers/staging/lustre/lnet/lnet/router.c
drivers/staging/lustre/lnet/selftest/rpc.c
drivers/staging/lustre/lustre/include/obd_support.h
drivers/staging/lustre/lustre/libcfs/Makefile
drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c [deleted file]

index 62bf32f8539d70348742b3dfb05281202414cc3e..c4f59075ed42cd14be657a40e612a55a847da8ee 100644 (file)
@@ -161,8 +161,8 @@ do {                                                                            \
 do {                                                                       \
        LIBCFS_ALLOC_PRE((size), (mask));                                   \
        (ptr) = (size) <= LIBCFS_VMALLOC_SIZE ?                             \
-               cfs_cpt_malloc((cptab), (cpt), (size), (mask)) :            \
-               cfs_cpt_vmalloc((cptab), (cpt), (size));                    \
+               kmalloc_node((size), (mask), cfs_cpt_spread_node(cptab, cpt)) :\
+               vmalloc_node(size, cfs_cpt_spread_node(cptab, cpt));        \
        LIBCFS_ALLOC_POST((ptr), (size));                                   \
 } while (0)
 
index f6cb4635ef4ea4fea04b41ed17879605c375190d..042a2bc432be5698133458b643dadc52faa74ac8 100644 (file)
        do { __oldfs = get_fs(); set_fs(get_ds());} while(0)
 #define MMSPACE_CLOSE         set_fs(__oldfs)
 
-
-/*
- * NUMA allocators
- *
- * NB: we will rename these functions in a separate patch:
- * - rename kmalloc to cfs_malloc
- * - rename kmalloc/free_page to cfs_page_alloc/free
- * - rename kmalloc/free_large to cfs_vmalloc/vfree
- */
-extern void *cfs_cpt_malloc(struct cfs_cpt_table *cptab, int cpt,
-                           size_t nr_bytes, unsigned int flags);
-extern void *cfs_cpt_vmalloc(struct cfs_cpt_table *cptab, int cpt,
-                            size_t nr_bytes);
-extern struct page *cfs_page_cpt_alloc(struct cfs_cpt_table *cptab,
-                                     int cpt, unsigned int flags);
-extern void *cfs_mem_cache_cpt_alloc(struct kmem_cache *cachep,
-                                    struct cfs_cpt_table *cptab,
-                                    int cpt, unsigned int flags);
-
 /*
  * Shrinker
  */
index f4b958bbe5a3cd7b5b00b312b69ac81980285c1a..221d37311caea1d650c8a470ac117829c7d24e40 100644 (file)
@@ -1203,8 +1203,9 @@ kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages)
        p->ibp_npages = npages;
 
        for (i = 0; i < npages; i++) {
-               p->ibp_pages[i] = cfs_page_cpt_alloc(lnet_cpt_table(), cpt,
-                                                    __GFP_IO);
+               p->ibp_pages[i] = alloc_pages_node(
+                                   cfs_cpt_spread_node(lnet_cpt_table(), cpt),
+                                   __GFP_IO, 0);
                if (p->ibp_pages[i] == NULL) {
                        CERROR("Can't allocate page %d of %d\n", i, npages);
                        kiblnd_free_pages(p);
index c5ff97aaacc37ba55f5908061e959c17a4cd6a42..a326ce06bc76e21c680ef1e00cad8a295cf765ec 100644 (file)
@@ -1247,8 +1247,9 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
        rb->rb_pool = rbp;
 
        for (i = 0; i < npages; i++) {
-               page = cfs_page_cpt_alloc(lnet_cpt_table(), cpt,
-                                         __GFP_ZERO | GFP_IOFS);
+               page = alloc_pages_node(
+                               cfs_cpt_spread_node(lnet_cpt_table(), cpt),
+                               __GFP_ZERO | GFP_IOFS, 0);
                if (page == NULL) {
                        while (--i >= 0)
                                __free_page(rb->rb_kiov[i].kiov_page);
index 91d83f4b746ee85117ab4f1ee99b64b88ca84ba4..bc1f38b804867f302c01460d7f54cf1534996bbd 100644 (file)
@@ -146,7 +146,8 @@ srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink)
                struct page *pg;
                int         nob;
 
-               pg = cfs_page_cpt_alloc(lnet_cpt_table(), cpt, GFP_IOFS);
+               pg = alloc_pages_node(cfs_cpt_spread_node(lnet_cpt_table(), cpt),
+                                     GFP_IOFS, 0);
                if (pg == NULL) {
                        CERROR("Can't allocate page %d of %d\n", i, bulk_npg);
                        srpc_free_bulk(bk);
index ee70867f1829ee6711312a2cb72ce27dcb35feb1..b5d40afc3599ad1c3050f156956369e80eece47f 100644 (file)
@@ -592,7 +592,7 @@ static inline void obd_pages_sub(int order)
 do {                                                                         \
        (ptr) = (cptab) == NULL ?                                             \
                kmalloc(size, flags) :                                \
-               cfs_cpt_malloc(cptab, cpt, size, flags);                      \
+               kmalloc_node(size, flags, cfs_cpt_spread_node(cptab, cpt));   \
        if (unlikely((ptr) == NULL)) {                                  \
                CERROR("kmalloc of '" #ptr "' (%d bytes) failed at %s:%d\n",  \
                       (int)(size), __FILE__, __LINE__);                      \
@@ -614,14 +614,14 @@ do {                                                                            \
 #define __OBD_MALLOC_VERBOSE(ptr, cptab, cpt, size, flags)                   \
 do {                                                                         \
        (ptr) = (cptab) == NULL ?                                             \
-               kmalloc(size, flags) :                                \
-               cfs_cpt_malloc(cptab, cpt, size, flags);                      \
+               kmalloc(size, flags | __GFP_ZERO) :                           \
+               kmalloc_node(size, flags | __GFP_ZERO,                        \
+                            cfs_cpt_spread_node(cptab, cpt));                \
        if (likely((ptr) != NULL &&                                        \
                   (!HAS_FAIL_ALLOC_FLAG || obd_alloc_fail_rate == 0 ||       \
                    !obd_alloc_fail(ptr, #ptr, "km", size,                  \
                                    __FILE__, __LINE__) ||                  \
                    OBD_FREE_RTN0(ptr)))){                                  \
-               memset(ptr, 0, size);                                    \
                OBD_ALLOC_POST(ptr, size, "kmalloced");                \
        }                                                                    \
 } while (0)
@@ -647,15 +647,14 @@ do {                                                                            \
 # define __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size)                        \
 do {                                                                         \
        (ptr) = cptab == NULL ?                                               \
-               vmalloc(size) :                                       \
-               cfs_cpt_vmalloc(cptab, cpt, size);                            \
+               vzalloc(size) :                                               \
+               vzalloc_node(size, cfs_cpt_spread_node(cptab, cpt));          \
        if (unlikely((ptr) == NULL)) {                                  \
                CERROR("vmalloc of '" #ptr "' (%d bytes) failed\n",        \
                       (int)(size));                                      \
                CERROR(LPU64" total bytes allocated by Lustre, %d by LNET\n", \
                       obd_memory_sum(), atomic_read(&libcfs_kmemory));   \
        } else {                                                              \
-               memset(ptr, 0, size);                                    \
                OBD_ALLOC_POST(ptr, size, "vmalloced");                \
        }                                                                    \
 } while(0)
@@ -756,14 +755,14 @@ do {                                                                            \
 do {                                                                         \
        LASSERT(ergo((type) != GFP_ATOMIC, !in_interrupt()));         \
        (ptr) = (cptab) == NULL ?                                             \
-               kmem_cache_alloc(slab, type) :                        \
-               cfs_mem_cache_cpt_alloc(slab, cptab, cpt, type);              \
+               kmem_cache_alloc(slab, type | __GFP_ZERO) :             \
+               kmem_cache_alloc_node(slab, type | __GFP_ZERO,          \
+                                     cfs_cpt_spread_node(cptab, cpt)); \
        if (likely((ptr) != NULL &&                                        \
                   (!HAS_FAIL_ALLOC_FLAG || obd_alloc_fail_rate == 0 ||       \
                    !obd_alloc_fail(ptr, #ptr, "slab-", size,            \
                                    __FILE__, __LINE__) ||                  \
                    OBD_SLAB_FREE_RTN0(ptr, slab)))) {                  \
-               memset(ptr, 0, size);                                    \
                OBD_ALLOC_POST(ptr, size, "slab-alloced");                  \
        }                                                                    \
 } while(0)
@@ -811,7 +810,7 @@ do {                                                                          \
 do {                                                                         \
        (ptr) = (cptab) == NULL ?                                             \
                alloc_page(gfp_mask) :                                \
-               cfs_page_cpt_alloc(cptab, cpt, gfp_mask);                     \
+               alloc_pages_node(cfs_cpt_spread_node(cptab, cpt), gfp_mask, 0);\
        if (unlikely((ptr) == NULL)) {                                  \
                CERROR("alloc_pages of '" #ptr "' %d page(s) / "LPU64" bytes "\
                       "failed\n", (int)1,                                  \
index 0d2cb620defa5765f4b0daa78b679eb8703339e7..9d4c4b63eac8a99d736c95979cc884e0c5351fe4 100644 (file)
@@ -1,7 +1,7 @@
 obj-$(CONFIG_LUSTRE_FS) += libcfs.o
 
 libcfs-linux-objs := linux-tracefile.o linux-debug.o
-libcfs-linux-objs += linux-prim.o linux-mem.o linux-cpu.o
+libcfs-linux-objs += linux-prim.o linux-cpu.o
 libcfs-linux-objs += linux-tcpip.o
 libcfs-linux-objs += linux-proc.o linux-curproc.o
 libcfs-linux-objs += linux-module.o
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c
deleted file mode 100644 (file)
index 3be3ede..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * 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
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include <linux/mm.h>
-#include <linux/vmalloc.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/libcfs/libcfs.h>
-
-/*
- * NB: we will rename some of above functions in another patch:
- * - rename kmalloc to cfs_malloc
- * - rename kmalloc/free_page to cfs_page_alloc/free
- * - rename kmalloc/free_large to cfs_vmalloc/vfree
- */
-
-void *
-cfs_cpt_malloc(struct cfs_cpt_table *cptab, int cpt,
-              size_t nr_bytes, unsigned int flags)
-{
-       void    *ptr;
-
-       ptr = kmalloc_node(nr_bytes, flags,
-                          cfs_cpt_spread_node(cptab, cpt));
-       if (ptr != NULL && (flags & __GFP_ZERO) != 0)
-               memset(ptr, 0, nr_bytes);
-
-       return ptr;
-}
-EXPORT_SYMBOL(cfs_cpt_malloc);
-
-void *
-cfs_cpt_vmalloc(struct cfs_cpt_table *cptab, int cpt, size_t nr_bytes)
-{
-       return vmalloc_node(nr_bytes, cfs_cpt_spread_node(cptab, cpt));
-}
-EXPORT_SYMBOL(cfs_cpt_vmalloc);
-
-struct page *
-cfs_page_cpt_alloc(struct cfs_cpt_table *cptab, int cpt, unsigned int flags)
-{
-       return alloc_pages_node(cfs_cpt_spread_node(cptab, cpt), flags, 0);
-}
-EXPORT_SYMBOL(cfs_page_cpt_alloc);
-
-void *
-cfs_mem_cache_cpt_alloc(struct kmem_cache *cachep, struct cfs_cpt_table *cptab,
-                       int cpt, unsigned int flags)
-{
-       return kmem_cache_alloc_node(cachep, flags,
-                                    cfs_cpt_spread_node(cptab, cpt));
-}
-EXPORT_SYMBOL(cfs_mem_cache_cpt_alloc);