Commit 2226feb6 authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

[PATCH] RPC: rename the sockstate field

 Clean-up: get rid of a name reference to sockets in the generic parts of the
 RPC client by renaming the sockstate field in the rpc_xprt structure.

 Test-plan:
 Compile kernel with CONFIG_NFS enabled.

 Version: Thu, 11 Aug 2005 16:05:53 -0400
Signed-off-by: default avatarChuck Lever <cel@netapp.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 5dc07727
...@@ -163,7 +163,7 @@ struct rpc_xprt { ...@@ -163,7 +163,7 @@ struct rpc_xprt {
struct list_head free; /* free slots */ struct list_head free; /* free slots */
struct rpc_rqst * slot; /* slot table storage */ struct rpc_rqst * slot; /* slot table storage */
unsigned int max_reqs; /* total slots */ unsigned int max_reqs; /* total slots */
unsigned long sockstate; /* Socket state */ unsigned long state; /* transport state */
unsigned char shutdown : 1, /* being shut down */ unsigned char shutdown : 1, /* being shut down */
nocong : 1, /* no congestion control */ nocong : 1, /* no congestion control */
resvport : 1, /* use a reserved port */ resvport : 1, /* use a reserved port */
...@@ -240,16 +240,54 @@ int xs_setup_udp(struct rpc_xprt *, ...@@ -240,16 +240,54 @@ int xs_setup_udp(struct rpc_xprt *,
int xs_setup_tcp(struct rpc_xprt *, int xs_setup_tcp(struct rpc_xprt *,
struct rpc_timeout *); struct rpc_timeout *);
#define XPRT_LOCKED 0 /*
#define XPRT_CONNECT 1 * Reserved bit positions in xprt->state
#define XPRT_CONNECTING 2 */
#define XPRT_LOCKED (0)
#define xprt_connected(xp) (test_bit(XPRT_CONNECT, &(xp)->sockstate)) #define XPRT_CONNECTED (1)
#define xprt_set_connected(xp) (set_bit(XPRT_CONNECT, &(xp)->sockstate)) #define XPRT_CONNECTING (2)
#define xprt_test_and_set_connected(xp) (test_and_set_bit(XPRT_CONNECT, &(xp)->sockstate))
#define xprt_test_and_clear_connected(xp) \ static inline void xprt_set_connected(struct rpc_xprt *xprt)
(test_and_clear_bit(XPRT_CONNECT, &(xp)->sockstate)) {
#define xprt_clear_connected(xp) (clear_bit(XPRT_CONNECT, &(xp)->sockstate)) set_bit(XPRT_CONNECTED, &xprt->state);
}
static inline void xprt_clear_connected(struct rpc_xprt *xprt)
{
clear_bit(XPRT_CONNECTED, &xprt->state);
}
static inline int xprt_connected(struct rpc_xprt *xprt)
{
return test_bit(XPRT_CONNECTED, &xprt->state);
}
static inline int xprt_test_and_set_connected(struct rpc_xprt *xprt)
{
return test_and_set_bit(XPRT_CONNECTED, &xprt->state);
}
static inline int xprt_test_and_clear_connected(struct rpc_xprt *xprt)
{
return test_and_clear_bit(XPRT_CONNECTED, &xprt->state);
}
static inline void xprt_clear_connecting(struct rpc_xprt *xprt)
{
smp_mb__before_clear_bit();
clear_bit(XPRT_CONNECTING, &xprt->state);
smp_mb__after_clear_bit();
}
static inline int xprt_connecting(struct rpc_xprt *xprt)
{
return test_bit(XPRT_CONNECTING, &xprt->state);
}
static inline int xprt_test_and_set_connecting(struct rpc_xprt *xprt)
{
return test_and_set_bit(XPRT_CONNECTING, &xprt->state);
}
#endif /* __KERNEL__*/ #endif /* __KERNEL__*/
......
...@@ -74,7 +74,7 @@ __xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task) ...@@ -74,7 +74,7 @@ __xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task)
{ {
struct rpc_rqst *req = task->tk_rqstp; struct rpc_rqst *req = task->tk_rqstp;
if (test_and_set_bit(XPRT_LOCKED, &xprt->sockstate)) { if (test_and_set_bit(XPRT_LOCKED, &xprt->state)) {
if (task == xprt->snd_task) if (task == xprt->snd_task)
return 1; return 1;
goto out_sleep; goto out_sleep;
...@@ -88,7 +88,7 @@ __xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task) ...@@ -88,7 +88,7 @@ __xprt_lock_write(struct rpc_xprt *xprt, struct rpc_task *task)
return 1; return 1;
} }
smp_mb__before_clear_bit(); smp_mb__before_clear_bit();
clear_bit(XPRT_LOCKED, &xprt->sockstate); clear_bit(XPRT_LOCKED, &xprt->state);
smp_mb__after_clear_bit(); smp_mb__after_clear_bit();
out_sleep: out_sleep:
dprintk("RPC: %4d failed to lock socket %p\n", task->tk_pid, xprt); dprintk("RPC: %4d failed to lock socket %p\n", task->tk_pid, xprt);
...@@ -118,7 +118,7 @@ __xprt_lock_write_next(struct rpc_xprt *xprt) ...@@ -118,7 +118,7 @@ __xprt_lock_write_next(struct rpc_xprt *xprt)
{ {
struct rpc_task *task; struct rpc_task *task;
if (test_and_set_bit(XPRT_LOCKED, &xprt->sockstate)) if (test_and_set_bit(XPRT_LOCKED, &xprt->state))
return; return;
if (!xprt->nocong && RPCXPRT_CONGESTED(xprt)) if (!xprt->nocong && RPCXPRT_CONGESTED(xprt))
goto out_unlock; goto out_unlock;
...@@ -139,7 +139,7 @@ __xprt_lock_write_next(struct rpc_xprt *xprt) ...@@ -139,7 +139,7 @@ __xprt_lock_write_next(struct rpc_xprt *xprt)
} }
out_unlock: out_unlock:
smp_mb__before_clear_bit(); smp_mb__before_clear_bit();
clear_bit(XPRT_LOCKED, &xprt->sockstate); clear_bit(XPRT_LOCKED, &xprt->state);
smp_mb__after_clear_bit(); smp_mb__after_clear_bit();
} }
...@@ -152,7 +152,7 @@ __xprt_release_write(struct rpc_xprt *xprt, struct rpc_task *task) ...@@ -152,7 +152,7 @@ __xprt_release_write(struct rpc_xprt *xprt, struct rpc_task *task)
if (xprt->snd_task == task) { if (xprt->snd_task == task) {
xprt->snd_task = NULL; xprt->snd_task = NULL;
smp_mb__before_clear_bit(); smp_mb__before_clear_bit();
clear_bit(XPRT_LOCKED, &xprt->sockstate); clear_bit(XPRT_LOCKED, &xprt->state);
smp_mb__after_clear_bit(); smp_mb__after_clear_bit();
__xprt_lock_write_next(xprt); __xprt_lock_write_next(xprt);
} }
...@@ -312,11 +312,11 @@ xprt_init_autodisconnect(unsigned long data) ...@@ -312,11 +312,11 @@ xprt_init_autodisconnect(unsigned long data)
spin_lock(&xprt->transport_lock); spin_lock(&xprt->transport_lock);
if (!list_empty(&xprt->recv) || xprt->shutdown) if (!list_empty(&xprt->recv) || xprt->shutdown)
goto out_abort; goto out_abort;
if (test_and_set_bit(XPRT_LOCKED, &xprt->sockstate)) if (test_and_set_bit(XPRT_LOCKED, &xprt->state))
goto out_abort; goto out_abort;
spin_unlock(&xprt->transport_lock); spin_unlock(&xprt->transport_lock);
/* Let keventd close the socket */ /* Let keventd close the socket */
if (test_bit(XPRT_CONNECTING, &xprt->sockstate) != 0) if (xprt_connecting(xprt))
xprt_release_write(xprt, NULL); xprt_release_write(xprt, NULL);
else else
schedule_work(&xprt->task_cleanup); schedule_work(&xprt->task_cleanup);
......
...@@ -925,9 +925,7 @@ static void xs_connect_worker(void *args) ...@@ -925,9 +925,7 @@ static void xs_connect_worker(void *args)
else else
rpc_wake_up(&xprt->pending); rpc_wake_up(&xprt->pending);
out_clear: out_clear:
smp_mb__before_clear_bit(); xprt_clear_connecting(xprt);
clear_bit(XPRT_CONNECTING, &xprt->sockstate);
smp_mb__after_clear_bit();
} }
/** /**
...@@ -940,7 +938,7 @@ static void xs_connect(struct rpc_task *task) ...@@ -940,7 +938,7 @@ static void xs_connect(struct rpc_task *task)
{ {
struct rpc_xprt *xprt = task->tk_xprt; struct rpc_xprt *xprt = task->tk_xprt;
if (!test_and_set_bit(XPRT_CONNECTING, &xprt->sockstate)) { if (!xprt_test_and_set_connecting(xprt)) {
if (xprt->sock != NULL) { if (xprt->sock != NULL) {
dprintk("RPC: xs_connect delayed xprt %p\n", xprt); dprintk("RPC: xs_connect delayed xprt %p\n", xprt);
schedule_delayed_work(&xprt->sock_connect, schedule_delayed_work(&xprt->sock_connect,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment