aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2013-08-09 12:48:53 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-09-03 15:26:34 -0400
commit744aa5253010636bb56f062336e9cae3132a46fb (patch)
tree616addca502e8a585bf9ca8fccf764fec347c0c1 /fs
parent9d33059c1b76d77004753799479af6d359d83217 (diff)
NFS: Add global helper to set up a stand-along nfs4_slot_table
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/nfs4session.c38
-rw-r--r--fs/nfs/nfs4session.h2
2 files changed, 27 insertions, 13 deletions
diff --git a/fs/nfs/nfs4session.c b/fs/nfs/nfs4session.c
index 746675b74624..be273c589b03 100644
--- a/fs/nfs/nfs4session.c
+++ b/fs/nfs/nfs4session.c
@@ -23,6 +23,14 @@
23 23
24#define NFSDBG_FACILITY NFSDBG_STATE 24#define NFSDBG_FACILITY NFSDBG_STATE
25 25
26static void nfs4_init_slot_table(struct nfs4_slot_table *tbl, const char *queue)
27{
28 tbl->highest_used_slotid = NFS4_NO_SLOT;
29 spin_lock_init(&tbl->slot_tbl_lock);
30 rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, queue);
31 init_completion(&tbl->complete);
32}
33
26/* 34/*
27 * nfs4_shrink_slot_table - free retired slots from the slot table 35 * nfs4_shrink_slot_table - free retired slots from the slot table
28 */ 36 */
@@ -223,6 +231,21 @@ out:
223 return ret; 231 return ret;
224} 232}
225 233
234/**
235 * nfs4_setup_slot_table - prepare a stand-alone slot table for use
236 * @tbl: slot table to set up
237 * @max_reqs: maximum number of requests allowed
238 * @queue: name to give RPC wait queue
239 *
240 * Returns zero on success, or a negative errno.
241 */
242int nfs4_setup_slot_table(struct nfs4_slot_table *tbl, unsigned int max_reqs,
243 const char *queue)
244{
245 nfs4_init_slot_table(tbl, queue);
246 return nfs4_realloc_slot_table(tbl, max_reqs, 0);
247}
248
226static bool nfs41_assign_slot(struct rpc_task *task, void *pslot) 249static bool nfs41_assign_slot(struct rpc_task *task, void *pslot)
227{ 250{
228 struct nfs4_sequence_args *args = task->tk_msg.rpc_argp; 251 struct nfs4_sequence_args *args = task->tk_msg.rpc_argp;
@@ -425,24 +448,13 @@ int nfs4_setup_session_slot_tables(struct nfs4_session *ses)
425struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp) 448struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
426{ 449{
427 struct nfs4_session *session; 450 struct nfs4_session *session;
428 struct nfs4_slot_table *tbl;
429 451
430 session = kzalloc(sizeof(struct nfs4_session), GFP_NOFS); 452 session = kzalloc(sizeof(struct nfs4_session), GFP_NOFS);
431 if (!session) 453 if (!session)
432 return NULL; 454 return NULL;
433 455
434 tbl = &session->fc_slot_table; 456 nfs4_init_slot_table(&session->fc_slot_table, "ForeChannel Slot table");
435 tbl->highest_used_slotid = NFS4_NO_SLOT; 457 nfs4_init_slot_table(&session->bc_slot_table, "BackChannel Slot table");
436 spin_lock_init(&tbl->slot_tbl_lock);
437 rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, "ForeChannel Slot table");
438 init_completion(&tbl->complete);
439
440 tbl = &session->bc_slot_table;
441 tbl->highest_used_slotid = NFS4_NO_SLOT;
442 spin_lock_init(&tbl->slot_tbl_lock);
443 rpc_init_wait_queue(&tbl->slot_tbl_waitq, "BackChannel Slot table");
444 init_completion(&tbl->complete);
445
446 session->session_state = 1<<NFS4_SESSION_INITING; 458 session->session_state = 1<<NFS4_SESSION_INITING;
447 459
448 session->clp = clp; 460 session->clp = clp;
diff --git a/fs/nfs/nfs4session.h b/fs/nfs/nfs4session.h
index e069cf2d8c5f..f223a7648f9e 100644
--- a/fs/nfs/nfs4session.h
+++ b/fs/nfs/nfs4session.h
@@ -72,6 +72,8 @@ enum nfs4_session_state {
72 NFS4_SESSION_INITING, 72 NFS4_SESSION_INITING,
73}; 73};
74 74
75extern int nfs4_setup_slot_table(struct nfs4_slot_table *tbl,
76 unsigned int max_reqs, const char *queue);
75extern struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl); 77extern struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl);
76extern void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot); 78extern void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot);
77extern void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl); 79extern void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl);