2007-12-12 15:13:19 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2005-2006 Network Appliance, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* This software is available to you under a choice of one of two
|
|
|
|
* licenses. You may choose to be licensed under the terms of the GNU
|
|
|
|
* General Public License (GPL) Version 2, available from the file
|
|
|
|
* COPYING in the main directory of this source tree, or the BSD-type
|
|
|
|
* license below:
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials provided
|
|
|
|
* with the distribution.
|
|
|
|
*
|
|
|
|
* Neither the name of the Network Appliance, Inc. nor the names of
|
|
|
|
* its contributors may be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written
|
|
|
|
* permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Author: Tom Tucker <tom@opengridcomputing.com>
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2007-12-12 15:13:19 -07:00
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/sysctl.h>
|
2010-10-15 09:49:27 -06:00
|
|
|
#include <linux/workqueue.h>
|
2007-12-12 15:13:19 -07:00
|
|
|
#include <linux/sunrpc/clnt.h>
|
|
|
|
#include <linux/sunrpc/sched.h>
|
|
|
|
#include <linux/sunrpc/svc_rdma.h>
|
2012-02-15 10:30:00 -07:00
|
|
|
#include "xprt_rdma.h"
|
2007-12-12 15:13:19 -07:00
|
|
|
|
|
|
|
#define RPCDBG_FACILITY RPCDBG_SVCXPRT
|
|
|
|
|
|
|
|
/* RPC/RDMA parameters */
|
|
|
|
unsigned int svcrdma_ord = RPCRDMA_ORD;
|
|
|
|
static unsigned int min_ord = 1;
|
|
|
|
static unsigned int max_ord = 4096;
|
|
|
|
unsigned int svcrdma_max_requests = RPCRDMA_MAX_REQUESTS;
|
|
|
|
static unsigned int min_max_requests = 4;
|
|
|
|
static unsigned int max_max_requests = 16384;
|
|
|
|
unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
|
|
|
|
static unsigned int min_max_inline = 4096;
|
|
|
|
static unsigned int max_max_inline = 65536;
|
|
|
|
|
|
|
|
atomic_t rdma_stat_recv;
|
|
|
|
atomic_t rdma_stat_read;
|
|
|
|
atomic_t rdma_stat_write;
|
|
|
|
atomic_t rdma_stat_sq_starve;
|
|
|
|
atomic_t rdma_stat_rq_starve;
|
|
|
|
atomic_t rdma_stat_rq_poll;
|
|
|
|
atomic_t rdma_stat_rq_prod;
|
|
|
|
atomic_t rdma_stat_sq_poll;
|
|
|
|
atomic_t rdma_stat_sq_prod;
|
|
|
|
|
2008-05-28 13:05:54 -06:00
|
|
|
/* Temporary NFS request map and context caches */
|
2008-05-28 12:54:04 -06:00
|
|
|
struct kmem_cache *svc_rdma_map_cachep;
|
2008-05-28 13:05:54 -06:00
|
|
|
struct kmem_cache *svc_rdma_ctxt_cachep;
|
2008-05-28 12:54:04 -06:00
|
|
|
|
2010-10-15 09:49:27 -06:00
|
|
|
struct workqueue_struct *svc_rdma_wq;
|
|
|
|
|
2007-12-12 15:13:19 -07:00
|
|
|
/*
|
|
|
|
* This function implements reading and resetting an atomic_t stat
|
|
|
|
* variable through read/write to a proc file. Any write to the file
|
|
|
|
* resets the associated statistic to zero. Any read returns it's
|
|
|
|
* current value.
|
|
|
|
*/
|
|
|
|
static int read_reset_stat(ctl_table *table, int write,
|
2009-09-23 16:57:19 -06:00
|
|
|
void __user *buffer, size_t *lenp,
|
2007-12-12 15:13:19 -07:00
|
|
|
loff_t *ppos)
|
|
|
|
{
|
|
|
|
atomic_t *stat = (atomic_t *)table->data;
|
|
|
|
|
|
|
|
if (!stat)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (write)
|
|
|
|
atomic_set(stat, 0);
|
|
|
|
else {
|
|
|
|
char str_buf[32];
|
|
|
|
char *data;
|
|
|
|
int len = snprintf(str_buf, 32, "%d\n", atomic_read(stat));
|
|
|
|
if (len >= 32)
|
|
|
|
return -EFAULT;
|
|
|
|
len = strlen(str_buf);
|
|
|
|
if (*ppos > len) {
|
|
|
|
*lenp = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
data = &str_buf[*ppos];
|
|
|
|
len -= *ppos;
|
|
|
|
if (len > *lenp)
|
|
|
|
len = *lenp;
|
|
|
|
if (len && copy_to_user(buffer, str_buf, len))
|
|
|
|
return -EFAULT;
|
|
|
|
*lenp = len;
|
|
|
|
*ppos += len;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ctl_table_header *svcrdma_table_header;
|
|
|
|
static ctl_table svcrdma_parm_table[] = {
|
|
|
|
{
|
|
|
|
.procname = "max_requests",
|
|
|
|
.data = &svcrdma_max_requests,
|
|
|
|
.maxlen = sizeof(unsigned int),
|
|
|
|
.mode = 0644,
|
2009-11-16 04:11:48 -07:00
|
|
|
.proc_handler = proc_dointvec_minmax,
|
2007-12-12 15:13:19 -07:00
|
|
|
.extra1 = &min_max_requests,
|
|
|
|
.extra2 = &max_max_requests
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "max_req_size",
|
|
|
|
.data = &svcrdma_max_req_size,
|
|
|
|
.maxlen = sizeof(unsigned int),
|
|
|
|
.mode = 0644,
|
2009-11-16 04:11:48 -07:00
|
|
|
.proc_handler = proc_dointvec_minmax,
|
2007-12-12 15:13:19 -07:00
|
|
|
.extra1 = &min_max_inline,
|
|
|
|
.extra2 = &max_max_inline
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "max_outbound_read_requests",
|
|
|
|
.data = &svcrdma_ord,
|
|
|
|
.maxlen = sizeof(unsigned int),
|
|
|
|
.mode = 0644,
|
2009-11-16 04:11:48 -07:00
|
|
|
.proc_handler = proc_dointvec_minmax,
|
2007-12-12 15:13:19 -07:00
|
|
|
.extra1 = &min_ord,
|
|
|
|
.extra2 = &max_ord,
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_read",
|
|
|
|
.data = &rdma_stat_read,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 04:11:48 -07:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-12 15:13:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_recv",
|
|
|
|
.data = &rdma_stat_recv,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 04:11:48 -07:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-12 15:13:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_write",
|
|
|
|
.data = &rdma_stat_write,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 04:11:48 -07:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-12 15:13:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_sq_starve",
|
|
|
|
.data = &rdma_stat_sq_starve,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 04:11:48 -07:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-12 15:13:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_rq_starve",
|
|
|
|
.data = &rdma_stat_rq_starve,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 04:11:48 -07:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-12 15:13:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_rq_poll",
|
|
|
|
.data = &rdma_stat_rq_poll,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 04:11:48 -07:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-12 15:13:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_rq_prod",
|
|
|
|
.data = &rdma_stat_rq_prod,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 04:11:48 -07:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-12 15:13:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_sq_poll",
|
|
|
|
.data = &rdma_stat_sq_poll,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 04:11:48 -07:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-12 15:13:19 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_sq_prod",
|
|
|
|
.data = &rdma_stat_sq_prod,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 04:11:48 -07:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-12 15:13:19 -07:00
|
|
|
},
|
2009-11-05 14:32:03 -07:00
|
|
|
{ },
|
2007-12-12 15:13:19 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static ctl_table svcrdma_table[] = {
|
|
|
|
{
|
|
|
|
.procname = "svc_rdma",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = svcrdma_parm_table
|
|
|
|
},
|
2009-11-05 14:32:03 -07:00
|
|
|
{ },
|
2007-12-12 15:13:19 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static ctl_table svcrdma_root_table[] = {
|
|
|
|
{
|
|
|
|
.procname = "sunrpc",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = svcrdma_table
|
|
|
|
},
|
2009-11-05 14:32:03 -07:00
|
|
|
{ },
|
2007-12-12 15:13:19 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
void svc_rdma_cleanup(void)
|
|
|
|
{
|
|
|
|
dprintk("SVCRDMA Module Removed, deregister RPC RDMA transport\n");
|
2010-10-15 09:49:27 -06:00
|
|
|
destroy_workqueue(svc_rdma_wq);
|
2007-12-12 15:13:19 -07:00
|
|
|
if (svcrdma_table_header) {
|
|
|
|
unregister_sysctl_table(svcrdma_table_header);
|
|
|
|
svcrdma_table_header = NULL;
|
|
|
|
}
|
|
|
|
svc_unreg_xprt_class(&svc_rdma_class);
|
2008-05-28 12:54:04 -06:00
|
|
|
kmem_cache_destroy(svc_rdma_map_cachep);
|
2008-05-28 13:05:54 -06:00
|
|
|
kmem_cache_destroy(svc_rdma_ctxt_cachep);
|
2007-12-12 15:13:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int svc_rdma_init(void)
|
|
|
|
{
|
|
|
|
dprintk("SVCRDMA Module Init, register RPC RDMA transport\n");
|
|
|
|
dprintk("\tsvcrdma_ord : %d\n", svcrdma_ord);
|
|
|
|
dprintk("\tmax_requests : %d\n", svcrdma_max_requests);
|
|
|
|
dprintk("\tsq_depth : %d\n",
|
|
|
|
svcrdma_max_requests * RPCRDMA_SQ_DEPTH_MULT);
|
|
|
|
dprintk("\tmax_inline : %d\n", svcrdma_max_req_size);
|
2010-10-15 09:49:27 -06:00
|
|
|
|
|
|
|
svc_rdma_wq = alloc_workqueue("svc_rdma", 0, 0);
|
|
|
|
if (!svc_rdma_wq)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2007-12-12 15:13:19 -07:00
|
|
|
if (!svcrdma_table_header)
|
|
|
|
svcrdma_table_header =
|
|
|
|
register_sysctl_table(svcrdma_root_table);
|
|
|
|
|
2008-05-28 12:54:04 -06:00
|
|
|
/* Create the temporary map cache */
|
|
|
|
svc_rdma_map_cachep = kmem_cache_create("svc_rdma_map_cache",
|
|
|
|
sizeof(struct svc_rdma_req_map),
|
|
|
|
0,
|
|
|
|
SLAB_HWCACHE_ALIGN,
|
|
|
|
NULL);
|
|
|
|
if (!svc_rdma_map_cachep) {
|
|
|
|
printk(KERN_INFO "Could not allocate map cache.\n");
|
2008-05-28 13:05:54 -06:00
|
|
|
goto err0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the temporary context cache */
|
|
|
|
svc_rdma_ctxt_cachep =
|
|
|
|
kmem_cache_create("svc_rdma_ctxt_cache",
|
|
|
|
sizeof(struct svc_rdma_op_ctxt),
|
|
|
|
0,
|
|
|
|
SLAB_HWCACHE_ALIGN,
|
|
|
|
NULL);
|
|
|
|
if (!svc_rdma_ctxt_cachep) {
|
|
|
|
printk(KERN_INFO "Could not allocate WR ctxt cache.\n");
|
|
|
|
goto err1;
|
2008-05-28 12:54:04 -06:00
|
|
|
}
|
|
|
|
|
2007-12-12 15:13:19 -07:00
|
|
|
/* Register RDMA with the SVC transport switch */
|
|
|
|
svc_reg_xprt_class(&svc_rdma_class);
|
|
|
|
return 0;
|
2008-05-28 13:05:54 -06:00
|
|
|
err1:
|
|
|
|
kmem_cache_destroy(svc_rdma_map_cachep);
|
|
|
|
err0:
|
2008-05-28 12:54:04 -06:00
|
|
|
unregister_sysctl_table(svcrdma_table_header);
|
2010-10-15 09:49:27 -06:00
|
|
|
destroy_workqueue(svc_rdma_wq);
|
2008-05-28 12:54:04 -06:00
|
|
|
return -ENOMEM;
|
2007-12-12 15:13:19 -07:00
|
|
|
}
|
|
|
|
MODULE_AUTHOR("Tom Tucker <tom@opengridcomputing.com>");
|
|
|
|
MODULE_DESCRIPTION("SVC RDMA Transport");
|
|
|
|
MODULE_LICENSE("Dual BSD/GPL");
|
|
|
|
module_init(svc_rdma_init);
|
|
|
|
module_exit(svc_rdma_cleanup);
|