aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4session.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/nfs4session.c')
-rw-r--r--fs/nfs/nfs4session.c86
1 files changed, 60 insertions, 26 deletions
diff --git a/fs/nfs/nfs4session.c b/fs/nfs/nfs4session.c
index 36e21cb29d65..cf883c7ae053 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 */
@@ -44,6 +52,17 @@ static void nfs4_shrink_slot_table(struct nfs4_slot_table *tbl, u32 newsize)
44 } 52 }
45} 53}
46 54
55/**
56 * nfs4_slot_tbl_drain_complete - wake waiters when drain is complete
57 * @tbl - controlling slot table
58 *
59 */
60void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl)
61{
62 if (nfs4_slot_tbl_draining(tbl))
63 complete(&tbl->complete);
64}
65
47/* 66/*
48 * nfs4_free_slot - free a slot and efficiently update slot table. 67 * nfs4_free_slot - free a slot and efficiently update slot table.
49 * 68 *
@@ -76,7 +95,7 @@ void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot)
76 nfs4_slot_tbl_drain_complete(tbl); 95 nfs4_slot_tbl_drain_complete(tbl);
77 } 96 }
78 } 97 }
79 dprintk("%s: slotid %u highest_used_slotid %d\n", __func__, 98 dprintk("%s: slotid %u highest_used_slotid %u\n", __func__,
80 slotid, tbl->highest_used_slotid); 99 slotid, tbl->highest_used_slotid);
81} 100}
82 101
@@ -146,9 +165,9 @@ struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl)
146 ret->generation = tbl->generation; 165 ret->generation = tbl->generation;
147 166
148out: 167out:
149 dprintk("<-- %s used_slots=%04lx highest_used=%d slotid=%d \n", 168 dprintk("<-- %s used_slots=%04lx highest_used=%u slotid=%u\n",
150 __func__, tbl->used_slots[0], tbl->highest_used_slotid, 169 __func__, tbl->used_slots[0], tbl->highest_used_slotid,
151 !IS_ERR(ret) ? ret->slot_nr : -1); 170 !IS_ERR(ret) ? ret->slot_nr : NFS4_NO_SLOT);
152 return ret; 171 return ret;
153} 172}
154 173
@@ -191,7 +210,7 @@ static int nfs4_realloc_slot_table(struct nfs4_slot_table *tbl,
191{ 210{
192 int ret; 211 int ret;
193 212
194 dprintk("--> %s: max_reqs=%u, tbl->max_slots %d\n", __func__, 213 dprintk("--> %s: max_reqs=%u, tbl->max_slots %u\n", __func__,
195 max_reqs, tbl->max_slots); 214 max_reqs, tbl->max_slots);
196 215
197 if (max_reqs > NFS4_MAX_SLOT_TABLE) 216 if (max_reqs > NFS4_MAX_SLOT_TABLE)
@@ -205,18 +224,36 @@ static int nfs4_realloc_slot_table(struct nfs4_slot_table *tbl,
205 nfs4_reset_slot_table(tbl, max_reqs - 1, ivalue); 224 nfs4_reset_slot_table(tbl, max_reqs - 1, ivalue);
206 spin_unlock(&tbl->slot_tbl_lock); 225 spin_unlock(&tbl->slot_tbl_lock);
207 226
208 dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__, 227 dprintk("%s: tbl=%p slots=%p max_slots=%u\n", __func__,
209 tbl, tbl->slots, tbl->max_slots); 228 tbl, tbl->slots, tbl->max_slots);
210out: 229out:
211 dprintk("<-- %s: return %d\n", __func__, ret); 230 dprintk("<-- %s: return %d\n", __func__, ret);
212 return ret; 231 return ret;
213} 232}
214 233
215/* Destroy the slot table */ 234/**
216static void nfs4_destroy_slot_tables(struct nfs4_session *session) 235 * nfs4_release_slot_table - release resources attached to a slot table
236 * @tbl: slot table to shut down
237 *
238 */
239void nfs4_release_slot_table(struct nfs4_slot_table *tbl)
240{
241 nfs4_shrink_slot_table(tbl, 0);
242}
243
244/**
245 * nfs4_setup_slot_table - prepare a stand-alone slot table for use
246 * @tbl: slot table to set up
247 * @max_reqs: maximum number of requests allowed
248 * @queue: name to give RPC wait queue
249 *
250 * Returns zero on success, or a negative errno.
251 */
252int nfs4_setup_slot_table(struct nfs4_slot_table *tbl, unsigned int max_reqs,
253 const char *queue)
217{ 254{
218 nfs4_shrink_slot_table(&session->fc_slot_table, 0); 255 nfs4_init_slot_table(tbl, queue);
219 nfs4_shrink_slot_table(&session->bc_slot_table, 0); 256 return nfs4_realloc_slot_table(tbl, max_reqs, 0);
220} 257}
221 258
222static bool nfs41_assign_slot(struct rpc_task *task, void *pslot) 259static bool nfs41_assign_slot(struct rpc_task *task, void *pslot)
@@ -273,6 +310,8 @@ void nfs41_wake_slot_table(struct nfs4_slot_table *tbl)
273 } 310 }
274} 311}
275 312
313#if defined(CONFIG_NFS_V4_1)
314
276static void nfs41_set_max_slotid_locked(struct nfs4_slot_table *tbl, 315static void nfs41_set_max_slotid_locked(struct nfs4_slot_table *tbl,
277 u32 target_highest_slotid) 316 u32 target_highest_slotid)
278{ 317{
@@ -383,6 +422,12 @@ void nfs41_update_target_slotid(struct nfs4_slot_table *tbl,
383 spin_unlock(&tbl->slot_tbl_lock); 422 spin_unlock(&tbl->slot_tbl_lock);
384} 423}
385 424
425static void nfs4_destroy_session_slot_tables(struct nfs4_session *session)
426{
427 nfs4_release_slot_table(&session->fc_slot_table);
428 nfs4_release_slot_table(&session->bc_slot_table);
429}
430
386/* 431/*
387 * Initialize or reset the forechannel and backchannel tables 432 * Initialize or reset the forechannel and backchannel tables
388 */ 433 */
@@ -405,31 +450,20 @@ int nfs4_setup_session_slot_tables(struct nfs4_session *ses)
405 if (status && tbl->slots == NULL) 450 if (status && tbl->slots == NULL)
406 /* Fore and back channel share a connection so get 451 /* Fore and back channel share a connection so get
407 * both slot tables or neither */ 452 * both slot tables or neither */
408 nfs4_destroy_slot_tables(ses); 453 nfs4_destroy_session_slot_tables(ses);
409 return status; 454 return status;
410} 455}
411 456
412struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp) 457struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
413{ 458{
414 struct nfs4_session *session; 459 struct nfs4_session *session;
415 struct nfs4_slot_table *tbl;
416 460
417 session = kzalloc(sizeof(struct nfs4_session), GFP_NOFS); 461 session = kzalloc(sizeof(struct nfs4_session), GFP_NOFS);
418 if (!session) 462 if (!session)
419 return NULL; 463 return NULL;
420 464
421 tbl = &session->fc_slot_table; 465 nfs4_init_slot_table(&session->fc_slot_table, "ForeChannel Slot table");
422 tbl->highest_used_slotid = NFS4_NO_SLOT; 466 nfs4_init_slot_table(&session->bc_slot_table, "BackChannel Slot table");
423 spin_lock_init(&tbl->slot_tbl_lock);
424 rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, "ForeChannel Slot table");
425 init_completion(&tbl->complete);
426
427 tbl = &session->bc_slot_table;
428 tbl->highest_used_slotid = NFS4_NO_SLOT;
429 spin_lock_init(&tbl->slot_tbl_lock);
430 rpc_init_wait_queue(&tbl->slot_tbl_waitq, "BackChannel Slot table");
431 init_completion(&tbl->complete);
432
433 session->session_state = 1<<NFS4_SESSION_INITING; 467 session->session_state = 1<<NFS4_SESSION_INITING;
434 468
435 session->clp = clp; 469 session->clp = clp;
@@ -441,7 +475,7 @@ void nfs4_destroy_session(struct nfs4_session *session)
441 struct rpc_xprt *xprt; 475 struct rpc_xprt *xprt;
442 struct rpc_cred *cred; 476 struct rpc_cred *cred;
443 477
444 cred = nfs4_get_exchange_id_cred(session->clp); 478 cred = nfs4_get_clid_cred(session->clp);
445 nfs4_proc_destroy_session(session, cred); 479 nfs4_proc_destroy_session(session, cred);
446 if (cred) 480 if (cred)
447 put_rpccred(cred); 481 put_rpccred(cred);
@@ -452,7 +486,7 @@ void nfs4_destroy_session(struct nfs4_session *session)
452 dprintk("%s Destroy backchannel for xprt %p\n", 486 dprintk("%s Destroy backchannel for xprt %p\n",
453 __func__, xprt); 487 __func__, xprt);
454 xprt_destroy_backchannel(xprt, NFS41_BC_MIN_CALLBACKS); 488 xprt_destroy_backchannel(xprt, NFS41_BC_MIN_CALLBACKS);
455 nfs4_destroy_slot_tables(session); 489 nfs4_destroy_session_slot_tables(session);
456 kfree(session); 490 kfree(session);
457} 491}
458 492
@@ -513,4 +547,4 @@ int nfs4_init_ds_session(struct nfs_client *clp, unsigned long lease_time)
513} 547}
514EXPORT_SYMBOL_GPL(nfs4_init_ds_session); 548EXPORT_SYMBOL_GPL(nfs4_init_ds_session);
515 549
516 550#endif /* defined(CONFIG_NFS_V4_1) */