提交 a246b010 编写于 作者: C Chuck Lever 提交者: Trond Myklebust

[PATCH] RPC: introduce client-side transport switch

 Move the bulk of client-side socket-specific code into a separate source
 file, net/sunrpc/xprtsock.c.

 Test-plan:
 Millions of fsx operations.  Performance characterization such as "sio" or
 "iozone".  Destructive testing (unplugging the network temporarily, server
 reboots).  Connectathon with v2, v3, and v4.

 Version: Thu, 11 Aug 2005 16:03:38 -0400
Signed-off-by: NChuck Lever <cel@netapp.com>
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 094bb20b
...@@ -165,11 +165,6 @@ extern int csum_partial_copy_to_xdr(struct xdr_buf *, struct sk_buff *); ...@@ -165,11 +165,6 @@ extern int csum_partial_copy_to_xdr(struct xdr_buf *, struct sk_buff *);
extern ssize_t xdr_partial_copy_from_skb(struct xdr_buf *, unsigned int, extern ssize_t xdr_partial_copy_from_skb(struct xdr_buf *, unsigned int,
skb_reader_t *, skb_read_actor_t); skb_reader_t *, skb_read_actor_t);
struct socket;
struct sockaddr;
extern int xdr_sendpages(struct socket *, struct sockaddr *, int,
struct xdr_buf *, unsigned int, int);
extern int xdr_encode_word(struct xdr_buf *, int, u32); extern int xdr_encode_word(struct xdr_buf *, int, u32);
extern int xdr_decode_word(struct xdr_buf *, int, u32 *); extern int xdr_decode_word(struct xdr_buf *, int, u32 *);
......
...@@ -59,7 +59,13 @@ extern unsigned int xprt_tcp_slot_table_entries; ...@@ -59,7 +59,13 @@ extern unsigned int xprt_tcp_slot_table_entries;
*/ */
#define RPC_REESTABLISH_TIMEOUT (15*HZ) #define RPC_REESTABLISH_TIMEOUT (15*HZ)
/* RPC call and reply header size as number of 32bit words (verifier /*
* RPC transport idle timeout.
*/
#define RPC_IDLE_DISCONNECT_TIMEOUT (5*60*HZ)
/*
* RPC call and reply header size as number of 32bit words (verifier
* size computed separately) * size computed separately)
*/ */
#define RPC_CALLHDRSIZE 6 #define RPC_CALLHDRSIZE 6
...@@ -121,12 +127,19 @@ struct rpc_rqst { ...@@ -121,12 +127,19 @@ struct rpc_rqst {
#define rq_svec rq_snd_buf.head #define rq_svec rq_snd_buf.head
#define rq_slen rq_snd_buf.len #define rq_slen rq_snd_buf.len
#define XPRT_LAST_FRAG (1 << 0) struct rpc_task;
#define XPRT_COPY_RECM (1 << 1) struct rpc_xprt;
#define XPRT_COPY_XID (1 << 2)
#define XPRT_COPY_DATA (1 << 3) struct rpc_xprt_ops {
void (*set_buffer_size)(struct rpc_xprt *xprt);
void (*connect)(struct rpc_task *task);
int (*send_request)(struct rpc_task *task);
void (*close)(struct rpc_xprt *xprt);
void (*destroy)(struct rpc_xprt *xprt);
};
struct rpc_xprt { struct rpc_xprt {
struct rpc_xprt_ops * ops; /* transport methods */
struct socket * sock; /* BSD socket layer */ struct socket * sock; /* BSD socket layer */
struct sock * inet; /* INET layer */ struct sock * inet; /* INET layer */
...@@ -199,14 +212,22 @@ struct rpc_xprt { ...@@ -199,14 +212,22 @@ struct rpc_xprt {
wait_queue_head_t cong_wait; wait_queue_head_t cong_wait;
}; };
#define XPRT_LAST_FRAG (1 << 0)
#define XPRT_COPY_RECM (1 << 1)
#define XPRT_COPY_XID (1 << 2)
#define XPRT_COPY_DATA (1 << 3)
#ifdef __KERNEL__ #ifdef __KERNEL__
struct rpc_xprt * xprt_create_proto(int proto, struct sockaddr_in *addr, struct rpc_xprt * xprt_create_proto(int proto, struct sockaddr_in *addr,
struct rpc_timeout *toparms); struct rpc_timeout *toparms);
void xprt_disconnect(struct rpc_xprt *);
int xprt_destroy(struct rpc_xprt *); int xprt_destroy(struct rpc_xprt *);
void xprt_set_timeout(struct rpc_timeout *, unsigned int, void xprt_set_timeout(struct rpc_timeout *, unsigned int,
unsigned long); unsigned long);
struct rpc_rqst * xprt_lookup_rqst(struct rpc_xprt *, u32);
void xprt_complete_rqst(struct rpc_xprt *,
struct rpc_rqst *, int);
void xprt_reserve(struct rpc_task *); void xprt_reserve(struct rpc_task *);
int xprt_prepare_transmit(struct rpc_task *); int xprt_prepare_transmit(struct rpc_task *);
void xprt_transmit(struct rpc_task *); void xprt_transmit(struct rpc_task *);
...@@ -214,7 +235,10 @@ void xprt_receive(struct rpc_task *); ...@@ -214,7 +235,10 @@ void xprt_receive(struct rpc_task *);
int xprt_adjust_timeout(struct rpc_rqst *req); int xprt_adjust_timeout(struct rpc_rqst *req);
void xprt_release(struct rpc_task *); void xprt_release(struct rpc_task *);
void xprt_connect(struct rpc_task *); void xprt_connect(struct rpc_task *);
void xprt_sock_setbufsize(struct rpc_xprt *); int xs_setup_udp(struct rpc_xprt *,
struct rpc_timeout *);
int xs_setup_tcp(struct rpc_xprt *,
struct rpc_timeout *);
#define XPRT_LOCKED 0 #define XPRT_LOCKED 0
#define XPRT_CONNECT 1 #define XPRT_CONNECT 1
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
obj-$(CONFIG_SUNRPC) += sunrpc.o obj-$(CONFIG_SUNRPC) += sunrpc.o
obj-$(CONFIG_SUNRPC_GSS) += auth_gss/ obj-$(CONFIG_SUNRPC_GSS) += auth_gss/
sunrpc-y := clnt.o xprt.o socklib.o sched.o \ sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \
auth.o auth_null.o auth_unix.o \ auth.o auth_null.o auth_unix.o \
svc.o svcsock.o svcauth.o svcauth_unix.o \ svc.o svcsock.o svcauth.o svcauth_unix.o \
pmap_clnt.o timer.o xdr.o \ pmap_clnt.o timer.o xdr.o \
......
...@@ -525,8 +525,7 @@ rpc_setbufsize(struct rpc_clnt *clnt, unsigned int sndsize, unsigned int rcvsize ...@@ -525,8 +525,7 @@ rpc_setbufsize(struct rpc_clnt *clnt, unsigned int sndsize, unsigned int rcvsize
xprt->rcvsize = 0; xprt->rcvsize = 0;
if (rcvsize) if (rcvsize)
xprt->rcvsize = rcvsize + RPC_SLACK_SPACE; xprt->rcvsize = rcvsize + RPC_SLACK_SPACE;
if (xprt_connected(xprt)) xprt->ops->set_buffer_size(xprt);
xprt_sock_setbufsize(xprt);
} }
/* /*
......
...@@ -119,6 +119,9 @@ proc_dodebug(ctl_table *table, int write, struct file *file, ...@@ -119,6 +119,9 @@ proc_dodebug(ctl_table *table, int write, struct file *file,
return 0; return 0;
} }
unsigned int xprt_udp_slot_table_entries = RPC_DEF_SLOT_TABLE;
unsigned int xprt_tcp_slot_table_entries = RPC_DEF_SLOT_TABLE;
static unsigned int min_slot_table_size = RPC_MIN_SLOT_TABLE; static unsigned int min_slot_table_size = RPC_MIN_SLOT_TABLE;
static unsigned int max_slot_table_size = RPC_MAX_SLOT_TABLE; static unsigned int max_slot_table_size = RPC_MAX_SLOT_TABLE;
......
...@@ -6,15 +6,12 @@ ...@@ -6,15 +6,12 @@
* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
*/ */
#include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/socket.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/in.h>
#include <linux/net.h>
#include <net/sock.h>
#include <linux/sunrpc/xdr.h> #include <linux/sunrpc/xdr.h>
#include <linux/sunrpc/msg_prot.h> #include <linux/sunrpc/msg_prot.h>
...@@ -177,103 +174,6 @@ xdr_inline_pages(struct xdr_buf *xdr, unsigned int offset, ...@@ -177,103 +174,6 @@ xdr_inline_pages(struct xdr_buf *xdr, unsigned int offset,
} }
int
xdr_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
struct xdr_buf *xdr, unsigned int base, int msgflags)
{
struct page **ppage = xdr->pages;
unsigned int len, pglen = xdr->page_len;
int err, ret = 0;
ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int);
len = xdr->head[0].iov_len;
if (base < len || (addr != NULL && base == 0)) {
struct kvec iov = {
.iov_base = xdr->head[0].iov_base + base,
.iov_len = len - base,
};
struct msghdr msg = {
.msg_name = addr,
.msg_namelen = addrlen,
.msg_flags = msgflags,
};
if (xdr->len > len)
msg.msg_flags |= MSG_MORE;
if (iov.iov_len != 0)
err = kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len);
else
err = kernel_sendmsg(sock, &msg, NULL, 0, 0);
if (ret == 0)
ret = err;
else if (err > 0)
ret += err;
if (err != iov.iov_len)
goto out;
base = 0;
} else
base -= len;
if (pglen == 0)
goto copy_tail;
if (base >= pglen) {
base -= pglen;
goto copy_tail;
}
if (base || xdr->page_base) {
pglen -= base;
base += xdr->page_base;
ppage += base >> PAGE_CACHE_SHIFT;
base &= ~PAGE_CACHE_MASK;
}
sendpage = sock->ops->sendpage ? : sock_no_sendpage;
do {
int flags = msgflags;
len = PAGE_CACHE_SIZE;
if (base)
len -= base;
if (pglen < len)
len = pglen;
if (pglen != len || xdr->tail[0].iov_len != 0)
flags |= MSG_MORE;
/* Hmm... We might be dealing with highmem pages */
if (PageHighMem(*ppage))
sendpage = sock_no_sendpage;
err = sendpage(sock, *ppage, base, len, flags);
if (ret == 0)
ret = err;
else if (err > 0)
ret += err;
if (err != len)
goto out;
base = 0;
ppage++;
} while ((pglen -= len) != 0);
copy_tail:
len = xdr->tail[0].iov_len;
if (base < len) {
struct kvec iov = {
.iov_base = xdr->tail[0].iov_base + base,
.iov_len = len - base,
};
struct msghdr msg = {
.msg_flags = msgflags,
};
err = kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len);
if (ret == 0)
ret = err;
else if (err > 0)
ret += err;
}
out:
return ret;
}
/* /*
* Helper routines for doing 'memmove' like operations on a struct xdr_buf * Helper routines for doing 'memmove' like operations on a struct xdr_buf
* *
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册