xprt.c (03e075b38e6cd25267c8d6e2797fa4537ca3348d) xprt.c (80b14d5e61ca6d08e46b4fc72baf6e4f738b30ce)
1/*
2 * linux/net/sunrpc/xprt.c
3 *
4 * This is a generic RPC call interface supporting congestion avoidance,
5 * and asynchronous calls.
6 *
7 * The interface works like this:
8 *

--- 34 unchanged lines hidden (view full) ---

43#include <linux/interrupt.h>
44#include <linux/workqueue.h>
45#include <linux/net.h>
46#include <linux/ktime.h>
47
48#include <linux/sunrpc/clnt.h>
49#include <linux/sunrpc/metrics.h>
50#include <linux/sunrpc/bc_xprt.h>
1/*
2 * linux/net/sunrpc/xprt.c
3 *
4 * This is a generic RPC call interface supporting congestion avoidance,
5 * and asynchronous calls.
6 *
7 * The interface works like this:
8 *

--- 34 unchanged lines hidden (view full) ---

43#include <linux/interrupt.h>
44#include <linux/workqueue.h>
45#include <linux/net.h>
46#include <linux/ktime.h>
47
48#include <linux/sunrpc/clnt.h>
49#include <linux/sunrpc/metrics.h>
50#include <linux/sunrpc/bc_xprt.h>
51#include <linux/rcupdate.h>
51
52#include <trace/events/sunrpc.h>
53
54#include "sunrpc.h"
55
56/*
57 * Local variables
58 */

--- 1102 unchanged lines hidden (view full) ---

1161 return NULL;
1162}
1163EXPORT_SYMBOL_GPL(xprt_alloc);
1164
1165void xprt_free(struct rpc_xprt *xprt)
1166{
1167 put_net(xprt->xprt_net);
1168 xprt_free_all_slots(xprt);
52
53#include <trace/events/sunrpc.h>
54
55#include "sunrpc.h"
56
57/*
58 * Local variables
59 */

--- 1102 unchanged lines hidden (view full) ---

1162 return NULL;
1163}
1164EXPORT_SYMBOL_GPL(xprt_alloc);
1165
1166void xprt_free(struct rpc_xprt *xprt)
1167{
1168 put_net(xprt->xprt_net);
1169 xprt_free_all_slots(xprt);
1169 kfree(xprt);
1170 kfree_rcu(xprt, rcu);
1170}
1171EXPORT_SYMBOL_GPL(xprt_free);
1172
1173/**
1174 * xprt_reserve - allocate an RPC request slot
1175 * @task: RPC task requesting a slot allocation
1176 *
1177 * If the transport is marked as being congested, or if no more

--- 124 unchanged lines hidden (view full) ---

1302 if (likely(!bc_prealloc(req)))
1303 xprt_free_slot(xprt, req);
1304 else
1305 xprt_free_bc_request(req);
1306}
1307
1308static void xprt_init(struct rpc_xprt *xprt, struct net *net)
1309{
1171}
1172EXPORT_SYMBOL_GPL(xprt_free);
1173
1174/**
1175 * xprt_reserve - allocate an RPC request slot
1176 * @task: RPC task requesting a slot allocation
1177 *
1178 * If the transport is marked as being congested, or if no more

--- 124 unchanged lines hidden (view full) ---

1303 if (likely(!bc_prealloc(req)))
1304 xprt_free_slot(xprt, req);
1305 else
1306 xprt_free_bc_request(req);
1307}
1308
1309static void xprt_init(struct rpc_xprt *xprt, struct net *net)
1310{
1310 atomic_set(&xprt->count, 1);
1311 kref_init(&xprt->kref);
1311
1312 spin_lock_init(&xprt->transport_lock);
1313 spin_lock_init(&xprt->reserve_lock);
1314
1315 INIT_LIST_HEAD(&xprt->free);
1316 INIT_LIST_HEAD(&xprt->recv);
1317#if defined(CONFIG_SUNRPC_BACKCHANNEL)
1318 spin_lock_init(&xprt->bc_pa_lock);
1319 INIT_LIST_HEAD(&xprt->bc_pa_list);
1320#endif /* CONFIG_SUNRPC_BACKCHANNEL */
1312
1313 spin_lock_init(&xprt->transport_lock);
1314 spin_lock_init(&xprt->reserve_lock);
1315
1316 INIT_LIST_HEAD(&xprt->free);
1317 INIT_LIST_HEAD(&xprt->recv);
1318#if defined(CONFIG_SUNRPC_BACKCHANNEL)
1319 spin_lock_init(&xprt->bc_pa_lock);
1320 INIT_LIST_HEAD(&xprt->bc_pa_list);
1321#endif /* CONFIG_SUNRPC_BACKCHANNEL */
1322 INIT_LIST_HEAD(&xprt->xprt_switch);
1321
1322 xprt->last_used = jiffies;
1323 xprt->cwnd = RPC_INITCWND;
1324 xprt->bind_index = 0;
1325
1326 rpc_init_wait_queue(&xprt->binding, "xprt_binding");
1327 rpc_init_wait_queue(&xprt->pending, "xprt_pending");
1328 rpc_init_priority_wait_queue(&xprt->sending, "xprt_sending");

--- 81 unchanged lines hidden (view full) ---

1410 cancel_work_sync(&xprt->task_cleanup);
1411 kfree(xprt->servername);
1412 /*
1413 * Tear down transport state and free the rpc_xprt
1414 */
1415 xprt->ops->destroy(xprt);
1416}
1417
1323
1324 xprt->last_used = jiffies;
1325 xprt->cwnd = RPC_INITCWND;
1326 xprt->bind_index = 0;
1327
1328 rpc_init_wait_queue(&xprt->binding, "xprt_binding");
1329 rpc_init_wait_queue(&xprt->pending, "xprt_pending");
1330 rpc_init_priority_wait_queue(&xprt->sending, "xprt_sending");

--- 81 unchanged lines hidden (view full) ---

1412 cancel_work_sync(&xprt->task_cleanup);
1413 kfree(xprt->servername);
1414 /*
1415 * Tear down transport state and free the rpc_xprt
1416 */
1417 xprt->ops->destroy(xprt);
1418}
1419
1420static void xprt_destroy_kref(struct kref *kref)
1421{
1422 xprt_destroy(container_of(kref, struct rpc_xprt, kref));
1423}
1424
1418/**
1425/**
1426 * xprt_get - return a reference to an RPC transport.
1427 * @xprt: pointer to the transport
1428 *
1429 */
1430struct rpc_xprt *xprt_get(struct rpc_xprt *xprt)
1431{
1432 if (xprt != NULL && kref_get_unless_zero(&xprt->kref))
1433 return xprt;
1434 return NULL;
1435}
1436EXPORT_SYMBOL_GPL(xprt_get);
1437
1438/**
1419 * xprt_put - release a reference to an RPC transport.
1420 * @xprt: pointer to the transport
1421 *
1422 */
1423void xprt_put(struct rpc_xprt *xprt)
1424{
1439 * xprt_put - release a reference to an RPC transport.
1440 * @xprt: pointer to the transport
1441 *
1442 */
1443void xprt_put(struct rpc_xprt *xprt)
1444{
1425 if (atomic_dec_and_test(&xprt->count))
1426 xprt_destroy(xprt);
1445 if (xprt != NULL)
1446 kref_put(&xprt->kref, xprt_destroy_kref);
1427}
1428EXPORT_SYMBOL_GPL(xprt_put);
1447}
1448EXPORT_SYMBOL_GPL(xprt_put);