Commit a6046f71 authored by Tom Tucker's avatar Tom Tucker Committed by J. Bruce Fields

svc: Change svc_sock_received to svc_xprt_received and export it

All fields touched by svc_sock_received are now transport independent.
Change it to use svc_xprt directly. This function is called from
transport dependent code, so export it.

Update the comment to clearly state the rules for calling this function.
Signed-off-by: default avatarTom Tucker <tom@opengridcomputing.com>
Acked-by: default avatarNeil Brown <neilb@suse.de>
Reviewed-by: default avatarChuck Lever <chuck.lever@oracle.com>
Reviewed-by: default avatarGreg Banks <gnb@sgi.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
parent a50fea26
...@@ -62,8 +62,8 @@ void svc_unreg_xprt_class(struct svc_xprt_class *); ...@@ -62,8 +62,8 @@ void svc_unreg_xprt_class(struct svc_xprt_class *);
void svc_xprt_init(struct svc_xprt_class *, struct svc_xprt *, void svc_xprt_init(struct svc_xprt_class *, struct svc_xprt *,
struct svc_serv *); struct svc_serv *);
int svc_create_xprt(struct svc_serv *, char *, unsigned short, int); int svc_create_xprt(struct svc_serv *, char *, unsigned short, int);
void svc_xprt_received(struct svc_xprt *);
void svc_xprt_put(struct svc_xprt *xprt); void svc_xprt_put(struct svc_xprt *xprt);
static inline void svc_xprt_get(struct svc_xprt *xprt) static inline void svc_xprt_get(struct svc_xprt *xprt)
{ {
kref_get(&xprt->xpt_ref); kref_get(&xprt->xpt_ref);
......
...@@ -325,19 +325,21 @@ svc_sock_dequeue(struct svc_pool *pool) ...@@ -325,19 +325,21 @@ svc_sock_dequeue(struct svc_pool *pool)
} }
/* /*
* Having read something from a socket, check whether it * svc_xprt_received conditionally queues the transport for processing
* needs to be re-enqueued. * by another thread. The caller must hold the XPT_BUSY bit and must
* Note: XPT_DATA only gets cleared when a read-attempt finds * not thereafter touch transport data.
* no (or insufficient) data. *
* Note: XPT_DATA only gets cleared when a read-attempt finds no (or
* insufficient) data.
*/ */
static inline void void svc_xprt_received(struct svc_xprt *xprt)
svc_sock_received(struct svc_sock *svsk)
{ {
svsk->sk_xprt.xpt_pool = NULL; BUG_ON(!test_bit(XPT_BUSY, &xprt->xpt_flags));
clear_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags); xprt->xpt_pool = NULL;
svc_xprt_enqueue(&svsk->sk_xprt); clear_bit(XPT_BUSY, &xprt->xpt_flags);
svc_xprt_enqueue(xprt);
} }
EXPORT_SYMBOL_GPL(svc_xprt_received);
/** /**
* svc_reserve - change the space reserved for the reply to a request. * svc_reserve - change the space reserved for the reply to a request.
...@@ -766,7 +768,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) ...@@ -766,7 +768,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
(serv->sv_nrthreads+3) * serv->sv_max_mesg); (serv->sv_nrthreads+3) * serv->sv_max_mesg);
if ((rqstp->rq_deferred = svc_deferred_dequeue(svsk))) { if ((rqstp->rq_deferred = svc_deferred_dequeue(svsk))) {
svc_sock_received(svsk); svc_xprt_received(&svsk->sk_xprt);
return svc_deferred_recv(rqstp); return svc_deferred_recv(rqstp);
} }
...@@ -783,7 +785,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) ...@@ -783,7 +785,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
dprintk("svc: recvfrom returned error %d\n", -err); dprintk("svc: recvfrom returned error %d\n", -err);
set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags); set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
} }
svc_sock_received(svsk); svc_xprt_received(&svsk->sk_xprt);
return -EAGAIN; return -EAGAIN;
} }
rqstp->rq_addrlen = sizeof(rqstp->rq_addr); rqstp->rq_addrlen = sizeof(rqstp->rq_addr);
...@@ -798,7 +800,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp) ...@@ -798,7 +800,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
/* /*
* Maybe more packets - kick another thread ASAP. * Maybe more packets - kick another thread ASAP.
*/ */
svc_sock_received(svsk); svc_xprt_received(&svsk->sk_xprt);
len = skb->len - sizeof(struct udphdr); len = skb->len - sizeof(struct udphdr);
rqstp->rq_arg.len = len; rqstp->rq_arg.len = len;
...@@ -1104,7 +1106,7 @@ static struct svc_xprt *svc_tcp_accept(struct svc_xprt *xprt) ...@@ -1104,7 +1106,7 @@ static struct svc_xprt *svc_tcp_accept(struct svc_xprt *xprt)
} }
memcpy(&newsvsk->sk_local, sin, slen); memcpy(&newsvsk->sk_local, sin, slen);
svc_sock_received(newsvsk); svc_xprt_received(&newsvsk->sk_xprt);
if (serv->sv_stats) if (serv->sv_stats)
serv->sv_stats->nettcpconn++; serv->sv_stats->nettcpconn++;
...@@ -1134,7 +1136,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp) ...@@ -1134,7 +1136,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
test_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags)); test_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags));
if ((rqstp->rq_deferred = svc_deferred_dequeue(svsk))) { if ((rqstp->rq_deferred = svc_deferred_dequeue(svsk))) {
svc_sock_received(svsk); svc_xprt_received(&svsk->sk_xprt);
return svc_deferred_recv(rqstp); return svc_deferred_recv(rqstp);
} }
...@@ -1174,7 +1176,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp) ...@@ -1174,7 +1176,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
if (len < want) { if (len < want) {
dprintk("svc: short recvfrom while reading record length (%d of %lu)\n", dprintk("svc: short recvfrom while reading record length (%d of %lu)\n",
len, want); len, want);
svc_sock_received(svsk); svc_xprt_received(&svsk->sk_xprt);
return -EAGAIN; /* record header not complete */ return -EAGAIN; /* record header not complete */
} }
...@@ -1210,7 +1212,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp) ...@@ -1210,7 +1212,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
if (len < svsk->sk_reclen) { if (len < svsk->sk_reclen) {
dprintk("svc: incomplete TCP record (%d of %d)\n", dprintk("svc: incomplete TCP record (%d of %d)\n",
len, svsk->sk_reclen); len, svsk->sk_reclen);
svc_sock_received(svsk); svc_xprt_received(&svsk->sk_xprt);
return -EAGAIN; /* record not complete */ return -EAGAIN; /* record not complete */
} }
len = svsk->sk_reclen; len = svsk->sk_reclen;
...@@ -1250,7 +1252,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp) ...@@ -1250,7 +1252,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
svsk->sk_reclen = 0; svsk->sk_reclen = 0;
svsk->sk_tcplen = 0; svsk->sk_tcplen = 0;
svc_sock_received(svsk); svc_xprt_received(&svsk->sk_xprt);
if (serv->sv_stats) if (serv->sv_stats)
serv->sv_stats->nettcpcnt++; serv->sv_stats->nettcpcnt++;
...@@ -1263,7 +1265,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp) ...@@ -1263,7 +1265,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
error: error:
if (len == -EAGAIN) { if (len == -EAGAIN) {
dprintk("RPC: TCP recvfrom got EAGAIN\n"); dprintk("RPC: TCP recvfrom got EAGAIN\n");
svc_sock_received(svsk); svc_xprt_received(&svsk->sk_xprt);
} else { } else {
printk(KERN_NOTICE "%s: recvfrom returned errno %d\n", printk(KERN_NOTICE "%s: recvfrom returned errno %d\n",
svsk->sk_xprt.xpt_server->sv_name, -len); svsk->sk_xprt.xpt_server->sv_name, -len);
...@@ -1590,7 +1592,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout) ...@@ -1590,7 +1592,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout)
__module_get(newxpt->xpt_class->xcl_owner); __module_get(newxpt->xpt_class->xcl_owner);
svc_check_conn_limits(svsk->sk_xprt.xpt_server); svc_check_conn_limits(svsk->sk_xprt.xpt_server);
} }
svc_sock_received(svsk); svc_xprt_received(&svsk->sk_xprt);
} else { } else {
dprintk("svc: server %p, pool %u, socket %p, inuse=%d\n", dprintk("svc: server %p, pool %u, socket %p, inuse=%d\n",
rqstp, pool->sp_id, svsk, rqstp, pool->sp_id, svsk,
...@@ -1809,7 +1811,7 @@ int svc_addsock(struct svc_serv *serv, ...@@ -1809,7 +1811,7 @@ int svc_addsock(struct svc_serv *serv,
else { else {
svsk = svc_setup_socket(serv, so, &err, SVC_SOCK_DEFAULTS); svsk = svc_setup_socket(serv, so, &err, SVC_SOCK_DEFAULTS);
if (svsk) { if (svsk) {
svc_sock_received(svsk); svc_xprt_received(&svsk->sk_xprt);
err = 0; err = 0;
} }
} }
...@@ -1865,7 +1867,7 @@ static struct svc_xprt *svc_create_socket(struct svc_serv *serv, ...@@ -1865,7 +1867,7 @@ static struct svc_xprt *svc_create_socket(struct svc_serv *serv,
} }
if ((svsk = svc_setup_socket(serv, sock, &error, flags)) != NULL) { if ((svsk = svc_setup_socket(serv, sock, &error, flags)) != NULL) {
svc_sock_received(svsk); svc_xprt_received(&svsk->sk_xprt);
return (struct svc_xprt *)svsk; return (struct svc_xprt *)svsk;
} }
......
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