Lines Matching refs:tbl
26 static void nfs4_init_slot_table(struct nfs4_slot_table *tbl, const char *queue) in nfs4_init_slot_table() argument
28 tbl->highest_used_slotid = NFS4_NO_SLOT; in nfs4_init_slot_table()
29 spin_lock_init(&tbl->slot_tbl_lock); in nfs4_init_slot_table()
30 rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, queue); in nfs4_init_slot_table()
31 init_completion(&tbl->complete); in nfs4_init_slot_table()
37 static void nfs4_shrink_slot_table(struct nfs4_slot_table *tbl, u32 newsize) in nfs4_shrink_slot_table() argument
40 if (newsize >= tbl->max_slots) in nfs4_shrink_slot_table()
43 p = &tbl->slots; in nfs4_shrink_slot_table()
51 tbl->max_slots--; in nfs4_shrink_slot_table()
60 void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl) in nfs4_slot_tbl_drain_complete() argument
62 if (nfs4_slot_tbl_draining(tbl)) in nfs4_slot_tbl_drain_complete()
63 complete(&tbl->complete); in nfs4_slot_tbl_drain_complete()
81 void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot) in nfs4_free_slot() argument
86 __clear_bit(slotid, tbl->used_slots); in nfs4_free_slot()
89 if (slotid == tbl->highest_used_slotid) { in nfs4_free_slot()
90 u32 new_max = find_last_bit(tbl->used_slots, slotid); in nfs4_free_slot()
92 tbl->highest_used_slotid = new_max; in nfs4_free_slot()
94 tbl->highest_used_slotid = NFS4_NO_SLOT; in nfs4_free_slot()
95 nfs4_slot_tbl_drain_complete(tbl); in nfs4_free_slot()
99 slotid, tbl->highest_used_slotid); in nfs4_free_slot()
102 static struct nfs4_slot *nfs4_new_slot(struct nfs4_slot_table *tbl, in nfs4_new_slot() argument
109 slot->table = tbl; in nfs4_new_slot()
116 static struct nfs4_slot *nfs4_find_or_create_slot(struct nfs4_slot_table *tbl, in nfs4_find_or_create_slot() argument
121 p = &tbl->slots; in nfs4_find_or_create_slot()
124 *p = nfs4_new_slot(tbl, tbl->max_slots, in nfs4_find_or_create_slot()
128 tbl->max_slots++; in nfs4_find_or_create_slot()
147 struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl) in nfs4_alloc_slot() argument
153 __func__, tbl->used_slots[0], tbl->highest_used_slotid, in nfs4_alloc_slot()
154 tbl->max_slotid + 1); in nfs4_alloc_slot()
155 slotid = find_first_zero_bit(tbl->used_slots, tbl->max_slotid + 1); in nfs4_alloc_slot()
156 if (slotid > tbl->max_slotid) in nfs4_alloc_slot()
158 ret = nfs4_find_or_create_slot(tbl, slotid, 1, GFP_NOWAIT); in nfs4_alloc_slot()
161 __set_bit(slotid, tbl->used_slots); in nfs4_alloc_slot()
162 if (slotid > tbl->highest_used_slotid || in nfs4_alloc_slot()
163 tbl->highest_used_slotid == NFS4_NO_SLOT) in nfs4_alloc_slot()
164 tbl->highest_used_slotid = slotid; in nfs4_alloc_slot()
165 ret->generation = tbl->generation; in nfs4_alloc_slot()
169 __func__, tbl->used_slots[0], tbl->highest_used_slotid, in nfs4_alloc_slot()
174 static int nfs4_grow_slot_table(struct nfs4_slot_table *tbl, in nfs4_grow_slot_table() argument
177 if (max_reqs <= tbl->max_slots) in nfs4_grow_slot_table()
179 if (!IS_ERR(nfs4_find_or_create_slot(tbl, max_reqs - 1, ivalue, GFP_NOFS))) in nfs4_grow_slot_table()
184 static void nfs4_reset_slot_table(struct nfs4_slot_table *tbl, in nfs4_reset_slot_table() argument
190 nfs4_shrink_slot_table(tbl, server_highest_slotid + 1); in nfs4_reset_slot_table()
191 p = &tbl->slots; in nfs4_reset_slot_table()
197 tbl->highest_used_slotid = NFS4_NO_SLOT; in nfs4_reset_slot_table()
198 tbl->target_highest_slotid = server_highest_slotid; in nfs4_reset_slot_table()
199 tbl->server_highest_slotid = server_highest_slotid; in nfs4_reset_slot_table()
200 tbl->d_target_highest_slotid = 0; in nfs4_reset_slot_table()
201 tbl->d2_target_highest_slotid = 0; in nfs4_reset_slot_table()
202 tbl->max_slotid = server_highest_slotid; in nfs4_reset_slot_table()
208 static int nfs4_realloc_slot_table(struct nfs4_slot_table *tbl, in nfs4_realloc_slot_table() argument
214 max_reqs, tbl->max_slots); in nfs4_realloc_slot_table()
219 ret = nfs4_grow_slot_table(tbl, max_reqs, ivalue); in nfs4_realloc_slot_table()
223 spin_lock(&tbl->slot_tbl_lock); in nfs4_realloc_slot_table()
224 nfs4_reset_slot_table(tbl, max_reqs - 1, ivalue); in nfs4_realloc_slot_table()
225 spin_unlock(&tbl->slot_tbl_lock); in nfs4_realloc_slot_table()
228 tbl, tbl->slots, tbl->max_slots); in nfs4_realloc_slot_table()
237 static void nfs4_release_slot_table(struct nfs4_slot_table *tbl) in nfs4_release_slot_table() argument
239 nfs4_shrink_slot_table(tbl, 0); in nfs4_release_slot_table()
247 void nfs4_shutdown_slot_table(struct nfs4_slot_table *tbl) in nfs4_shutdown_slot_table() argument
249 nfs4_release_slot_table(tbl); in nfs4_shutdown_slot_table()
250 rpc_destroy_wait_queue(&tbl->slot_tbl_waitq); in nfs4_shutdown_slot_table()
261 int nfs4_setup_slot_table(struct nfs4_slot_table *tbl, unsigned int max_reqs, in nfs4_setup_slot_table() argument
264 nfs4_init_slot_table(tbl, queue); in nfs4_setup_slot_table()
265 return nfs4_realloc_slot_table(tbl, max_reqs, 0); in nfs4_setup_slot_table()
273 struct nfs4_slot_table *tbl = slot->table; in nfs41_assign_slot() local
275 if (nfs4_slot_tbl_draining(tbl) && !args->sa_privileged) in nfs41_assign_slot()
277 slot->generation = tbl->generation; in nfs41_assign_slot()
286 static bool __nfs41_wake_and_assign_slot(struct nfs4_slot_table *tbl, in __nfs41_wake_and_assign_slot() argument
289 if (rpc_wake_up_first(&tbl->slot_tbl_waitq, nfs41_assign_slot, slot)) in __nfs41_wake_and_assign_slot()
294 bool nfs41_wake_and_assign_slot(struct nfs4_slot_table *tbl, in nfs41_wake_and_assign_slot() argument
297 if (slot->slot_nr > tbl->max_slotid) in nfs41_wake_and_assign_slot()
299 return __nfs41_wake_and_assign_slot(tbl, slot); in nfs41_wake_and_assign_slot()
302 static bool nfs41_try_wake_next_slot_table_entry(struct nfs4_slot_table *tbl) in nfs41_try_wake_next_slot_table_entry() argument
304 struct nfs4_slot *slot = nfs4_alloc_slot(tbl); in nfs41_try_wake_next_slot_table_entry()
306 bool ret = __nfs41_wake_and_assign_slot(tbl, slot); in nfs41_try_wake_next_slot_table_entry()
309 nfs4_free_slot(tbl, slot); in nfs41_try_wake_next_slot_table_entry()
314 void nfs41_wake_slot_table(struct nfs4_slot_table *tbl) in nfs41_wake_slot_table() argument
317 if (!nfs41_try_wake_next_slot_table_entry(tbl)) in nfs41_wake_slot_table()
324 static void nfs41_set_max_slotid_locked(struct nfs4_slot_table *tbl, in nfs41_set_max_slotid_locked() argument
330 if (max_slotid > tbl->server_highest_slotid) in nfs41_set_max_slotid_locked()
331 max_slotid = tbl->server_highest_slotid; in nfs41_set_max_slotid_locked()
332 if (max_slotid > tbl->target_highest_slotid) in nfs41_set_max_slotid_locked()
333 max_slotid = tbl->target_highest_slotid; in nfs41_set_max_slotid_locked()
334 tbl->max_slotid = max_slotid; in nfs41_set_max_slotid_locked()
335 nfs41_wake_slot_table(tbl); in nfs41_set_max_slotid_locked()
339 static void nfs41_set_target_slotid_locked(struct nfs4_slot_table *tbl, in nfs41_set_target_slotid_locked() argument
342 if (tbl->target_highest_slotid == target_highest_slotid) in nfs41_set_target_slotid_locked()
344 tbl->target_highest_slotid = target_highest_slotid; in nfs41_set_target_slotid_locked()
345 tbl->generation++; in nfs41_set_target_slotid_locked()
348 void nfs41_set_target_slotid(struct nfs4_slot_table *tbl, in nfs41_set_target_slotid() argument
351 spin_lock(&tbl->slot_tbl_lock); in nfs41_set_target_slotid()
352 nfs41_set_target_slotid_locked(tbl, target_highest_slotid); in nfs41_set_target_slotid()
353 tbl->d_target_highest_slotid = 0; in nfs41_set_target_slotid()
354 tbl->d2_target_highest_slotid = 0; in nfs41_set_target_slotid()
355 nfs41_set_max_slotid_locked(tbl, target_highest_slotid); in nfs41_set_target_slotid()
356 spin_unlock(&tbl->slot_tbl_lock); in nfs41_set_target_slotid()
359 static void nfs41_set_server_slotid_locked(struct nfs4_slot_table *tbl, in nfs41_set_server_slotid_locked() argument
362 if (tbl->server_highest_slotid == highest_slotid) in nfs41_set_server_slotid_locked()
364 if (tbl->highest_used_slotid > highest_slotid) in nfs41_set_server_slotid_locked()
367 nfs4_shrink_slot_table(tbl, highest_slotid + 1); in nfs41_set_server_slotid_locked()
368 tbl->server_highest_slotid = highest_slotid; in nfs41_set_server_slotid_locked()
400 static bool nfs41_is_outlier_target_slotid(struct nfs4_slot_table *tbl, in nfs41_is_outlier_target_slotid() argument
407 tbl->target_highest_slotid); in nfs41_is_outlier_target_slotid()
409 tbl->d_target_highest_slotid); in nfs41_is_outlier_target_slotid()
411 if (nfs41_same_sign_or_zero_s32(d_target, tbl->d_target_highest_slotid)) in nfs41_is_outlier_target_slotid()
414 if (nfs41_same_sign_or_zero_s32(d2_target, tbl->d2_target_highest_slotid)) in nfs41_is_outlier_target_slotid()
416 tbl->d_target_highest_slotid = d_target; in nfs41_is_outlier_target_slotid()
417 tbl->d2_target_highest_slotid = d2_target; in nfs41_is_outlier_target_slotid()
421 void nfs41_update_target_slotid(struct nfs4_slot_table *tbl, in nfs41_update_target_slotid() argument
425 spin_lock(&tbl->slot_tbl_lock); in nfs41_update_target_slotid()
426 if (!nfs41_is_outlier_target_slotid(tbl, res->sr_target_highest_slotid)) in nfs41_update_target_slotid()
427 nfs41_set_target_slotid_locked(tbl, res->sr_target_highest_slotid); in nfs41_update_target_slotid()
428 if (tbl->generation == slot->generation) in nfs41_update_target_slotid()
429 nfs41_set_server_slotid_locked(tbl, res->sr_highest_slotid); in nfs41_update_target_slotid()
430 nfs41_set_max_slotid_locked(tbl, res->sr_target_highest_slotid); in nfs41_update_target_slotid()
431 spin_unlock(&tbl->slot_tbl_lock); in nfs41_update_target_slotid()
445 struct nfs4_slot_table *tbl; in nfs4_setup_session_slot_tables() local
450 tbl = &ses->fc_slot_table; in nfs4_setup_session_slot_tables()
451 tbl->session = ses; in nfs4_setup_session_slot_tables()
452 status = nfs4_realloc_slot_table(tbl, ses->fc_attrs.max_reqs, 1); in nfs4_setup_session_slot_tables()
456 tbl = &ses->bc_slot_table; in nfs4_setup_session_slot_tables()
457 tbl->session = ses; in nfs4_setup_session_slot_tables()
458 status = nfs4_realloc_slot_table(tbl, ses->bc_attrs.max_reqs, 0); in nfs4_setup_session_slot_tables()
459 if (status && tbl->slots == NULL) in nfs4_setup_session_slot_tables()