Lines Matching +full:wakeup +full:- +full:rtt +full:- +full:timer

1 // SPDX-License-Identifier: GPL-2.0-only
10 * - When a process places a call, it allocates a request slot if
13 * - Next, the caller puts together the RPC message, stuffs it into
15 * - xprt_transmit sends the message and installs the caller on the
17 * it installs a timer that is run after the packet's timeout has
19 * - When a packet arrives, the data_ready handler walks the list of
21 * caller is woken up, and the timer removed.
22 * - When no reply arrives within the timeout interval, the timer is
25 * of -ETIMEDOUT.
26 * - When the caller receives a notification from RPC that a reply arrived,
32 * Support for async RPC is done through a set of RPC-specific scheduling
36 * Copyright (C) 1995-1997, Olaf Kirch <okir@monad.swb.de>
83 unsigned long timeout = jiffies + req->rq_timeout; in xprt_request_timeout()
85 if (time_before(timeout, req->rq_majortimeo)) in xprt_request_timeout()
87 return req->rq_majortimeo; in xprt_request_timeout()
91 * xprt_register_transport - register a transport implementation
99 * -EEXIST: transport already registered
100 * -EINVAL: transport module being unloaded
107 result = -EEXIST; in xprt_register_transport()
111 if (t->ident == transport->ident) in xprt_register_transport()
115 list_add_tail(&transport->list, &xprt_list); in xprt_register_transport()
117 transport->name); in xprt_register_transport()
127 * xprt_unregister_transport - unregister a transport implementation
132 * -ENOENT: transport never registered
145 transport->name); in xprt_unregister_transport()
146 list_del_init(&transport->list); in xprt_unregister_transport()
150 result = -ENOENT; in xprt_unregister_transport()
161 module_put(t->owner); in xprt_class_release()
170 if (t->ident != ident) in xprt_class_find_by_ident_locked()
172 if (!try_module_get(t->owner)) in xprt_class_find_by_ident_locked()
197 for (i = 0; t->netid[i][0] != '\0'; i++) { in xprt_class_find_by_netid_locked()
198 if (strcmp(t->netid[i], netid) != 0) in xprt_class_find_by_netid_locked()
200 if (!try_module_get(t->owner)) in xprt_class_find_by_netid_locked()
226 * xprt_find_transport_ident - convert a netid into a transport identifier
231 * -ENOENT: transport module not available
240 return -ENOENT; in xprt_find_transport_ident()
241 ret = t->ident; in xprt_find_transport_ident()
249 xprt->snd_task = NULL; in xprt_clear_locked()
250 if (!test_bit(XPRT_CLOSE_WAIT, &xprt->state)) in xprt_clear_locked()
251 clear_bit_unlock(XPRT_LOCKED, &xprt->state); in xprt_clear_locked()
253 queue_work(xprtiod_workqueue, &xprt->task_cleanup); in xprt_clear_locked()
257 * xprt_reserve_xprt - serialize write access to transports
267 struct rpc_rqst *req = task->tk_rqstp; in xprt_reserve_xprt()
269 if (test_and_set_bit(XPRT_LOCKED, &xprt->state)) { in xprt_reserve_xprt()
270 if (task == xprt->snd_task) in xprt_reserve_xprt()
274 if (test_bit(XPRT_WRITE_SPACE, &xprt->state)) in xprt_reserve_xprt()
276 xprt->snd_task = task; in xprt_reserve_xprt()
285 task->tk_status = -EAGAIN; in xprt_reserve_xprt()
287 rpc_sleep_on_timeout(&xprt->sending, task, NULL, in xprt_reserve_xprt()
290 rpc_sleep_on(&xprt->sending, task, NULL); in xprt_reserve_xprt()
298 return test_bit(XPRT_CWND_WAIT, &xprt->state); in xprt_need_congestion_window_wait()
304 if (!list_empty(&xprt->xmit_queue)) { in xprt_set_congestion_window_wait()
306 if (list_first_entry(&xprt->xmit_queue, struct rpc_rqst, in xprt_set_congestion_window_wait()
307 rq_xmit)->rq_cong) in xprt_set_congestion_window_wait()
310 set_bit(XPRT_CWND_WAIT, &xprt->state); in xprt_set_congestion_window_wait()
317 clear_bit(XPRT_CWND_WAIT, &xprt->state); in xprt_test_and_clear_congestion_window_wait()
321 * xprt_reserve_xprt_cong - serialize write access to transports
331 struct rpc_rqst *req = task->tk_rqstp; in xprt_reserve_xprt_cong()
333 if (test_and_set_bit(XPRT_LOCKED, &xprt->state)) { in xprt_reserve_xprt_cong()
334 if (task == xprt->snd_task) in xprt_reserve_xprt_cong()
339 xprt->snd_task = task; in xprt_reserve_xprt_cong()
342 if (test_bit(XPRT_WRITE_SPACE, &xprt->state)) in xprt_reserve_xprt_cong()
345 xprt->snd_task = task; in xprt_reserve_xprt_cong()
351 task->tk_status = -EAGAIN; in xprt_reserve_xprt_cong()
353 rpc_sleep_on_timeout(&xprt->sending, task, NULL, in xprt_reserve_xprt_cong()
356 rpc_sleep_on(&xprt->sending, task, NULL); in xprt_reserve_xprt_cong()
368 if (test_bit(XPRT_LOCKED, &xprt->state) && xprt->snd_task == task) in xprt_lock_write()
370 spin_lock(&xprt->transport_lock); in xprt_lock_write()
371 retval = xprt->ops->reserve_xprt(xprt, task); in xprt_lock_write()
372 spin_unlock(&xprt->transport_lock); in xprt_lock_write()
380 xprt->snd_task = task; in __xprt_lock_write_func()
386 if (test_and_set_bit(XPRT_LOCKED, &xprt->state)) in __xprt_lock_write_next()
388 if (test_bit(XPRT_WRITE_SPACE, &xprt->state)) in __xprt_lock_write_next()
390 if (rpc_wake_up_first_on_wq(xprtiod_workqueue, &xprt->sending, in __xprt_lock_write_next()
399 if (test_and_set_bit(XPRT_LOCKED, &xprt->state)) in __xprt_lock_write_next_cong()
401 if (test_bit(XPRT_WRITE_SPACE, &xprt->state)) in __xprt_lock_write_next_cong()
405 if (rpc_wake_up_first_on_wq(xprtiod_workqueue, &xprt->sending, in __xprt_lock_write_next_cong()
413 * xprt_release_xprt - allow other requests to use a transport
421 if (xprt->snd_task == task) { in xprt_release_xprt()
430 * xprt_release_xprt_cong - allow other requests to use a transport
439 if (xprt->snd_task == task) { in xprt_release_xprt_cong()
449 if (xprt->snd_task != task) in xprt_release_write()
451 spin_lock(&xprt->transport_lock); in xprt_release_write()
452 xprt->ops->release_xprt(xprt, task); in xprt_release_write()
453 spin_unlock(&xprt->transport_lock); in xprt_release_write()
463 if (req->rq_cong) in __xprt_get_cong()
465 trace_xprt_get_cong(xprt, req->rq_task); in __xprt_get_cong()
470 req->rq_cong = 1; in __xprt_get_cong()
471 xprt->cong += RPC_CWNDSCALE; in __xprt_get_cong()
482 if (!req->rq_cong) in __xprt_put_cong()
484 req->rq_cong = 0; in __xprt_put_cong()
485 xprt->cong -= RPC_CWNDSCALE; in __xprt_put_cong()
487 trace_xprt_put_cong(xprt, req->rq_task); in __xprt_put_cong()
492 * xprt_request_get_cong - Request congestion control credits
503 if (req->rq_cong) in xprt_request_get_cong()
505 spin_lock(&xprt->transport_lock); in xprt_request_get_cong()
507 spin_unlock(&xprt->transport_lock); in xprt_request_get_cong()
513 * xprt_release_rqst_cong - housekeeping when request is complete
520 struct rpc_rqst *req = task->tk_rqstp; in xprt_release_rqst_cong()
522 __xprt_put_cong(req->rq_xprt, req); in xprt_release_rqst_cong()
528 if (test_and_clear_bit(XPRT_CWND_WAIT, &xprt->state)) in xprt_clear_congestion_window_wait_locked()
534 * entry on xprt->sending
539 if (test_and_clear_bit(XPRT_CWND_WAIT, &xprt->state)) { in xprt_clear_congestion_window_wait()
540 spin_lock(&xprt->transport_lock); in xprt_clear_congestion_window_wait()
542 spin_unlock(&xprt->transport_lock); in xprt_clear_congestion_window_wait()
547 * xprt_adjust_cwnd - adjust transport congestion window
552 * The transport code maintains an estimate on the maximum number of out-
558 * - a reply is received and
559 * - a full number of requests are outstanding and
560 * - the congestion window hasn't been updated recently.
564 struct rpc_rqst *req = task->tk_rqstp; in xprt_adjust_cwnd()
565 unsigned long cwnd = xprt->cwnd; in xprt_adjust_cwnd()
567 if (result >= 0 && cwnd <= xprt->cong) { in xprt_adjust_cwnd()
574 } else if (result == -ETIMEDOUT) { in xprt_adjust_cwnd()
580 xprt->cong, xprt->cwnd, cwnd); in xprt_adjust_cwnd()
581 xprt->cwnd = cwnd; in xprt_adjust_cwnd()
587 * xprt_wake_pending_tasks - wake all tasks on a transport's pending queue
595 rpc_wake_up_status(&xprt->pending, status); in xprt_wake_pending_tasks()
597 rpc_wake_up(&xprt->pending); in xprt_wake_pending_tasks()
602 * xprt_wait_for_buffer_space - wait for transport output buffer to clear
605 * Note that we only set the timer for the case of RPC_IS_SOFT(), since
611 set_bit(XPRT_WRITE_SPACE, &xprt->state); in xprt_wait_for_buffer_space()
618 if (test_and_clear_bit(XPRT_WRITE_SPACE, &xprt->state)) { in xprt_clear_write_space_locked()
628 * xprt_write_space - wake the task waiting for transport output buffer space
637 if (!test_bit(XPRT_WRITE_SPACE, &xprt->state)) in xprt_write_space()
639 spin_lock(&xprt->transport_lock); in xprt_write_space()
641 spin_unlock(&xprt->transport_lock); in xprt_write_space()
648 s64 delta = ktime_to_ns(ktime_get() - abstime); in xprt_abs_ktime_to_jiffies()
650 jiffies - nsecs_to_jiffies(delta) : in xprt_abs_ktime_to_jiffies()
651 jiffies + nsecs_to_jiffies(-delta); in xprt_abs_ktime_to_jiffies()
656 const struct rpc_timeout *to = req->rq_task->tk_client->cl_timeout; in xprt_calc_majortimeo()
657 unsigned long majortimeo = req->rq_timeout; in xprt_calc_majortimeo()
659 if (to->to_exponential) in xprt_calc_majortimeo()
660 majortimeo <<= to->to_retries; in xprt_calc_majortimeo()
662 majortimeo += to->to_increment * to->to_retries; in xprt_calc_majortimeo()
663 if (majortimeo > to->to_maxval || majortimeo == 0) in xprt_calc_majortimeo()
664 majortimeo = to->to_maxval; in xprt_calc_majortimeo()
670 req->rq_majortimeo += xprt_calc_majortimeo(req); in xprt_reset_majortimeo()
675 req->rq_minortimeo += req->rq_timeout; in xprt_reset_minortimeo()
681 struct rpc_xprt *xprt = req->rq_xprt; in xprt_init_majortimeo()
686 time_init = xprt_abs_ktime_to_jiffies(task->tk_start); in xprt_init_majortimeo()
687 req->rq_timeout = task->tk_client->cl_timeout->to_initval; in xprt_init_majortimeo()
688 req->rq_majortimeo = time_init + xprt_calc_majortimeo(req); in xprt_init_majortimeo()
689 req->rq_minortimeo = time_init + req->rq_timeout; in xprt_init_majortimeo()
693 * xprt_adjust_timeout - adjust timeout values for next retransmit
699 struct rpc_xprt *xprt = req->rq_xprt; in xprt_adjust_timeout()
700 const struct rpc_timeout *to = req->rq_task->tk_client->cl_timeout; in xprt_adjust_timeout()
703 if (time_before(jiffies, req->rq_majortimeo)) { in xprt_adjust_timeout()
704 if (time_before(jiffies, req->rq_minortimeo)) in xprt_adjust_timeout()
706 if (to->to_exponential) in xprt_adjust_timeout()
707 req->rq_timeout <<= 1; in xprt_adjust_timeout()
709 req->rq_timeout += to->to_increment; in xprt_adjust_timeout()
710 if (to->to_maxval && req->rq_timeout >= to->to_maxval) in xprt_adjust_timeout()
711 req->rq_timeout = to->to_maxval; in xprt_adjust_timeout()
712 req->rq_retries++; in xprt_adjust_timeout()
714 req->rq_timeout = to->to_initval; in xprt_adjust_timeout()
715 req->rq_retries = 0; in xprt_adjust_timeout()
717 /* Reset the RTT counters == "slow start" */ in xprt_adjust_timeout()
718 spin_lock(&xprt->transport_lock); in xprt_adjust_timeout()
719 rpc_init_rtt(req->rq_task->tk_client->cl_rtt, to->to_initval); in xprt_adjust_timeout()
720 spin_unlock(&xprt->transport_lock); in xprt_adjust_timeout()
721 status = -ETIMEDOUT; in xprt_adjust_timeout()
725 if (req->rq_timeout == 0) { in xprt_adjust_timeout()
727 req->rq_timeout = 5 * HZ; in xprt_adjust_timeout()
739 xprt->connect_cookie++; in xprt_autoclose()
741 clear_bit(XPRT_CLOSE_WAIT, &xprt->state); in xprt_autoclose()
742 xprt->ops->close(xprt); in xprt_autoclose()
744 wake_up_bit(&xprt->state, XPRT_LOCKED); in xprt_autoclose()
749 * xprt_disconnect_done - mark a transport as disconnected
756 spin_lock(&xprt->transport_lock); in xprt_disconnect_done()
760 xprt_wake_pending_tasks(xprt, -ENOTCONN); in xprt_disconnect_done()
761 spin_unlock(&xprt->transport_lock); in xprt_disconnect_done()
766 * xprt_schedule_autoclose_locked - Try to schedule an autoclose RPC call
771 if (test_and_set_bit(XPRT_CLOSE_WAIT, &xprt->state)) in xprt_schedule_autoclose_locked()
773 if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0) in xprt_schedule_autoclose_locked()
774 queue_work(xprtiod_workqueue, &xprt->task_cleanup); in xprt_schedule_autoclose_locked()
775 else if (xprt->snd_task && !test_bit(XPRT_SND_IS_COOKIE, &xprt->state)) in xprt_schedule_autoclose_locked()
776 rpc_wake_up_queued_task_set_status(&xprt->pending, in xprt_schedule_autoclose_locked()
777 xprt->snd_task, -ENOTCONN); in xprt_schedule_autoclose_locked()
781 * xprt_force_disconnect - force a transport to disconnect
790 spin_lock(&xprt->transport_lock); in xprt_force_disconnect()
792 spin_unlock(&xprt->transport_lock); in xprt_force_disconnect()
799 return READ_ONCE(xprt->connect_cookie); in xprt_connect_cookie()
805 struct rpc_rqst *req = task->tk_rqstp; in xprt_request_retransmit_after_disconnect()
806 struct rpc_xprt *xprt = req->rq_xprt; in xprt_request_retransmit_after_disconnect()
808 return req->rq_connect_cookie != xprt_connect_cookie(xprt) || in xprt_request_retransmit_after_disconnect()
813 * xprt_conditional_disconnect - force a transport to disconnect
826 spin_lock(&xprt->transport_lock); in xprt_conditional_disconnect()
827 if (cookie != xprt->connect_cookie) in xprt_conditional_disconnect()
829 if (test_bit(XPRT_CLOSING, &xprt->state)) in xprt_conditional_disconnect()
833 spin_unlock(&xprt->transport_lock); in xprt_conditional_disconnect()
839 return xprt->idle_timeout != 0; in xprt_has_timer()
844 __must_hold(&xprt->transport_lock) in xprt_schedule_autodisconnect()
846 xprt->last_used = jiffies; in xprt_schedule_autodisconnect()
847 if (RB_EMPTY_ROOT(&xprt->recv_queue) && xprt_has_timer(xprt)) in xprt_schedule_autodisconnect()
848 mod_timer(&xprt->timer, xprt->last_used + xprt->idle_timeout); in xprt_schedule_autodisconnect()
854 struct rpc_xprt *xprt = from_timer(xprt, t, timer); in xprt_init_autodisconnect()
856 if (!RB_EMPTY_ROOT(&xprt->recv_queue)) in xprt_init_autodisconnect()
858 /* Reset xprt->last_used to avoid connect/autodisconnect cycling */ in xprt_init_autodisconnect()
859 xprt->last_used = jiffies; in xprt_init_autodisconnect()
860 if (test_and_set_bit(XPRT_LOCKED, &xprt->state)) in xprt_init_autodisconnect()
862 queue_work(xprtiod_workqueue, &xprt->task_cleanup); in xprt_init_autodisconnect()
870 xprt->ops->inject_disconnect(xprt); in xprt_inject_disconnect()
884 spin_lock(&xprt->transport_lock); in xprt_lock_connect()
885 if (!test_bit(XPRT_LOCKED, &xprt->state)) in xprt_lock_connect()
887 if (xprt->snd_task != task) in xprt_lock_connect()
889 set_bit(XPRT_SND_IS_COOKIE, &xprt->state); in xprt_lock_connect()
890 xprt->snd_task = cookie; in xprt_lock_connect()
893 spin_unlock(&xprt->transport_lock); in xprt_lock_connect()
900 spin_lock(&xprt->transport_lock); in xprt_unlock_connect()
901 if (xprt->snd_task != cookie) in xprt_unlock_connect()
903 if (!test_bit(XPRT_LOCKED, &xprt->state)) in xprt_unlock_connect()
905 xprt->snd_task =NULL; in xprt_unlock_connect()
906 clear_bit(XPRT_SND_IS_COOKIE, &xprt->state); in xprt_unlock_connect()
907 xprt->ops->release_xprt(xprt, NULL); in xprt_unlock_connect()
910 spin_unlock(&xprt->transport_lock); in xprt_unlock_connect()
911 wake_up_bit(&xprt->state, XPRT_LOCKED); in xprt_unlock_connect()
916 * xprt_connect - schedule a transport connect operation
922 struct rpc_xprt *xprt = task->tk_rqstp->rq_xprt; in xprt_connect()
927 task->tk_status = -EAGAIN; in xprt_connect()
933 if (!xprt_connected(xprt) && !test_bit(XPRT_CLOSE_WAIT, &xprt->state)) { in xprt_connect()
934 task->tk_rqstp->rq_connect_cookie = xprt->connect_cookie; in xprt_connect()
935 rpc_sleep_on_timeout(&xprt->pending, task, NULL, in xprt_connect()
936 xprt_request_timeout(task->tk_rqstp)); in xprt_connect()
938 if (test_bit(XPRT_CLOSING, &xprt->state)) in xprt_connect()
944 xprt->stat.connect_start = jiffies; in xprt_connect()
945 xprt->ops->connect(xprt, task); in xprt_connect()
948 task->tk_status = 0; in xprt_connect()
949 rpc_wake_up_queued_task(&xprt->pending, task); in xprt_connect()
956 * xprt_reconnect_delay - compute the wait before scheduling a connect
964 start = xprt->stat.connect_start + xprt->reestablish_timeout; in xprt_reconnect_delay()
966 return start - now; in xprt_reconnect_delay()
972 * xprt_reconnect_backoff - compute the new re-establish timeout
979 xprt->reestablish_timeout <<= 1; in xprt_reconnect_backoff()
980 if (xprt->reestablish_timeout > xprt->max_reconnect_timeout) in xprt_reconnect_backoff()
981 xprt->reestablish_timeout = xprt->max_reconnect_timeout; in xprt_reconnect_backoff()
982 if (xprt->reestablish_timeout < init_to) in xprt_reconnect_backoff()
983 xprt->reestablish_timeout = init_to; in xprt_reconnect_backoff()
1005 struct rb_node *n = xprt->recv_queue.rb_node; in xprt_request_rb_find()
1010 switch (xprt_xid_cmp(xid, req->rq_xid)) { in xprt_request_rb_find()
1012 n = n->rb_left; in xprt_request_rb_find()
1015 n = n->rb_right; in xprt_request_rb_find()
1027 struct rb_node **p = &xprt->recv_queue.rb_node; in xprt_request_rb_insert()
1034 switch(xprt_xid_cmp(new->rq_xid, req->rq_xid)) { in xprt_request_rb_insert()
1036 p = &n->rb_left; in xprt_request_rb_insert()
1039 p = &n->rb_right; in xprt_request_rb_insert()
1046 rb_link_node(&new->rq_recv, n, p); in xprt_request_rb_insert()
1047 rb_insert_color(&new->rq_recv, &xprt->recv_queue); in xprt_request_rb_insert()
1053 rb_erase(&req->rq_recv, &xprt->recv_queue); in xprt_request_rb_remove()
1057 * xprt_lookup_rqst - find an RPC request corresponding to an XID
1061 * Caller holds xprt->queue_lock.
1070 entry->rq_rtt = ktime_sub(ktime_get(), entry->rq_xtime); in xprt_lookup_rqst()
1076 trace_xprt_lookup_rqst(xprt, xid, -ENOENT); in xprt_lookup_rqst()
1077 xprt->stat.bad_xids++; in xprt_lookup_rqst()
1085 return atomic_read(&req->rq_pin) != 0; in xprt_is_pinned_rqst()
1089 * xprt_pin_rqst - Pin a request on the transport receive list
1093 * so should be holding xprt->queue_lock.
1097 atomic_inc(&req->rq_pin); in xprt_pin_rqst()
1102 * xprt_unpin_rqst - Unpin a request on the transport receive list
1105 * Caller should be holding xprt->queue_lock.
1109 if (!test_bit(RPC_TASK_MSG_PIN_WAIT, &req->rq_task->tk_runstate)) { in xprt_unpin_rqst()
1110 atomic_dec(&req->rq_pin); in xprt_unpin_rqst()
1113 if (atomic_dec_and_test(&req->rq_pin)) in xprt_unpin_rqst()
1114 wake_up_var(&req->rq_pin); in xprt_unpin_rqst()
1120 wait_var_event(&req->rq_pin, !xprt_is_pinned_rqst(req)); in xprt_wait_on_pinned_rqst()
1126 return !test_bit(RPC_TASK_NEED_RECV, &task->tk_runstate) && in xprt_request_data_received()
1127 READ_ONCE(task->tk_rqstp->rq_reply_bytes_recvd) != 0; in xprt_request_data_received()
1133 return !test_bit(RPC_TASK_NEED_RECV, &task->tk_runstate) && in xprt_request_need_enqueue_receive()
1134 READ_ONCE(task->tk_rqstp->rq_reply_bytes_recvd) == 0; in xprt_request_need_enqueue_receive()
1138 * xprt_request_enqueue_receive - Add an request to the receive queue
1145 struct rpc_rqst *req = task->tk_rqstp; in xprt_request_enqueue_receive()
1146 struct rpc_xprt *xprt = req->rq_xprt; in xprt_request_enqueue_receive()
1152 ret = xprt_request_prepare(task->tk_rqstp, &req->rq_rcv_buf); in xprt_request_enqueue_receive()
1155 spin_lock(&xprt->queue_lock); in xprt_request_enqueue_receive()
1158 memcpy(&req->rq_private_buf, &req->rq_rcv_buf, in xprt_request_enqueue_receive()
1159 sizeof(req->rq_private_buf)); in xprt_request_enqueue_receive()
1163 set_bit(RPC_TASK_NEED_RECV, &task->tk_runstate); in xprt_request_enqueue_receive()
1164 spin_unlock(&xprt->queue_lock); in xprt_request_enqueue_receive()
1167 del_timer_sync(&xprt->timer); in xprt_request_enqueue_receive()
1172 * xprt_request_dequeue_receive_locked - Remove a request from the receive queue
1175 * Caller must hold xprt->queue_lock.
1180 struct rpc_rqst *req = task->tk_rqstp; in xprt_request_dequeue_receive_locked()
1182 if (test_and_clear_bit(RPC_TASK_NEED_RECV, &task->tk_runstate)) in xprt_request_dequeue_receive_locked()
1183 xprt_request_rb_remove(req->rq_xprt, req); in xprt_request_dequeue_receive_locked()
1187 * xprt_update_rtt - Update RPC RTT statistics
1190 * Caller holds xprt->queue_lock.
1194 struct rpc_rqst *req = task->tk_rqstp; in xprt_update_rtt()
1195 struct rpc_rtt *rtt = task->tk_client->cl_rtt; in xprt_update_rtt() local
1196 unsigned int timer = task->tk_msg.rpc_proc->p_timer; in xprt_update_rtt() local
1197 long m = usecs_to_jiffies(ktime_to_us(req->rq_rtt)); in xprt_update_rtt()
1199 if (timer) { in xprt_update_rtt()
1200 if (req->rq_ntrans == 1) in xprt_update_rtt()
1201 rpc_update_rtt(rtt, timer, m); in xprt_update_rtt()
1202 rpc_set_timeo(rtt, timer, req->rq_ntrans - 1); in xprt_update_rtt()
1208 * xprt_complete_rqst - called when reply processing is complete
1212 * Caller holds xprt->queue_lock.
1216 struct rpc_rqst *req = task->tk_rqstp; in xprt_complete_rqst()
1217 struct rpc_xprt *xprt = req->rq_xprt; in xprt_complete_rqst()
1219 xprt->stat.recvs++; in xprt_complete_rqst()
1221 xdr_free_bvec(&req->rq_rcv_buf); in xprt_complete_rqst()
1222 req->rq_private_buf.bvec = NULL; in xprt_complete_rqst()
1223 req->rq_private_buf.len = copied; in xprt_complete_rqst()
1225 /* req->rq_reply_bytes_recvd */ in xprt_complete_rqst()
1227 req->rq_reply_bytes_recvd = copied; in xprt_complete_rqst()
1229 rpc_wake_up_queued_task(&xprt->pending, task); in xprt_complete_rqst()
1235 struct rpc_rqst *req = task->tk_rqstp; in xprt_timer()
1236 struct rpc_xprt *xprt = req->rq_xprt; in xprt_timer()
1238 if (task->tk_status != -ETIMEDOUT) in xprt_timer()
1241 trace_xprt_timer(xprt, req->rq_xid, task->tk_status); in xprt_timer()
1242 if (!req->rq_reply_bytes_recvd) { in xprt_timer()
1243 if (xprt->ops->timer) in xprt_timer()
1244 xprt->ops->timer(xprt, task); in xprt_timer()
1246 task->tk_status = 0; in xprt_timer()
1250 * xprt_wait_for_reply_request_def - wait for reply
1255 * the retransmit timeout based on round-trip time estimation,
1260 struct rpc_rqst *req = task->tk_rqstp; in xprt_wait_for_reply_request_def()
1262 rpc_sleep_on_timeout(&req->rq_xprt->pending, task, xprt_timer, in xprt_wait_for_reply_request_def()
1268 * xprt_wait_for_reply_request_rtt - wait for reply using RTT estimator
1271 * Set a request's retransmit timeout using the RTT estimator,
1276 int timer = task->tk_msg.rpc_proc->p_timer; in xprt_wait_for_reply_request_rtt() local
1277 struct rpc_clnt *clnt = task->tk_client; in xprt_wait_for_reply_request_rtt()
1278 struct rpc_rtt *rtt = clnt->cl_rtt; in xprt_wait_for_reply_request_rtt() local
1279 struct rpc_rqst *req = task->tk_rqstp; in xprt_wait_for_reply_request_rtt()
1280 unsigned long max_timeout = clnt->cl_timeout->to_maxval; in xprt_wait_for_reply_request_rtt()
1283 timeout = rpc_calc_rto(rtt, timer); in xprt_wait_for_reply_request_rtt()
1284 timeout <<= rpc_ntimeo(rtt, timer) + req->rq_retries; in xprt_wait_for_reply_request_rtt()
1287 rpc_sleep_on_timeout(&req->rq_xprt->pending, task, xprt_timer, in xprt_wait_for_reply_request_rtt()
1293 * xprt_request_wait_receive - wait for the reply to an RPC request
1299 struct rpc_rqst *req = task->tk_rqstp; in xprt_request_wait_receive()
1300 struct rpc_xprt *xprt = req->rq_xprt; in xprt_request_wait_receive()
1302 if (!test_bit(RPC_TASK_NEED_RECV, &task->tk_runstate)) in xprt_request_wait_receive()
1307 * req->rq_reply_bytes_recvd, and the call to rpc_sleep_on(). in xprt_request_wait_receive()
1309 spin_lock(&xprt->queue_lock); in xprt_request_wait_receive()
1310 if (test_bit(RPC_TASK_NEED_RECV, &task->tk_runstate)) { in xprt_request_wait_receive()
1311 xprt->ops->wait_for_reply_request(task); in xprt_request_wait_receive()
1313 * Send an extra queue wakeup call if the in xprt_request_wait_receive()
1318 rpc_wake_up_queued_task_set_status(&xprt->pending, in xprt_request_wait_receive()
1319 task, -ENOTCONN); in xprt_request_wait_receive()
1321 spin_unlock(&xprt->queue_lock); in xprt_request_wait_receive()
1327 return !test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate); in xprt_request_need_enqueue_transmit()
1331 * xprt_request_enqueue_transmit - queue a task for transmission
1339 struct rpc_rqst *pos, *req = task->tk_rqstp; in xprt_request_enqueue_transmit()
1340 struct rpc_xprt *xprt = req->rq_xprt; in xprt_request_enqueue_transmit()
1344 ret = xprt_request_prepare(task->tk_rqstp, &req->rq_snd_buf); in xprt_request_enqueue_transmit()
1346 task->tk_status = ret; in xprt_request_enqueue_transmit()
1349 req->rq_bytes_sent = 0; in xprt_request_enqueue_transmit()
1350 spin_lock(&xprt->queue_lock); in xprt_request_enqueue_transmit()
1355 if (req->rq_cong) { in xprt_request_enqueue_transmit()
1357 list_for_each_entry(pos, &xprt->xmit_queue, rq_xmit) { in xprt_request_enqueue_transmit()
1358 if (pos->rq_cong) in xprt_request_enqueue_transmit()
1361 list_add_tail(&req->rq_xmit, &pos->rq_xmit); in xprt_request_enqueue_transmit()
1362 INIT_LIST_HEAD(&req->rq_xmit2); in xprt_request_enqueue_transmit()
1365 } else if (!req->rq_seqno) { in xprt_request_enqueue_transmit()
1366 list_for_each_entry(pos, &xprt->xmit_queue, rq_xmit) { in xprt_request_enqueue_transmit()
1367 if (pos->rq_task->tk_owner != task->tk_owner) in xprt_request_enqueue_transmit()
1369 list_add_tail(&req->rq_xmit2, &pos->rq_xmit2); in xprt_request_enqueue_transmit()
1370 INIT_LIST_HEAD(&req->rq_xmit); in xprt_request_enqueue_transmit()
1374 list_add_tail(&req->rq_xmit, &xprt->xmit_queue); in xprt_request_enqueue_transmit()
1375 INIT_LIST_HEAD(&req->rq_xmit2); in xprt_request_enqueue_transmit()
1377 atomic_long_inc(&xprt->xmit_queuelen); in xprt_request_enqueue_transmit()
1378 set_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate); in xprt_request_enqueue_transmit()
1379 spin_unlock(&xprt->queue_lock); in xprt_request_enqueue_transmit()
1384 * xprt_request_dequeue_transmit_locked - remove a task from the transmission queue
1388 * Caller must hold xprt->queue_lock
1393 struct rpc_rqst *req = task->tk_rqstp; in xprt_request_dequeue_transmit_locked()
1395 if (!test_and_clear_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) in xprt_request_dequeue_transmit_locked()
1397 if (!list_empty(&req->rq_xmit)) { in xprt_request_dequeue_transmit_locked()
1398 list_del(&req->rq_xmit); in xprt_request_dequeue_transmit_locked()
1399 if (!list_empty(&req->rq_xmit2)) { in xprt_request_dequeue_transmit_locked()
1400 struct rpc_rqst *next = list_first_entry(&req->rq_xmit2, in xprt_request_dequeue_transmit_locked()
1402 list_del(&req->rq_xmit2); in xprt_request_dequeue_transmit_locked()
1403 list_add_tail(&next->rq_xmit, &next->rq_xprt->xmit_queue); in xprt_request_dequeue_transmit_locked()
1406 list_del(&req->rq_xmit2); in xprt_request_dequeue_transmit_locked()
1407 atomic_long_dec(&req->rq_xprt->xmit_queuelen); in xprt_request_dequeue_transmit_locked()
1408 xdr_free_bvec(&req->rq_snd_buf); in xprt_request_dequeue_transmit_locked()
1412 * xprt_request_dequeue_transmit - remove a task from the transmission queue
1420 struct rpc_rqst *req = task->tk_rqstp; in xprt_request_dequeue_transmit()
1421 struct rpc_xprt *xprt = req->rq_xprt; in xprt_request_dequeue_transmit()
1423 spin_lock(&xprt->queue_lock); in xprt_request_dequeue_transmit()
1425 spin_unlock(&xprt->queue_lock); in xprt_request_dequeue_transmit()
1429 * xprt_request_dequeue_xprt - remove a task from the transmit+receive queue
1438 struct rpc_rqst *req = task->tk_rqstp; in xprt_request_dequeue_xprt()
1439 struct rpc_xprt *xprt = req->rq_xprt; in xprt_request_dequeue_xprt()
1441 if (test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate) || in xprt_request_dequeue_xprt()
1442 test_bit(RPC_TASK_NEED_RECV, &task->tk_runstate) || in xprt_request_dequeue_xprt()
1444 spin_lock(&xprt->queue_lock); in xprt_request_dequeue_xprt()
1446 set_bit(RPC_TASK_MSG_PIN_WAIT, &task->tk_runstate); in xprt_request_dequeue_xprt()
1447 spin_unlock(&xprt->queue_lock); in xprt_request_dequeue_xprt()
1449 spin_lock(&xprt->queue_lock); in xprt_request_dequeue_xprt()
1450 clear_bit(RPC_TASK_MSG_PIN_WAIT, &task->tk_runstate); in xprt_request_dequeue_xprt()
1454 spin_unlock(&xprt->queue_lock); in xprt_request_dequeue_xprt()
1455 xdr_free_bvec(&req->rq_rcv_buf); in xprt_request_dequeue_xprt()
1460 * xprt_request_prepare - prepare an encoded request for transport
1471 struct rpc_xprt *xprt = req->rq_xprt; in xprt_request_prepare()
1473 if (xprt->ops->prepare_request) in xprt_request_prepare()
1474 return xprt->ops->prepare_request(req, buf); in xprt_request_prepare()
1479 * xprt_request_need_retransmit - Test if a task needs retransmission
1491 * xprt_prepare_transmit - reserve the transport before sending a request
1497 struct rpc_rqst *req = task->tk_rqstp; in xprt_prepare_transmit()
1498 struct rpc_xprt *xprt = req->rq_xprt; in xprt_prepare_transmit()
1502 if (!test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) in xprt_prepare_transmit()
1503 rpc_wake_up_queued_task_set_status(&xprt->sending, in xprt_prepare_transmit()
1508 if (atomic_read(&xprt->swapper)) in xprt_prepare_transmit()
1510 current->flags |= PF_MEMALLOC; in xprt_prepare_transmit()
1516 struct rpc_xprt *xprt = task->tk_rqstp->rq_xprt; in xprt_end_transmit()
1523 * xprt_request_transmit - send an RPC request on a transport
1535 struct rpc_xprt *xprt = req->rq_xprt; in xprt_request_transmit()
1536 struct rpc_task *task = req->rq_task; in xprt_request_transmit()
1541 if (!req->rq_bytes_sent) { in xprt_request_transmit()
1548 status = -EBADMSG; in xprt_request_transmit()
1552 status = -ERESTARTSYS; in xprt_request_transmit()
1558 * Update req->rq_ntrans before transmitting to avoid races with in xprt_request_transmit()
1562 req->rq_ntrans++; in xprt_request_transmit()
1564 trace_rpc_xdr_sendto(task, &req->rq_snd_buf); in xprt_request_transmit()
1565 connect_cookie = xprt->connect_cookie; in xprt_request_transmit()
1566 status = xprt->ops->send_request(req); in xprt_request_transmit()
1568 req->rq_ntrans--; in xprt_request_transmit()
1574 task->tk_client->cl_stats->rpcretrans++; in xprt_request_transmit()
1580 task->tk_flags |= RPC_TASK_SENT; in xprt_request_transmit()
1581 spin_lock(&xprt->transport_lock); in xprt_request_transmit()
1583 xprt->stat.sends++; in xprt_request_transmit()
1584 xprt->stat.req_u += xprt->stat.sends - xprt->stat.recvs; in xprt_request_transmit()
1585 xprt->stat.bklog_u += xprt->backlog.qlen; in xprt_request_transmit()
1586 xprt->stat.sending_u += xprt->sending.qlen; in xprt_request_transmit()
1587 xprt->stat.pending_u += xprt->pending.qlen; in xprt_request_transmit()
1588 spin_unlock(&xprt->transport_lock); in xprt_request_transmit()
1590 req->rq_connect_cookie = connect_cookie; in xprt_request_transmit()
1594 rpc_wake_up_queued_task_set_status(&xprt->sending, task, status); in xprt_request_transmit()
1599 * xprt_transmit - send an RPC request on a transport
1610 struct rpc_rqst *next, *req = task->tk_rqstp; in xprt_transmit()
1611 struct rpc_xprt *xprt = req->rq_xprt; in xprt_transmit()
1614 spin_lock(&xprt->queue_lock); in xprt_transmit()
1616 next = list_first_entry_or_null(&xprt->xmit_queue, in xprt_transmit()
1621 spin_unlock(&xprt->queue_lock); in xprt_transmit()
1623 if (status == -EBADMSG && next != req) in xprt_transmit()
1625 spin_lock(&xprt->queue_lock); in xprt_transmit()
1628 if (test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) in xprt_transmit()
1629 task->tk_status = status; in xprt_transmit()
1634 !test_bit(RPC_TASK_NEED_XMIT, &task->tk_runstate)) in xprt_transmit()
1636 cond_resched_lock(&xprt->queue_lock); in xprt_transmit()
1638 spin_unlock(&xprt->queue_lock); in xprt_transmit()
1643 if (task->tk_rqstp) in xprt_complete_request_init()
1649 set_bit(XPRT_CONGESTED, &xprt->state); in xprt_add_backlog()
1650 rpc_sleep_on(&xprt->backlog, task, xprt_complete_request_init); in xprt_add_backlog()
1658 if (task->tk_rqstp == NULL) { in __xprt_set_rq()
1660 task->tk_rqstp = req; in __xprt_set_rq()
1668 if (rpc_wake_up_first(&xprt->backlog, __xprt_set_rq, req) == NULL) { in xprt_wake_up_backlog()
1669 clear_bit(XPRT_CONGESTED, &xprt->state); in xprt_wake_up_backlog()
1680 if (!test_bit(XPRT_CONGESTED, &xprt->state)) in xprt_throttle_congested()
1682 spin_lock(&xprt->reserve_lock); in xprt_throttle_congested()
1683 if (test_bit(XPRT_CONGESTED, &xprt->state)) { in xprt_throttle_congested()
1687 spin_unlock(&xprt->reserve_lock); in xprt_throttle_congested()
1694 struct rpc_rqst *req = ERR_PTR(-EAGAIN); in xprt_dynamic_alloc_slot()
1696 if (xprt->num_reqs >= xprt->max_reqs) in xprt_dynamic_alloc_slot()
1698 ++xprt->num_reqs; in xprt_dynamic_alloc_slot()
1699 spin_unlock(&xprt->reserve_lock); in xprt_dynamic_alloc_slot()
1701 spin_lock(&xprt->reserve_lock); in xprt_dynamic_alloc_slot()
1704 --xprt->num_reqs; in xprt_dynamic_alloc_slot()
1705 req = ERR_PTR(-ENOMEM); in xprt_dynamic_alloc_slot()
1712 if (xprt->num_reqs > xprt->min_reqs) { in xprt_dynamic_free_slot()
1713 --xprt->num_reqs; in xprt_dynamic_free_slot()
1724 spin_lock(&xprt->reserve_lock); in xprt_alloc_slot()
1725 if (!list_empty(&xprt->free)) { in xprt_alloc_slot()
1726 req = list_entry(xprt->free.next, struct rpc_rqst, rq_list); in xprt_alloc_slot()
1727 list_del(&req->rq_list); in xprt_alloc_slot()
1734 case -ENOMEM: in xprt_alloc_slot()
1737 task->tk_status = -ENOMEM; in xprt_alloc_slot()
1739 case -EAGAIN: in xprt_alloc_slot()
1744 task->tk_status = -EAGAIN; in xprt_alloc_slot()
1746 spin_unlock(&xprt->reserve_lock); in xprt_alloc_slot()
1749 xprt->stat.max_slots = max_t(unsigned int, xprt->stat.max_slots, in xprt_alloc_slot()
1750 xprt->num_reqs); in xprt_alloc_slot()
1751 spin_unlock(&xprt->reserve_lock); in xprt_alloc_slot()
1753 task->tk_status = 0; in xprt_alloc_slot()
1754 task->tk_rqstp = req; in xprt_alloc_slot()
1760 spin_lock(&xprt->reserve_lock); in xprt_free_slot()
1764 list_add(&req->rq_list, &xprt->free); in xprt_free_slot()
1766 spin_unlock(&xprt->reserve_lock); in xprt_free_slot()
1773 while (!list_empty(&xprt->free)) { in xprt_free_all_slots()
1774 req = list_first_entry(&xprt->free, struct rpc_rqst, rq_list); in xprt_free_all_slots()
1775 list_del(&req->rq_list); in xprt_free_all_slots()
1795 xprt->id = id; in xprt_alloc_id()
1801 ida_free(&rpc_xprt_ids, xprt->id); in xprt_free_id()
1823 list_add(&req->rq_list, &xprt->free); in xprt_alloc()
1825 xprt->max_reqs = max_t(unsigned int, max_alloc, num_prealloc); in xprt_alloc()
1826 xprt->min_reqs = num_prealloc; in xprt_alloc()
1827 xprt->num_reqs = num_prealloc; in xprt_alloc()
1840 put_net_track(xprt->xprt_net, &xprt->ns_tracker); in xprt_free()
1851 req->rq_connect_cookie = xprt_connect_cookie(xprt) - 1; in xprt_init_connect_cookie()
1859 spin_lock(&xprt->reserve_lock); in xprt_alloc_xid()
1860 xid = (__force __be32)xprt->xid++; in xprt_alloc_xid()
1861 spin_unlock(&xprt->reserve_lock); in xprt_alloc_xid()
1868 xprt->xid = get_random_u32(); in xprt_init_xid()
1874 struct rpc_xprt *xprt = task->tk_xprt; in xprt_request_init()
1875 struct rpc_rqst *req = task->tk_rqstp; in xprt_request_init()
1877 req->rq_task = task; in xprt_request_init()
1878 req->rq_xprt = xprt; in xprt_request_init()
1879 req->rq_buffer = NULL; in xprt_request_init()
1880 req->rq_xid = xprt_alloc_xid(xprt); in xprt_request_init()
1882 req->rq_snd_buf.len = 0; in xprt_request_init()
1883 req->rq_snd_buf.buflen = 0; in xprt_request_init()
1884 req->rq_rcv_buf.len = 0; in xprt_request_init()
1885 req->rq_rcv_buf.buflen = 0; in xprt_request_init()
1886 req->rq_snd_buf.bvec = NULL; in xprt_request_init()
1887 req->rq_rcv_buf.bvec = NULL; in xprt_request_init()
1888 req->rq_release_snd_buf = NULL; in xprt_request_init()
1897 xprt->ops->alloc_slot(xprt, task); in xprt_do_reserve()
1898 if (task->tk_rqstp != NULL) in xprt_do_reserve()
1903 * xprt_reserve - allocate an RPC request slot
1912 struct rpc_xprt *xprt = task->tk_xprt; in xprt_reserve()
1914 task->tk_status = 0; in xprt_reserve()
1915 if (task->tk_rqstp != NULL) in xprt_reserve()
1918 task->tk_status = -EAGAIN; in xprt_reserve()
1924 * xprt_retry_reserve - allocate an RPC request slot
1934 struct rpc_xprt *xprt = task->tk_xprt; in xprt_retry_reserve()
1936 task->tk_status = 0; in xprt_retry_reserve()
1937 if (task->tk_rqstp != NULL) in xprt_retry_reserve()
1940 task->tk_status = -EAGAIN; in xprt_retry_reserve()
1945 * xprt_release - release an RPC request slot
1952 struct rpc_rqst *req = task->tk_rqstp; in xprt_release()
1955 if (task->tk_client) { in xprt_release()
1956 xprt = task->tk_xprt; in xprt_release()
1962 xprt = req->rq_xprt; in xprt_release()
1964 spin_lock(&xprt->transport_lock); in xprt_release()
1965 xprt->ops->release_xprt(xprt, task); in xprt_release()
1966 if (xprt->ops->release_request) in xprt_release()
1967 xprt->ops->release_request(task); in xprt_release()
1969 spin_unlock(&xprt->transport_lock); in xprt_release()
1970 if (req->rq_buffer) in xprt_release()
1971 xprt->ops->buf_free(task); in xprt_release()
1972 if (req->rq_cred != NULL) in xprt_release()
1973 put_rpccred(req->rq_cred); in xprt_release()
1974 if (req->rq_release_snd_buf) in xprt_release()
1975 req->rq_release_snd_buf(req); in xprt_release()
1977 task->tk_rqstp = NULL; in xprt_release()
1979 xprt->ops->free_slot(xprt, req); in xprt_release()
1988 struct xdr_buf *xbufp = &req->rq_snd_buf; in xprt_init_bc_request()
1990 task->tk_rqstp = req; in xprt_init_bc_request()
1991 req->rq_task = task; in xprt_init_bc_request()
1992 xprt_init_connect_cookie(req, req->rq_xprt); in xprt_init_bc_request()
1997 xbufp->len = xbufp->head[0].iov_len + xbufp->page_len + in xprt_init_bc_request()
1998 xbufp->tail[0].iov_len; in xprt_init_bc_request()
2004 kref_init(&xprt->kref); in xprt_init()
2006 spin_lock_init(&xprt->transport_lock); in xprt_init()
2007 spin_lock_init(&xprt->reserve_lock); in xprt_init()
2008 spin_lock_init(&xprt->queue_lock); in xprt_init()
2010 INIT_LIST_HEAD(&xprt->free); in xprt_init()
2011 xprt->recv_queue = RB_ROOT; in xprt_init()
2012 INIT_LIST_HEAD(&xprt->xmit_queue); in xprt_init()
2014 spin_lock_init(&xprt->bc_pa_lock); in xprt_init()
2015 INIT_LIST_HEAD(&xprt->bc_pa_list); in xprt_init()
2017 INIT_LIST_HEAD(&xprt->xprt_switch); in xprt_init()
2019 xprt->last_used = jiffies; in xprt_init()
2020 xprt->cwnd = RPC_INITCWND; in xprt_init()
2021 xprt->bind_index = 0; in xprt_init()
2023 rpc_init_wait_queue(&xprt->binding, "xprt_binding"); in xprt_init()
2024 rpc_init_wait_queue(&xprt->pending, "xprt_pending"); in xprt_init()
2025 rpc_init_wait_queue(&xprt->sending, "xprt_sending"); in xprt_init()
2026 rpc_init_priority_wait_queue(&xprt->backlog, "xprt_backlog"); in xprt_init()
2030 xprt->xprt_net = get_net_track(net, &xprt->ns_tracker, GFP_KERNEL); in xprt_init()
2034 * xprt_create_transport - create an RPC transport
2043 t = xprt_class_find_by_ident(args->ident); in xprt_create_transport()
2045 dprintk("RPC: transport (%d) not supported\n", args->ident); in xprt_create_transport()
2046 return ERR_PTR(-EIO); in xprt_create_transport()
2049 xprt = t->setup(args); in xprt_create_transport()
2054 if (args->flags & XPRT_CREATE_NO_IDLE_TIMEOUT) in xprt_create_transport()
2055 xprt->idle_timeout = 0; in xprt_create_transport()
2056 INIT_WORK(&xprt->task_cleanup, xprt_autoclose); in xprt_create_transport()
2058 timer_setup(&xprt->timer, xprt_init_autodisconnect, 0); in xprt_create_transport()
2060 timer_setup(&xprt->timer, NULL, 0); in xprt_create_transport()
2062 if (strlen(args->servername) > RPC_MAXNETNAMELEN) { in xprt_create_transport()
2064 return ERR_PTR(-EINVAL); in xprt_create_transport()
2066 xprt->servername = kstrdup(args->servername, GFP_KERNEL); in xprt_create_transport()
2067 if (xprt->servername == NULL) { in xprt_create_transport()
2069 return ERR_PTR(-ENOMEM); in xprt_create_transport()
2087 rpc_destroy_wait_queue(&xprt->binding); in xprt_destroy_cb()
2088 rpc_destroy_wait_queue(&xprt->pending); in xprt_destroy_cb()
2089 rpc_destroy_wait_queue(&xprt->sending); in xprt_destroy_cb()
2090 rpc_destroy_wait_queue(&xprt->backlog); in xprt_destroy_cb()
2091 kfree(xprt->servername); in xprt_destroy_cb()
2100 xprt->ops->destroy(xprt); in xprt_destroy_cb()
2104 * xprt_destroy - destroy an RPC transport, killing off all requests.
2113 wait_on_bit_lock(&xprt->state, XPRT_LOCKED, TASK_UNINTERRUPTIBLE); in xprt_destroy()
2117 * is cleared. We use ->transport_lock to ensure the mod_timer() in xprt_destroy()
2120 spin_lock(&xprt->transport_lock); in xprt_destroy()
2121 del_timer_sync(&xprt->timer); in xprt_destroy()
2122 spin_unlock(&xprt->transport_lock); in xprt_destroy()
2128 INIT_WORK(&xprt->task_cleanup, xprt_destroy_cb); in xprt_destroy()
2129 schedule_work(&xprt->task_cleanup); in xprt_destroy()
2138 * xprt_get - return a reference to an RPC transport.
2144 if (xprt != NULL && kref_get_unless_zero(&xprt->kref)) in xprt_get()
2151 * xprt_put - release a reference to an RPC transport.
2158 kref_put(&xprt->kref, xprt_destroy_kref); in xprt_put()
2164 if (!test_and_set_bit(XPRT_OFFLINE, &xprt->state)) { in xprt_set_offline_locked()
2165 spin_lock(&xps->xps_lock); in xprt_set_offline_locked()
2166 xps->xps_nactive--; in xprt_set_offline_locked()
2167 spin_unlock(&xps->xps_lock); in xprt_set_offline_locked()
2173 if (test_and_clear_bit(XPRT_OFFLINE, &xprt->state)) { in xprt_set_online_locked()
2174 spin_lock(&xps->xps_lock); in xprt_set_online_locked()
2175 xps->xps_nactive++; in xprt_set_online_locked()
2176 spin_unlock(&xps->xps_lock); in xprt_set_online_locked()
2182 if (test_and_set_bit(XPRT_REMOVE, &xprt->state)) in xprt_delete_locked()
2186 if (!test_bit(XPRT_CONNECTED, &xprt->state)) in xprt_delete_locked()
2189 if (!xprt->sending.qlen && !xprt->pending.qlen && in xprt_delete_locked()
2190 !xprt->backlog.qlen && !atomic_long_read(&xprt->queuelen)) in xprt_delete_locked()