Lines Matching refs:tbl
27 static void nfs4_init_slot_table(struct nfs4_slot_table *tbl, const char *queue) in nfs4_init_slot_table() argument
29 tbl->highest_used_slotid = NFS4_NO_SLOT; in nfs4_init_slot_table()
30 spin_lock_init(&tbl->slot_tbl_lock); in nfs4_init_slot_table()
31 rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, queue); in nfs4_init_slot_table()
32 init_waitqueue_head(&tbl->slot_waitq); in nfs4_init_slot_table()
33 init_completion(&tbl->complete); in nfs4_init_slot_table()
39 static void nfs4_shrink_slot_table(struct nfs4_slot_table *tbl, u32 newsize) in nfs4_shrink_slot_table() argument
42 if (newsize >= tbl->max_slots) in nfs4_shrink_slot_table()
45 p = &tbl->slots; in nfs4_shrink_slot_table()
53 tbl->max_slots--; in nfs4_shrink_slot_table()
62 void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl) in nfs4_slot_tbl_drain_complete() argument
64 if (nfs4_slot_tbl_draining(tbl)) in nfs4_slot_tbl_drain_complete()
65 complete(&tbl->complete); in nfs4_slot_tbl_drain_complete()
83 void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot) in nfs4_free_slot() argument
88 __clear_bit(slotid, tbl->used_slots); in nfs4_free_slot()
91 if (slotid == tbl->highest_used_slotid) { in nfs4_free_slot()
92 u32 new_max = find_last_bit(tbl->used_slots, slotid); in nfs4_free_slot()
94 tbl->highest_used_slotid = new_max; in nfs4_free_slot()
96 tbl->highest_used_slotid = NFS4_NO_SLOT; in nfs4_free_slot()
97 nfs4_slot_tbl_drain_complete(tbl); in nfs4_free_slot()
101 slotid, tbl->highest_used_slotid); in nfs4_free_slot()
104 static struct nfs4_slot *nfs4_new_slot(struct nfs4_slot_table *tbl, in nfs4_new_slot() argument
111 slot->table = tbl; in nfs4_new_slot()
120 static struct nfs4_slot *nfs4_find_or_create_slot(struct nfs4_slot_table *tbl, in nfs4_find_or_create_slot() argument
125 p = &tbl->slots; in nfs4_find_or_create_slot()
128 *p = nfs4_new_slot(tbl, tbl->max_slots, in nfs4_find_or_create_slot()
132 tbl->max_slots++; in nfs4_find_or_create_slot()
142 static void nfs4_lock_slot(struct nfs4_slot_table *tbl, in nfs4_lock_slot() argument
147 __set_bit(slotid, tbl->used_slots); in nfs4_lock_slot()
148 if (slotid > tbl->highest_used_slotid || in nfs4_lock_slot()
149 tbl->highest_used_slotid == NFS4_NO_SLOT) in nfs4_lock_slot()
150 tbl->highest_used_slotid = slotid; in nfs4_lock_slot()
151 slot->generation = tbl->generation; in nfs4_lock_slot()
159 bool nfs4_try_to_lock_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot) in nfs4_try_to_lock_slot() argument
161 if (nfs4_test_locked_slot(tbl, slot->slot_nr)) in nfs4_try_to_lock_slot()
163 nfs4_lock_slot(tbl, slot); in nfs4_try_to_lock_slot()
172 struct nfs4_slot *nfs4_lookup_slot(struct nfs4_slot_table *tbl, u32 slotid) in nfs4_lookup_slot() argument
174 if (slotid <= tbl->max_slotid) in nfs4_lookup_slot()
175 return nfs4_find_or_create_slot(tbl, slotid, 0, GFP_NOWAIT); in nfs4_lookup_slot()
179 static int nfs4_slot_get_seqid(struct nfs4_slot_table *tbl, u32 slotid, in nfs4_slot_get_seqid() argument
181 __must_hold(&tbl->slot_tbl_lock) in nfs4_slot_get_seqid()
186 slot = nfs4_lookup_slot(tbl, slotid); in nfs4_slot_get_seqid()
201 static bool nfs4_slot_seqid_in_use(struct nfs4_slot_table *tbl, in nfs4_slot_seqid_in_use() argument
207 spin_lock(&tbl->slot_tbl_lock); in nfs4_slot_seqid_in_use()
208 if (nfs4_slot_get_seqid(tbl, slotid, &cur_seq) == 0 && in nfs4_slot_seqid_in_use()
209 cur_seq == seq_nr && test_bit(slotid, tbl->used_slots)) in nfs4_slot_seqid_in_use()
211 spin_unlock(&tbl->slot_tbl_lock); in nfs4_slot_seqid_in_use()
222 int nfs4_slot_wait_on_seqid(struct nfs4_slot_table *tbl, in nfs4_slot_wait_on_seqid() argument
226 if (wait_event_timeout(tbl->slot_waitq, in nfs4_slot_wait_on_seqid()
227 !nfs4_slot_seqid_in_use(tbl, slotid, seq_nr), in nfs4_slot_wait_on_seqid()
242 struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl) in nfs4_alloc_slot() argument
248 __func__, tbl->used_slots[0], tbl->highest_used_slotid, in nfs4_alloc_slot()
249 tbl->max_slotid + 1); in nfs4_alloc_slot()
250 slotid = find_first_zero_bit(tbl->used_slots, tbl->max_slotid + 1); in nfs4_alloc_slot()
251 if (slotid <= tbl->max_slotid) { in nfs4_alloc_slot()
252 ret = nfs4_find_or_create_slot(tbl, slotid, 1, GFP_NOWAIT); in nfs4_alloc_slot()
254 nfs4_lock_slot(tbl, ret); in nfs4_alloc_slot()
257 __func__, tbl->used_slots[0], tbl->highest_used_slotid, in nfs4_alloc_slot()
262 static int nfs4_grow_slot_table(struct nfs4_slot_table *tbl, in nfs4_grow_slot_table() argument
265 if (max_reqs <= tbl->max_slots) in nfs4_grow_slot_table()
267 if (!IS_ERR(nfs4_find_or_create_slot(tbl, max_reqs - 1, ivalue, GFP_NOFS))) in nfs4_grow_slot_table()
272 static void nfs4_reset_slot_table(struct nfs4_slot_table *tbl, in nfs4_reset_slot_table() argument
278 nfs4_shrink_slot_table(tbl, server_highest_slotid + 1); in nfs4_reset_slot_table()
279 p = &tbl->slots; in nfs4_reset_slot_table()
286 tbl->highest_used_slotid = NFS4_NO_SLOT; in nfs4_reset_slot_table()
287 tbl->target_highest_slotid = server_highest_slotid; in nfs4_reset_slot_table()
288 tbl->server_highest_slotid = server_highest_slotid; in nfs4_reset_slot_table()
289 tbl->d_target_highest_slotid = 0; in nfs4_reset_slot_table()
290 tbl->d2_target_highest_slotid = 0; in nfs4_reset_slot_table()
291 tbl->max_slotid = server_highest_slotid; in nfs4_reset_slot_table()
297 static int nfs4_realloc_slot_table(struct nfs4_slot_table *tbl, in nfs4_realloc_slot_table() argument
303 max_reqs, tbl->max_slots); in nfs4_realloc_slot_table()
308 ret = nfs4_grow_slot_table(tbl, max_reqs, ivalue); in nfs4_realloc_slot_table()
312 spin_lock(&tbl->slot_tbl_lock); in nfs4_realloc_slot_table()
313 nfs4_reset_slot_table(tbl, max_reqs - 1, ivalue); in nfs4_realloc_slot_table()
314 spin_unlock(&tbl->slot_tbl_lock); in nfs4_realloc_slot_table()
317 tbl, tbl->slots, tbl->max_slots); in nfs4_realloc_slot_table()
326 static void nfs4_release_slot_table(struct nfs4_slot_table *tbl) in nfs4_release_slot_table() argument
328 nfs4_shrink_slot_table(tbl, 0); in nfs4_release_slot_table()
336 void nfs4_shutdown_slot_table(struct nfs4_slot_table *tbl) in nfs4_shutdown_slot_table() argument
338 nfs4_release_slot_table(tbl); in nfs4_shutdown_slot_table()
339 rpc_destroy_wait_queue(&tbl->slot_tbl_waitq); in nfs4_shutdown_slot_table()
350 int nfs4_setup_slot_table(struct nfs4_slot_table *tbl, unsigned int max_reqs, in nfs4_setup_slot_table() argument
353 nfs4_init_slot_table(tbl, queue); in nfs4_setup_slot_table()
354 return nfs4_realloc_slot_table(tbl, max_reqs, 0); in nfs4_setup_slot_table()
362 struct nfs4_slot_table *tbl = slot->table; in nfs41_assign_slot() local
364 if (nfs4_slot_tbl_draining(tbl) && !args->sa_privileged) in nfs41_assign_slot()
366 slot->generation = tbl->generation; in nfs41_assign_slot()
375 static bool __nfs41_wake_and_assign_slot(struct nfs4_slot_table *tbl, in __nfs41_wake_and_assign_slot() argument
378 if (rpc_wake_up_first(&tbl->slot_tbl_waitq, nfs41_assign_slot, slot)) in __nfs41_wake_and_assign_slot()
383 bool nfs41_wake_and_assign_slot(struct nfs4_slot_table *tbl, in nfs41_wake_and_assign_slot() argument
386 if (slot->slot_nr > tbl->max_slotid) in nfs41_wake_and_assign_slot()
388 return __nfs41_wake_and_assign_slot(tbl, slot); in nfs41_wake_and_assign_slot()
391 static bool nfs41_try_wake_next_slot_table_entry(struct nfs4_slot_table *tbl) in nfs41_try_wake_next_slot_table_entry() argument
393 struct nfs4_slot *slot = nfs4_alloc_slot(tbl); in nfs41_try_wake_next_slot_table_entry()
395 bool ret = __nfs41_wake_and_assign_slot(tbl, slot); in nfs41_try_wake_next_slot_table_entry()
398 nfs4_free_slot(tbl, slot); in nfs41_try_wake_next_slot_table_entry()
403 void nfs41_wake_slot_table(struct nfs4_slot_table *tbl) in nfs41_wake_slot_table() argument
406 if (!nfs41_try_wake_next_slot_table_entry(tbl)) in nfs41_wake_slot_table()
413 static void nfs41_set_max_slotid_locked(struct nfs4_slot_table *tbl, in nfs41_set_max_slotid_locked() argument
419 if (max_slotid > tbl->server_highest_slotid) in nfs41_set_max_slotid_locked()
420 max_slotid = tbl->server_highest_slotid; in nfs41_set_max_slotid_locked()
421 if (max_slotid > tbl->target_highest_slotid) in nfs41_set_max_slotid_locked()
422 max_slotid = tbl->target_highest_slotid; in nfs41_set_max_slotid_locked()
423 tbl->max_slotid = max_slotid; in nfs41_set_max_slotid_locked()
424 nfs41_wake_slot_table(tbl); in nfs41_set_max_slotid_locked()
428 static void nfs41_set_target_slotid_locked(struct nfs4_slot_table *tbl, in nfs41_set_target_slotid_locked() argument
431 if (tbl->target_highest_slotid == target_highest_slotid) in nfs41_set_target_slotid_locked()
433 tbl->target_highest_slotid = target_highest_slotid; in nfs41_set_target_slotid_locked()
434 tbl->generation++; in nfs41_set_target_slotid_locked()
437 void nfs41_set_target_slotid(struct nfs4_slot_table *tbl, in nfs41_set_target_slotid() argument
440 spin_lock(&tbl->slot_tbl_lock); in nfs41_set_target_slotid()
441 nfs41_set_target_slotid_locked(tbl, target_highest_slotid); in nfs41_set_target_slotid()
442 tbl->d_target_highest_slotid = 0; in nfs41_set_target_slotid()
443 tbl->d2_target_highest_slotid = 0; in nfs41_set_target_slotid()
444 nfs41_set_max_slotid_locked(tbl, target_highest_slotid); in nfs41_set_target_slotid()
445 spin_unlock(&tbl->slot_tbl_lock); in nfs41_set_target_slotid()
448 static void nfs41_set_server_slotid_locked(struct nfs4_slot_table *tbl, in nfs41_set_server_slotid_locked() argument
451 if (tbl->server_highest_slotid == highest_slotid) in nfs41_set_server_slotid_locked()
453 if (tbl->highest_used_slotid > highest_slotid) in nfs41_set_server_slotid_locked()
456 nfs4_shrink_slot_table(tbl, highest_slotid + 1); in nfs41_set_server_slotid_locked()
457 tbl->server_highest_slotid = highest_slotid; in nfs41_set_server_slotid_locked()
489 static bool nfs41_is_outlier_target_slotid(struct nfs4_slot_table *tbl, in nfs41_is_outlier_target_slotid() argument
496 tbl->target_highest_slotid); in nfs41_is_outlier_target_slotid()
498 tbl->d_target_highest_slotid); in nfs41_is_outlier_target_slotid()
500 if (nfs41_same_sign_or_zero_s32(d_target, tbl->d_target_highest_slotid)) in nfs41_is_outlier_target_slotid()
503 if (nfs41_same_sign_or_zero_s32(d2_target, tbl->d2_target_highest_slotid)) in nfs41_is_outlier_target_slotid()
505 tbl->d_target_highest_slotid = d_target; in nfs41_is_outlier_target_slotid()
506 tbl->d2_target_highest_slotid = d2_target; in nfs41_is_outlier_target_slotid()
510 void nfs41_update_target_slotid(struct nfs4_slot_table *tbl, in nfs41_update_target_slotid() argument
518 spin_lock(&tbl->slot_tbl_lock); in nfs41_update_target_slotid()
519 if (!nfs41_is_outlier_target_slotid(tbl, target_highest_slotid)) in nfs41_update_target_slotid()
520 nfs41_set_target_slotid_locked(tbl, target_highest_slotid); in nfs41_update_target_slotid()
521 if (tbl->generation == slot->generation) in nfs41_update_target_slotid()
522 nfs41_set_server_slotid_locked(tbl, highest_slotid); in nfs41_update_target_slotid()
523 nfs41_set_max_slotid_locked(tbl, target_highest_slotid); in nfs41_update_target_slotid()
524 spin_unlock(&tbl->slot_tbl_lock); in nfs41_update_target_slotid()
538 struct nfs4_slot_table *tbl; in nfs4_setup_session_slot_tables() local
543 tbl = &ses->fc_slot_table; in nfs4_setup_session_slot_tables()
544 tbl->session = ses; in nfs4_setup_session_slot_tables()
545 status = nfs4_realloc_slot_table(tbl, ses->fc_attrs.max_reqs, 1); in nfs4_setup_session_slot_tables()
549 tbl = &ses->bc_slot_table; in nfs4_setup_session_slot_tables()
550 tbl->session = ses; in nfs4_setup_session_slot_tables()
551 status = nfs4_realloc_slot_table(tbl, ses->bc_attrs.max_reqs, 0); in nfs4_setup_session_slot_tables()
552 if (status && tbl->slots == NULL) in nfs4_setup_session_slot_tables()