From: Tom Tucker <tom@opengridcomputing.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 21/40] svc: Make the enqueue service transport neutral and export it.
Date: Sun, 30 Dec 2007 21:07:57 -0600 [thread overview]
Message-ID: <20071231030757.8430.59754.stgit@dell3.ogc.int> (raw)
In-Reply-To: <20071231030712.8430.45576.stgit-gUwIgmpLGaKNDNWfRnPdfg@public.gmane.org>
The svc_sock_enqueue function is now transport independent since all of
the fields it touches have been moved to the transport independent svc_xprt
structure. Change the function to use the svc_xprt structure directly
instead of the transport specific svc_sock structure.
Transport specific data-ready handlers need to call this function, so
export it.
Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---
net/sunrpc/svcsock.c | 94 ++++++++++++++++++++++++++------------------------
1 files changed, 48 insertions(+), 46 deletions(-)
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index ec5ad81..f356c02 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -5,7 +5,7 @@
*
* The server scheduling algorithm does not always distribute the load
* evenly when servicing a single client. May need to modify the
- * svc_sock_enqueue procedure...
+ * svc_xprt_enqueue procedure...
*
* TCP support is largely untested and may be a little slow. The problem
* is that we currently do two separate recvfrom's, one for the 4-byte
@@ -63,7 +63,7 @@
* providing that certain rules are followed:
*
* XPT_CONN, XPT_DATA, can be set or cleared at any time.
- * after a set, svc_sock_enqueue must be called.
+ * after a set, svc_xprt_enqueue must be called.
* after a clear, the socket must be read/accepted
* if this succeeds, it must be set again.
* XPT_CLOSE can set at any time. It is never cleared.
@@ -212,22 +212,21 @@ static void svc_release_skb(struct svc_rqst *rqstp)
* processes, wake 'em up.
*
*/
-static void
-svc_sock_enqueue(struct svc_sock *svsk)
+void svc_xprt_enqueue(struct svc_xprt *xprt)
{
- struct svc_serv *serv = svsk->sk_xprt.xpt_server;
+ struct svc_serv *serv = xprt->xpt_server;
struct svc_pool *pool;
struct svc_rqst *rqstp;
int cpu;
- if (!(svsk->sk_xprt.xpt_flags &
+ if (!(xprt->xpt_flags &
((1<<XPT_CONN)|(1<<XPT_DATA)|(1<<XPT_CLOSE)|(1<<XPT_DEFERRED))))
return;
- if (test_bit(XPT_DEAD, &svsk->sk_xprt.xpt_flags))
+ if (test_bit(XPT_DEAD, &xprt->xpt_flags))
return;
cpu = get_cpu();
- pool = svc_pool_for_cpu(svsk->sk_xprt.xpt_server, cpu);
+ pool = svc_pool_for_cpu(xprt->xpt_server, cpu);
put_cpu();
spin_lock_bh(&pool->sp_lock);
@@ -235,11 +234,12 @@ svc_sock_enqueue(struct svc_sock *svsk)
if (!list_empty(&pool->sp_threads) &&
!list_empty(&pool->sp_sockets))
printk(KERN_ERR
- "svc_sock_enqueue: threads and sockets both waiting??\n");
+ "svc_xprt_enqueue: "
+ "threads and transports both waiting??\n");
- if (test_bit(XPT_DEAD, &svsk->sk_xprt.xpt_flags)) {
+ if (test_bit(XPT_DEAD, &xprt->xpt_flags)) {
/* Don't enqueue dead sockets */
- dprintk("svc: socket %p is dead, not enqueued\n", svsk->sk_sk);
+ dprintk("svc: transport %p is dead, not enqueued\n", xprt);
goto out_unlock;
}
@@ -248,28 +248,29 @@ svc_sock_enqueue(struct svc_sock *svsk)
* on the idle list. We update XPT_BUSY atomically because
* it also guards against trying to enqueue the svc_sock twice.
*/
- if (test_and_set_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags)) {
+ if (test_and_set_bit(XPT_BUSY, &xprt->xpt_flags)) {
/* Don't enqueue socket while already enqueued */
- dprintk("svc: socket %p busy, not enqueued\n", svsk->sk_sk);
+ dprintk("svc: transport %p busy, not enqueued\n", xprt);
goto out_unlock;
}
- BUG_ON(svsk->sk_xprt.xpt_pool != NULL);
- svsk->sk_xprt.xpt_pool = pool;
+ BUG_ON(xprt->xpt_pool != NULL);
+ xprt->xpt_pool = pool;
/* Handle pending connection */
- if (test_bit(XPT_CONN, &svsk->sk_xprt.xpt_flags))
+ if (test_bit(XPT_CONN, &xprt->xpt_flags))
goto process;
/* Handle close in-progress */
- if (test_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags))
+ if (test_bit(XPT_CLOSE, &xprt->xpt_flags))
goto process;
/* Check if we have space to reply to a request */
- if (!svsk->sk_xprt.xpt_ops->xpo_has_wspace(&svsk->sk_xprt)) {
+ if (!xprt->xpt_ops->xpo_has_wspace(xprt)) {
/* Don't enqueue while not enough space for reply */
- dprintk("svc: no write space, socket %p not enqueued\n", svsk);
- svsk->sk_xprt.xpt_pool = NULL;
- clear_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags);
+ dprintk("svc: no write space, transport %p not enqueued\n",
+ xprt);
+ xprt->xpt_pool = NULL;
+ clear_bit(XPT_BUSY, &xprt->xpt_flags);
goto out_unlock;
}
@@ -278,28 +279,29 @@ svc_sock_enqueue(struct svc_sock *svsk)
rqstp = list_entry(pool->sp_threads.next,
struct svc_rqst,
rq_list);
- dprintk("svc: socket %p served by daemon %p\n",
- svsk->sk_sk, rqstp);
+ dprintk("svc: transport %p served by daemon %p\n",
+ xprt, rqstp);
svc_thread_dequeue(pool, rqstp);
- if (rqstp->rq_sock)
+ if (rqstp->rq_xprt)
printk(KERN_ERR
- "svc_sock_enqueue: server %p, rq_sock=%p!\n",
- rqstp, rqstp->rq_sock);
- rqstp->rq_sock = svsk;
- svc_xprt_get(&svsk->sk_xprt);
+ "svc_xprt_enqueue: server %p, rq_xprt=%p!\n",
+ rqstp, rqstp->rq_xprt);
+ rqstp->rq_xprt = xprt;
+ svc_xprt_get(xprt);
rqstp->rq_reserved = serv->sv_max_mesg;
- atomic_add(rqstp->rq_reserved, &svsk->sk_xprt.xpt_reserved);
- BUG_ON(svsk->sk_xprt.xpt_pool != pool);
+ atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved);
+ BUG_ON(xprt->xpt_pool != pool);
wake_up(&rqstp->rq_wait);
} else {
- dprintk("svc: socket %p put into queue\n", svsk->sk_sk);
- list_add_tail(&svsk->sk_xprt.xpt_ready, &pool->sp_sockets);
- BUG_ON(svsk->sk_xprt.xpt_pool != pool);
+ dprintk("svc: transport %p put into queue\n", xprt);
+ list_add_tail(&xprt->xpt_ready, &pool->sp_sockets);
+ BUG_ON(xprt->xpt_pool != pool);
}
out_unlock:
spin_unlock_bh(&pool->sp_lock);
}
+EXPORT_SYMBOL_GPL(svc_xprt_enqueue);
/*
* Dequeue the first socket. Must be called with the pool->sp_lock held.
@@ -333,7 +335,7 @@ svc_sock_received(struct svc_sock *svsk)
{
svsk->sk_xprt.xpt_pool = NULL;
clear_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags);
- svc_sock_enqueue(svsk);
+ svc_xprt_enqueue(&svsk->sk_xprt);
}
@@ -352,11 +354,11 @@ void svc_reserve(struct svc_rqst *rqstp, int space)
space += rqstp->rq_res.head[0].iov_len;
if (space < rqstp->rq_reserved) {
- struct svc_sock *svsk = rqstp->rq_sock;
- atomic_sub((rqstp->rq_reserved - space), &svsk->sk_xprt.xpt_reserved);
+ struct svc_xprt *xprt = rqstp->rq_xprt;
+ atomic_sub((rqstp->rq_reserved - space), &xprt->xpt_reserved);
rqstp->rq_reserved = space;
- svc_sock_enqueue(svsk);
+ svc_xprt_enqueue(xprt);
}
}
@@ -684,7 +686,7 @@ svc_udp_data_ready(struct sock *sk, int count)
svsk, sk, count,
test_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags));
set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
- svc_sock_enqueue(svsk);
+ svc_xprt_enqueue(&svsk->sk_xprt);
}
if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
wake_up_interruptible(sk->sk_sleep);
@@ -701,7 +703,7 @@ svc_write_space(struct sock *sk)
if (svsk) {
dprintk("svc: socket %p(inet %p), write_space busy=%d\n",
svsk, sk, test_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags));
- svc_sock_enqueue(svsk);
+ svc_xprt_enqueue(&svsk->sk_xprt);
}
if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) {
@@ -973,7 +975,7 @@ svc_tcp_listen_data_ready(struct sock *sk, int count_unused)
if (sk->sk_state == TCP_LISTEN) {
if (svsk) {
set_bit(XPT_CONN, &svsk->sk_xprt.xpt_flags);
- svc_sock_enqueue(svsk);
+ svc_xprt_enqueue(&svsk->sk_xprt);
} else
printk("svc: socket %p: no user data\n", sk);
}
@@ -997,7 +999,7 @@ svc_tcp_state_change(struct sock *sk)
printk("svc: socket %p: no user data\n", sk);
else {
set_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags);
- svc_sock_enqueue(svsk);
+ svc_xprt_enqueue(&svsk->sk_xprt);
}
if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
wake_up_interruptible_all(sk->sk_sleep);
@@ -1012,7 +1014,7 @@ svc_tcp_data_ready(struct sock *sk, int count)
sk, sk->sk_user_data);
if (svsk) {
set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
- svc_sock_enqueue(svsk);
+ svc_xprt_enqueue(&svsk->sk_xprt);
}
if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
wake_up_interruptible(sk->sk_sleep);
@@ -1298,7 +1300,7 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
(sent<0)?"got error":"sent only",
sent, xbufp->len);
set_bit(XPT_CLOSE, &rqstp->rq_sock->sk_xprt.xpt_flags);
- svc_sock_enqueue(rqstp->rq_sock);
+ svc_xprt_enqueue(rqstp->rq_xprt);
sent = -EAGAIN;
}
return sent;
@@ -1476,7 +1478,7 @@ static void svc_check_conn_limits(struct svc_serv *serv)
spin_unlock_bh(&serv->sv_lock);
if (svsk) {
- svc_sock_enqueue(svsk);
+ svc_xprt_enqueue(&svsk->sk_xprt);
svc_xprt_put(&svsk->sk_xprt);
}
}
@@ -1709,7 +1711,7 @@ svc_age_temp_sockets(unsigned long closure)
svsk, get_seconds() - svsk->sk_lastrecv);
/* a thread will dequeue and close it soon */
- svc_sock_enqueue(svsk);
+ svc_xprt_enqueue(&svsk->sk_xprt);
svc_xprt_put(&svsk->sk_xprt);
}
@@ -1991,7 +1993,7 @@ static void svc_revisit(struct cache_deferred_req *dreq, int too_many)
list_add(&dr->handle.recent, &svsk->sk_deferred);
spin_unlock(&svsk->sk_lock);
set_bit(XPT_DEFERRED, &svsk->sk_xprt.xpt_flags);
- svc_sock_enqueue(svsk);
+ svc_xprt_enqueue(&svsk->sk_xprt);
svc_xprt_put(&svsk->sk_xprt);
}
next prev parent reply other threads:[~2007-12-31 3:07 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-31 3:07 [PATCH 00/40] svc: SVC Transport Switch Tom Tucker
[not found] ` <20071231030712.8430.45576.stgit-gUwIgmpLGaKNDNWfRnPdfg@public.gmane.org>
2007-12-31 3:07 ` [PATCH 01/40] svc: Add an svc transport class Tom Tucker
2007-12-31 3:07 ` [PATCH 02/40] svc: Make svc_sock the tcp/udp transport Tom Tucker
2007-12-31 3:07 ` [PATCH 03/40] svc: Change the svc_sock in the rqstp structure to a transport Tom Tucker
2007-12-31 3:07 ` [PATCH 04/40] svc: Add a max payload value to the transport Tom Tucker
2007-12-31 3:07 ` [PATCH 05/40] svc: Move sk_sendto and sk_recvfrom to svc_xprt_class Tom Tucker
2007-12-31 3:07 ` [PATCH 06/40] svc: Add transport specific xpo_release function Tom Tucker
2007-12-31 3:07 ` [PATCH 07/40] svc: Add per-transport delete functions Tom Tucker
2007-12-31 3:07 ` [PATCH 08/40] svc: Add xpo_prep_reply_hdr Tom Tucker
2007-12-31 3:07 ` [PATCH 09/40] svc: Add a transport function that checks for write space Tom Tucker
2007-12-31 3:07 ` [PATCH 10/40] svc: Move close processing to a single place Tom Tucker
2007-12-31 3:07 ` [PATCH 11/40] svc: Add xpo_accept transport function Tom Tucker
2007-12-31 3:07 ` [PATCH 12/40] svc: Remove unnecessary call to svc_sock_enqueue Tom Tucker
2007-12-31 3:07 ` [PATCH 13/40] svc: Move connection limit checking to its own function Tom Tucker
2007-12-31 3:07 ` [PATCH 14/40] svc: Add a generic transport svc_create_xprt function Tom Tucker
2007-12-31 3:07 ` [PATCH 15/40] svc: Change services to use new svc_create_xprt service Tom Tucker
2007-12-31 3:07 ` [PATCH 16/40] svc: Change sk_inuse to a kref Tom Tucker
2007-12-31 3:07 ` [PATCH 17/40] svc: Move sk_flags to the svc_xprt structure Tom Tucker
2007-12-31 3:07 ` [PATCH 18/40] svc: Move sk_server and sk_pool to svc_xprt Tom Tucker
2007-12-31 3:07 ` [PATCH 19/40] svc: Make close transport independent Tom Tucker
2007-12-31 3:07 ` [PATCH 20/40] svc: Move sk_reserved to svc_xprt Tom Tucker
2007-12-31 3:07 ` Tom Tucker [this message]
2007-12-31 3:07 ` [PATCH 22/40] svc: Make svc_send transport neutral Tom Tucker
2007-12-31 3:08 ` [PATCH 23/40] svc: Change svc_sock_received to svc_xprt_received and export it Tom Tucker
2007-12-31 3:08 ` [PATCH 24/40] svc: Move accept call to svc_xprt_received to common code Tom Tucker
2007-12-31 3:08 ` [PATCH 25/40] svc: Remove sk_lastrecv Tom Tucker
2007-12-31 3:08 ` [PATCH 26/40] svc: Move the authinfo cache to svc_xprt Tom Tucker
2007-12-31 3:08 ` [PATCH 27/40] svc: Make deferral processing xprt independent Tom Tucker
2007-12-31 3:08 ` [PATCH 28/40] svc: Move the sockaddr information to svc_xprt Tom Tucker
2007-12-31 3:08 ` [PATCH 29/40] svc: Make svc_sock_release svc_xprt_release Tom Tucker
2007-12-31 3:08 ` [PATCH 30/40] svc: Make svc_recv transport neutral Tom Tucker
2007-12-31 3:08 ` [PATCH 31/40] svc: Make svc_age_temp_sockets svc_age_temp_transports Tom Tucker
2007-12-31 3:08 ` [PATCH 32/40] svc: Move create logic to common code Tom Tucker
2007-12-31 3:08 ` [PATCH 33/40] svc: Removing remaining references to rq_sock in rqstp Tom Tucker
2007-12-31 3:08 ` [PATCH 34/40] svc: Make svc_check_conn_limits xprt independent Tom Tucker
2007-12-31 3:08 ` [PATCH 35/40] svc: Move the xprt independent code to the svc_xprt.c file Tom Tucker
[not found] ` <20071231030827.8430.76850.stgit-gUwIgmpLGaKNDNWfRnPdfg@public.gmane.org>
2007-12-31 22:14 ` J. Bruce Fields
2007-12-31 3:08 ` [PATCH 36/40] svc: Add transport hdr size for defer/revisit Tom Tucker
2007-12-31 3:08 ` [PATCH 37/40] svc: Add /proc/sys/sunrpc/transport files Tom Tucker
2007-12-31 3:08 ` [PATCH 38/40] svc: Add svc API that queries for a transport instance Tom Tucker
2007-12-31 3:08 ` [PATCH 39/40] knfsd: Support adding transports by writing portlist file Tom Tucker
2007-12-31 3:08 ` [PATCH 40/40] svc: Add svc_xprt_names service to replace svc_sock_names Tom Tucker
2007-12-31 22:13 ` [PATCH 00/40] svc: SVC Transport Switch J. Bruce Fields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071231030757.8430.59754.stgit@dell3.ogc.int \
--to=tom@opengridcomputing.com \
--cc=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.