9p: new transport interface
Subsystems (3)
Latchesar Ionkov
maintainerPATCH 1/10 9p: new transport interface
The current transport interface is tied too closely to the socket/file descriptor operations. It expects only a single message to be transmitted at any given time. It also depends on the vfs poll mechanism for notification when data can be sent/received.
This patch modifies the transport interface making it more suitable for implementing various 9P transports.
Signed-off-by Latchesar Ionkov <[email protected]>
--- fs/9p/v9fs.c | 1 - include/net/9p/9p.h | 1 + include/net/9p/client.h | 13 ++- include/net/9p/conn.h | 57 -------- include/net/9p/transport.h | 37 ++++-- net/9p/Kconfig | 18 ++-- net/9p/Makefile | 1 - net/9p/client.c | 333 ++++++++++++++++++++++++++++++++++++++++---- net/9p/conv.c | 16 ++- net/9p/mod.c | 12 +-- 10 files changed, 368 insertions(+), 121 deletions(-)
fs/9p/v9fs.c +0 -1
@@ -31,7 +31,6 @@#include <linux/idr.h> #include <net/9p/9p.h> #include <net/9p/transport.h> -#include <net/9p/conn.h> #include <net/9p/client.h> #include "v9fs.h" #include "v9fs_vfs.h"
include/net/9p/9p.h +1 -0
@@ -383,6 +383,7 @@ int p9_deserialize_stat(void *buf, u32 buflen, struct p9_stat *stat, int dotu);int p9_deserialize_fcall (void *buf,u32 buflen,struct p9_fcall *fc,int dotu);void p9_set_tag (struct p9_fcall *fc,u16 tag); +struct p9_fcall *p9_fcall_alloc (u32 size);struct p9_fcall *p9_create_tversion (u32 msize,char *version);struct p9_fcall *p9_create_tattach (u32 fid,u32 afid,char *uname,char *aname,u32 n_uname,int dotu);
include/net/9p/client.h +11 -2
@@ -25,14 +25,14 @@#ifndef NET_9P_CLIENT_H #define NET_9P_CLIENT_H +struct p9_trans_req ;struct p9_client {spinlock_t lock;/* protect client structure */ int msize;unsigned char dotu;struct p9_trans *trans; -struct p9_conn *conn; -struct p9_idpool *fidpool; +struct p9_idpool *tagpool;struct list_head fidlist; };
@@ -78,4 +78,13 @@ struct p9_stat *p9_client_stat(struct p9_fid *fid);int p9_client_wstat (struct p9_fid *fid,struct p9_wstat *wst);struct p9_stat *p9_client_dirread (struct p9_fid *fid,u64 offset); +void p9_client_req_incref (struct p9_trans_req *req); +void p9_client_req_decref (struct p9_trans_req *req); +struct p9_trans_req *p9_client_rpcnb (struct p9_client *clnt, +struct p9_fcall *tc,struct p9_fcall *rc, +void (*cb)(struct p9_trans_req *),void *cba); +void p9_client_flush_req (struct p9_trans_req *req); +int p9_client_rpc (struct p9_client *clnt,struct p9_fcall *tc, +struct p9_fcall **prc); +#endif /* NET_9P_CLIENT_H */
include/net/9p/conn.h deleted +0 -57
57 lines not on this page · raw message
include/net/9p/transport.h +27 -10
@@ -26,19 +26,36 @@#ifndef NET_9P_TRANSPORT_H #define NET_9P_TRANSPORT_H -enum p9_trans_status { - Connected, - Disconnected, - Hung, +struct p9_trans ; + +struct p9_trans_req { +u16 tag; +int err; +struct p9_fcall *tc; +struct p9_fcall *rc; +void (*cb)(struct p9_trans *,struct p9_trans_req *); +void *cba; + +void *aux;/* transport specific */ +struct list_head req_list; };struct p9_trans { -enum p9_trans_status status; -void *priv; -int (*write) (struct p9_trans *,void *,int ); -int (*read) (struct p9_trans *,void *,int ); -void (*close) (struct p9_trans *); -unsigned int (*poll)(struct p9_trans *,struct poll_table_struct *); +int err;/* 0 == connected */ +u32 msize; +int dotu;/* 9P2000.u */ +void *aux; +void *priv;/* transport specific */ + +/* The function schedules sending the data from the 'tc' +over the transport. If the 'rc' is set, the response is +read in it and the 'cb' is called. +*/ +void (*request)(struct p9_trans *trans,struct p9_trans_req *req); + +/* If the request is not sent down the wire, don't send it. */ +int (*cancel)(struct p9_trans *trans,struct p9_trans_req *req); +void (*destroy)(struct p9_trans *trans); }; struct p9_trans_module {
net/9p/Kconfig +9 -9
@@ -13,15 +13,15 @@ menuconfig NET_9P If unsure, say N. -config NET_9P_FD - depends on NET_9P - default y if NET_9P - tristate "9P File Descriptor Transports (Experimental)" - help - This builds support for file descriptor transports for 9p - which includes support for TCP/IP, named pipes, or passed - file descriptors. TCP/IP is the default transport for 9p, - so if you are going to use 9p, you'll likely want this. +#config NET_9P_FD +# depends on NET_9P +# default y if NET_9P +# tristate "9P File Descriptor Transports (Experimental)" +# help +# This builds support for file descriptor transports for 9p +# which includes support for TCP/IP, named pipes, or passed +# file descriptors. TCP/IP is the default transport for 9p, +# so if you are going to use 9p, you'll likely want this. config NET_9P_DEBUG bool "Debug information"
net/9p/Makefile +0 -1
@@ -3,7 +3,6 @@ obj-$(CONFIG_NET_9P_FD) += 9pnet_fd.o 9pnet-objs := \ mod.o \ - mux.o \ client.o \ conv.o \ error.o \
net/9p/client.c +304 -29
483 lines not on this page · raw message
net/9p/conv.c +15 -1
@@ -130,7 +130,7 @@ static char *buf_put_stringn(struct cbuf *buf, const char *s, u16 slen)static inline void buf_put_string (struct cbuf *buf,const char *s) { -buf_put_stringn (buf, s,strlen (s)); +buf_put_stringn (buf, s, s?strlen (s):0 ); }static u8 buf_get_int8 (struct cbuf *buf)
@@ -496,6 +496,20 @@ p9_put_wstat(struct cbuf *bufp, struct p9_wstat *wstat, } } +struct p9_fcall *p9_fcall_alloc (u32 size) +{ +struct p9_fcall *fc; + + fc =kmalloc (sizeof (struct p9_fcall ) + size,GFP_KERNEL ); +if (!fc) +return ERR_PTR (-ENOMEM ); + + fc->size = size; + fc->sdata = (char *)fc +sizeof (*fc); +return fc; +} +EXPORT_SYMBOL (p9_fcall_alloc); +static struct p9_fcall *p9_create_common (struct cbuf *bufp,u32 size,u8 id) {
net/9p/mod.c +1 -11
@@ -49,9 +49,6 @@ static struct subsys_attribute p9_debug_attr = __ATTR(debuglevel, 0644,decl_subsys_name (p9,9p ,NULL ,NULL );EXPORT_SYMBOL (p9_subsys); -extern int p9_mux_global_init (void ); -extern void p9_mux_global_exit (void ); -/* * Dynamic Transport Registration Routines *
@@ -154,13 +151,7 @@ static int __init init_p9(void)#endif printk (KERN_INFO "Installing 9P2000 support\n" ); - ret =p9_mux_global_init (); -if (ret) { -printk (KERN_WARNING "9p: starting mux failed\n" ); -return ret; - } - -return ret; +return 0 ; }/**
@@ -170,7 +161,6 @@ static int __init init_p9(void) static void __exit exit_p9(void) { -p9_mux_global_exit ();subsystem_unregister (&p9_subsys); }