aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Tucker <tom@opengridcomputing.com>2007-12-30 22:07:59 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2008-02-01 16:42:11 -0500
commita50fea26b9d2aa7b66fdd6d9579de10827ec086a (patch)
treeefb7893e6e45b417405e9320d3b82100b1684daf
parentf6150c3cab6e788afacb07470be3c6b4a722f1ed (diff)
svc: Make svc_send transport neutral
Move the sk_mutex field to the transport independent svc_xprt structure. Now all the fields that svc_send touches are transport neutral. Change the svc_send function to use the transport independent svc_xprt directly instead of the transport dependent svc_sock structure. Signed-off-by: Tom Tucker <tom@opengridcomputing.com> Acked-by: Neil Brown <neilb@suse.de> Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Greg Banks <gnb@sgi.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
-rw-r--r--include/linux/sunrpc/svc_xprt.h1
-rw-r--r--include/linux/sunrpc/svcsock.h1
-rw-r--r--net/sunrpc/svc_xprt.c1
-rw-r--r--net/sunrpc/svcsock.c19
4 files changed, 10 insertions, 12 deletions
diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
index 0b8ee06f99c0..1b8c596b1177 100644
--- a/include/linux/sunrpc/svc_xprt.h
+++ b/include/linux/sunrpc/svc_xprt.h
@@ -54,6 +54,7 @@ struct svc_xprt {
54 struct svc_pool *xpt_pool; /* current pool iff queued */ 54 struct svc_pool *xpt_pool; /* current pool iff queued */
55 struct svc_serv *xpt_server; /* service for transport */ 55 struct svc_serv *xpt_server; /* service for transport */
56 atomic_t xpt_reserved; /* space on outq that is rsvd */ 56 atomic_t xpt_reserved; /* space on outq that is rsvd */
57 struct mutex xpt_mutex; /* to serialize sending data */
57}; 58};
58 59
59int svc_reg_xprt_class(struct svc_xprt_class *); 60int svc_reg_xprt_class(struct svc_xprt_class *);
diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index ba41f11788f2..41c2dfaf7371 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -24,7 +24,6 @@ struct svc_sock {
24 * sk_info_authunix */ 24 * sk_info_authunix */
25 struct list_head sk_deferred; /* deferred requests that need to 25 struct list_head sk_deferred; /* deferred requests that need to
26 * be revisted */ 26 * be revisted */
27 struct mutex sk_mutex; /* to serialize sending data */
28 27
29 /* We keep the old state_change and data_ready CB's here */ 28 /* We keep the old state_change and data_ready CB's here */
30 void (*sk_ostate)(struct sock *); 29 void (*sk_ostate)(struct sock *);
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 95186b548099..3e6a1c81d4ce 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -99,6 +99,7 @@ void svc_xprt_init(struct svc_xprt_class *xcl, struct svc_xprt *xprt,
99 xprt->xpt_server = serv; 99 xprt->xpt_server = serv;
100 INIT_LIST_HEAD(&xprt->xpt_list); 100 INIT_LIST_HEAD(&xprt->xpt_list);
101 INIT_LIST_HEAD(&xprt->xpt_ready); 101 INIT_LIST_HEAD(&xprt->xpt_ready);
102 mutex_init(&xprt->xpt_mutex);
102} 103}
103EXPORT_SYMBOL_GPL(svc_xprt_init); 104EXPORT_SYMBOL_GPL(svc_xprt_init);
104 105
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index d95a0c894d4f..2016d9c63f88 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1632,15 +1632,13 @@ svc_drop(struct svc_rqst *rqstp)
1632int 1632int
1633svc_send(struct svc_rqst *rqstp) 1633svc_send(struct svc_rqst *rqstp)
1634{ 1634{
1635 struct svc_sock *svsk; 1635 struct svc_xprt *xprt;
1636 int len; 1636 int len;
1637 struct xdr_buf *xb; 1637 struct xdr_buf *xb;
1638 1638
1639 if ((svsk = rqstp->rq_sock) == NULL) { 1639 xprt = rqstp->rq_xprt;
1640 printk(KERN_WARNING "NULL socket pointer in %s:%d\n", 1640 if (!xprt)
1641 __FILE__, __LINE__);
1642 return -EFAULT; 1641 return -EFAULT;
1643 }
1644 1642
1645 /* release the receive skb before sending the reply */ 1643 /* release the receive skb before sending the reply */
1646 rqstp->rq_xprt->xpt_ops->xpo_release_rqst(rqstp); 1644 rqstp->rq_xprt->xpt_ops->xpo_release_rqst(rqstp);
@@ -1651,13 +1649,13 @@ svc_send(struct svc_rqst *rqstp)
1651 xb->page_len + 1649 xb->page_len +
1652 xb->tail[0].iov_len; 1650 xb->tail[0].iov_len;
1653 1651
1654 /* Grab svsk->sk_mutex to serialize outgoing data. */ 1652 /* Grab mutex to serialize outgoing data. */
1655 mutex_lock(&svsk->sk_mutex); 1653 mutex_lock(&xprt->xpt_mutex);
1656 if (test_bit(XPT_DEAD, &svsk->sk_xprt.xpt_flags)) 1654 if (test_bit(XPT_DEAD, &xprt->xpt_flags))
1657 len = -ENOTCONN; 1655 len = -ENOTCONN;
1658 else 1656 else
1659 len = svsk->sk_xprt.xpt_ops->xpo_sendto(rqstp); 1657 len = xprt->xpt_ops->xpo_sendto(rqstp);
1660 mutex_unlock(&svsk->sk_mutex); 1658 mutex_unlock(&xprt->xpt_mutex);
1661 svc_sock_release(rqstp); 1659 svc_sock_release(rqstp);
1662 1660
1663 if (len == -ECONNREFUSED || len == -ENOTCONN || len == -EAGAIN) 1661 if (len == -ECONNREFUSED || len == -ENOTCONN || len == -EAGAIN)
@@ -1759,7 +1757,6 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
1759 svsk->sk_lastrecv = get_seconds(); 1757 svsk->sk_lastrecv = get_seconds();
1760 spin_lock_init(&svsk->sk_lock); 1758 spin_lock_init(&svsk->sk_lock);
1761 INIT_LIST_HEAD(&svsk->sk_deferred); 1759 INIT_LIST_HEAD(&svsk->sk_deferred);
1762 mutex_init(&svsk->sk_mutex);
1763 1760
1764 /* Initialize the socket */ 1761 /* Initialize the socket */
1765 if (sock->type == SOCK_DGRAM) 1762 if (sock->type == SOCK_DGRAM)