Commit e6242e92 authored by Sridhar Samudrala's avatar Sridhar Samudrala Committed by David S. Miller

[SUNRPC]: Update to use in-kernel sockets API.

Signed-off-by: default avatarSridhar Samudrala <sri@us.ibm.com>
Acked-by: default avatarJames Morris <jmorris@namei.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ac5a488e
...@@ -388,7 +388,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) ...@@ -388,7 +388,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
/* send head */ /* send head */
if (slen == xdr->head[0].iov_len) if (slen == xdr->head[0].iov_len)
flags = 0; flags = 0;
len = sock->ops->sendpage(sock, rqstp->rq_respages[0], 0, xdr->head[0].iov_len, flags); len = kernel_sendpage(sock, rqstp->rq_respages[0], 0, xdr->head[0].iov_len, flags);
if (len != xdr->head[0].iov_len) if (len != xdr->head[0].iov_len)
goto out; goto out;
slen -= xdr->head[0].iov_len; slen -= xdr->head[0].iov_len;
...@@ -400,7 +400,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) ...@@ -400,7 +400,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
while (pglen > 0) { while (pglen > 0) {
if (slen == size) if (slen == size)
flags = 0; flags = 0;
result = sock->ops->sendpage(sock, *ppage, base, size, flags); result = kernel_sendpage(sock, *ppage, base, size, flags);
if (result > 0) if (result > 0)
len += result; len += result;
if (result != size) if (result != size)
...@@ -413,7 +413,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) ...@@ -413,7 +413,7 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
} }
/* send tail */ /* send tail */
if (xdr->tail[0].iov_len) { if (xdr->tail[0].iov_len) {
result = sock->ops->sendpage(sock, rqstp->rq_respages[rqstp->rq_restailpage], result = kernel_sendpage(sock, rqstp->rq_respages[rqstp->rq_restailpage],
((unsigned long)xdr->tail[0].iov_base)& (PAGE_SIZE-1), ((unsigned long)xdr->tail[0].iov_base)& (PAGE_SIZE-1),
xdr->tail[0].iov_len, 0); xdr->tail[0].iov_len, 0);
...@@ -434,13 +434,10 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) ...@@ -434,13 +434,10 @@ svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
static int static int
svc_recv_available(struct svc_sock *svsk) svc_recv_available(struct svc_sock *svsk)
{ {
mm_segment_t oldfs;
struct socket *sock = svsk->sk_sock; struct socket *sock = svsk->sk_sock;
int avail, err; int avail, err;
oldfs = get_fs(); set_fs(KERNEL_DS); err = kernel_sock_ioctl(sock, TIOCINQ, (unsigned long) &avail);
err = sock->ops->ioctl(sock, TIOCINQ, (unsigned long) &avail);
set_fs(oldfs);
return (err >= 0)? avail : err; return (err >= 0)? avail : err;
} }
...@@ -472,7 +469,7 @@ svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen) ...@@ -472,7 +469,7 @@ svc_recvfrom(struct svc_rqst *rqstp, struct kvec *iov, int nr, int buflen)
* at accept time. FIXME * at accept time. FIXME
*/ */
alen = sizeof(rqstp->rq_addr); alen = sizeof(rqstp->rq_addr);
sock->ops->getname(sock, (struct sockaddr *)&rqstp->rq_addr, &alen, 1); kernel_getpeername(sock, (struct sockaddr *)&rqstp->rq_addr, &alen);
dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n", dprintk("svc: socket %p recvfrom(%p, %Zu) = %d\n",
rqstp->rq_sock, iov[0].iov_base, iov[0].iov_len, len); rqstp->rq_sock, iov[0].iov_base, iov[0].iov_len, len);
...@@ -758,7 +755,6 @@ svc_tcp_accept(struct svc_sock *svsk) ...@@ -758,7 +755,6 @@ svc_tcp_accept(struct svc_sock *svsk)
struct svc_serv *serv = svsk->sk_server; struct svc_serv *serv = svsk->sk_server;
struct socket *sock = svsk->sk_sock; struct socket *sock = svsk->sk_sock;
struct socket *newsock; struct socket *newsock;
const struct proto_ops *ops;
struct svc_sock *newsvsk; struct svc_sock *newsvsk;
int err, slen; int err, slen;
...@@ -766,29 +762,23 @@ svc_tcp_accept(struct svc_sock *svsk) ...@@ -766,29 +762,23 @@ svc_tcp_accept(struct svc_sock *svsk)
if (!sock) if (!sock)
return; return;
err = sock_create_lite(PF_INET, SOCK_STREAM, IPPROTO_TCP, &newsock); clear_bit(SK_CONN, &svsk->sk_flags);
if (err) { err = kernel_accept(sock, &newsock, O_NONBLOCK);
if (err < 0) {
if (err == -ENOMEM) if (err == -ENOMEM)
printk(KERN_WARNING "%s: no more sockets!\n", printk(KERN_WARNING "%s: no more sockets!\n",
serv->sv_name); serv->sv_name);
return; else if (err != -EAGAIN && net_ratelimit())
}
dprintk("svc: tcp_accept %p allocated\n", newsock);
newsock->ops = ops = sock->ops;
clear_bit(SK_CONN, &svsk->sk_flags);
if ((err = ops->accept(sock, newsock, O_NONBLOCK)) < 0) {
if (err != -EAGAIN && net_ratelimit())
printk(KERN_WARNING "%s: accept failed (err %d)!\n", printk(KERN_WARNING "%s: accept failed (err %d)!\n",
serv->sv_name, -err); serv->sv_name, -err);
goto failed; /* aborted connection or whatever */ return;
} }
set_bit(SK_CONN, &svsk->sk_flags); set_bit(SK_CONN, &svsk->sk_flags);
svc_sock_enqueue(svsk); svc_sock_enqueue(svsk);
slen = sizeof(sin); slen = sizeof(sin);
err = ops->getname(newsock, (struct sockaddr *) &sin, &slen, 1); err = kernel_getpeername(newsock, (struct sockaddr *) &sin, &slen);
if (err < 0) { if (err < 0) {
if (net_ratelimit()) if (net_ratelimit())
printk(KERN_WARNING "%s: peername failed (err %d)!\n", printk(KERN_WARNING "%s: peername failed (err %d)!\n",
...@@ -1406,14 +1396,14 @@ svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin) ...@@ -1406,14 +1396,14 @@ svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin)
if (sin != NULL) { if (sin != NULL) {
if (type == SOCK_STREAM) if (type == SOCK_STREAM)
sock->sk->sk_reuse = 1; /* allow address reuse */ sock->sk->sk_reuse = 1; /* allow address reuse */
error = sock->ops->bind(sock, (struct sockaddr *) sin, error = kernel_bind(sock, (struct sockaddr *) sin,
sizeof(*sin)); sizeof(*sin));
if (error < 0) if (error < 0)
goto bummer; goto bummer;
} }
if (protocol == IPPROTO_TCP) { if (protocol == IPPROTO_TCP) {
if ((error = sock->ops->listen(sock, 64)) < 0) if ((error = kernel_listen(sock, 64)) < 0)
goto bummer; goto bummer;
} }
......
...@@ -207,7 +207,7 @@ static inline int xs_sendpages(struct socket *sock, struct sockaddr *addr, int a ...@@ -207,7 +207,7 @@ static inline int xs_sendpages(struct socket *sock, struct sockaddr *addr, int a
base &= ~PAGE_CACHE_MASK; base &= ~PAGE_CACHE_MASK;
} }
sendpage = sock->ops->sendpage ? : sock_no_sendpage; sendpage = kernel_sendpage;
do { do {
int flags = XS_SENDMSG_FLAGS; int flags = XS_SENDMSG_FLAGS;
...@@ -986,7 +986,7 @@ static int xs_bindresvport(struct rpc_xprt *xprt, struct socket *sock) ...@@ -986,7 +986,7 @@ static int xs_bindresvport(struct rpc_xprt *xprt, struct socket *sock)
do { do {
myaddr.sin_port = htons(port); myaddr.sin_port = htons(port);
err = sock->ops->bind(sock, (struct sockaddr *) &myaddr, err = kernel_bind(sock, (struct sockaddr *) &myaddr,
sizeof(myaddr)); sizeof(myaddr));
if (err == 0) { if (err == 0) {
xprt->port = port; xprt->port = port;
...@@ -1081,7 +1081,7 @@ static void xs_tcp_reuse_connection(struct rpc_xprt *xprt) ...@@ -1081,7 +1081,7 @@ static void xs_tcp_reuse_connection(struct rpc_xprt *xprt)
*/ */
memset(&any, 0, sizeof(any)); memset(&any, 0, sizeof(any));
any.sa_family = AF_UNSPEC; any.sa_family = AF_UNSPEC;
result = sock->ops->connect(sock, &any, sizeof(any), 0); result = kernel_connect(sock, &any, sizeof(any), 0);
if (result) if (result)
dprintk("RPC: AF_UNSPEC connect return code %d\n", dprintk("RPC: AF_UNSPEC connect return code %d\n",
result); result);
...@@ -1151,7 +1151,7 @@ static void xs_tcp_connect_worker(void *args) ...@@ -1151,7 +1151,7 @@ static void xs_tcp_connect_worker(void *args)
/* Tell the socket layer to start connecting... */ /* Tell the socket layer to start connecting... */
xprt->stat.connect_count++; xprt->stat.connect_count++;
xprt->stat.connect_start = jiffies; xprt->stat.connect_start = jiffies;
status = sock->ops->connect(sock, (struct sockaddr *) &xprt->addr, status = kernel_connect(sock, (struct sockaddr *) &xprt->addr,
sizeof(xprt->addr), O_NONBLOCK); sizeof(xprt->addr), O_NONBLOCK);
dprintk("RPC: %p connect status %d connected %d sock state %d\n", dprintk("RPC: %p connect status %d connected %d sock state %d\n",
xprt, -status, xprt_connected(xprt), sock->sk->sk_state); xprt, -status, xprt_connected(xprt), sock->sk->sk_state);
......
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