v9fs: new multiplexer implementation
Latchesar Ionkov
maintainerPATCH 1/3 v9fs: new multiplexer implementation
New multiplexer implementation. Decreases the number of kernel threads required. Better handling when the user process receives a signal.
Signed-off-by Latchesar Ionkov <[email protected]>
---
fs/9p/9p.c | 68 ++- fs/9p/9p.h | 9 fs/9p/conv.c | 86 ++-- fs/9p/conv.h | 13 - fs/9p/fid.c | 2 fs/9p/mux.c | 1136 +++++++++++++++++++++++++++++++++++++--------------- fs/9p/mux.h | 46 +- fs/9p/trans_fd.c | 49 ++ fs/9p/trans_sock.c | 163 +++++-- fs/9p/transport.h | 4 fs/9p/v9fs.c | 41 +- fs/9p/v9fs.h | 17 - fs/9p/vfs_dentry.c | 13 - fs/9p/vfs_dir.c | 17 - fs/9p/vfs_inode.c | 89 ++-- fs/9p/vfs_super.c | 3 16 files changed, 1184 insertions(+), 572 deletions(-)
9dbba8fb15d40900ef639a85b5c1e8ade604917e
fs/9p/9p.c +49 -19
@@ -52,10 +52,11 @@ v9fs_t_version(struct v9fs_session_infodprintk (DEBUG_9P ,"msize: %d version: %s\n" , msize, version); msg.id =TVERSION ; + msg.tag = ~0 ; msg.params.tversion.msize = msize; msg.params.tversion.version = version; -return v9fs_mux_rpc (v9ses, &msg, fcall); +return v9fs_mux_rpc (v9ses->mux, &msg, fcall); }/**
@@ -83,7 +84,30 @@ v9fs_t_attach(struct v9fs_session_info * msg.params.tattach.uname = uname; msg.params.tattach.aname = aname; -return v9fs_mux_rpc (v9ses, &msg, fcall); +return v9fs_mux_rpc (v9ses->mux, &msg, fcall); +} + +static void v9fs_t_clunk_cb (void *a,struct v9fs_fcall *tc, +struct v9fs_fcall *rc,int err) +{ +int fid; +struct v9fs_session_info *v9ses; + +if (err) +return ; + + fid = tc->params.tclunk.fid; +kfree (tc); + +if (!rc) +return ; + +dprintk (DEBUG_9P ,"tcall id %d rcall id %d\n" , tc->id, rc->id); + v9ses = a; +if (rc->id ==RCLUNK ) +v9fs_put_idpool (fid, &v9ses->fidpool); + +kfree (rc); }/**
@@ -93,18 +117,24 @@ v9fs_t_attach(struct v9fs_session_info ** @fcall: pointer to response fcall pointer * */ -int -v9fs_t_clunk (struct v9fs_session_info *v9ses,u32 fid, -struct v9fs_fcall **fcall) +v9fs_t_clunk (struct v9fs_session_info *v9ses,u32 fid) { -struct v9fs_fcall msg; +int err; +struct v9fs_fcall *tc, *rc; + + tc =kmalloc (sizeof (struct v9fs_fcall ),GFP_KERNEL );dprintk (DEBUG_9P ,"fid %d\n" , fid); - msg.id =TCLUNK ; - msg.params.tclunk.fid = fid; + tc->id =TCLUNK ; + tc->params.tclunk.fid = fid; -return v9fs_mux_rpc (v9ses, &msg, fcall); + err =v9fs_mux_rpc (v9ses->mux, tc, &rc); +if (err >=0 ) { +v9fs_t_clunk_cb (v9ses, tc, rc,0 ); + } + +return err; }/**
@@ -121,7 +151,7 @@ int v9fs_t_flush(struct v9fs_session_infdprintk (DEBUG_9P ,"oldtag %d\n" , tag); msg.id =TFLUSH ; msg.params.tflush.oldtag = tag; -return v9fs_mux_rpc (v9ses, &msg,NULL ); +return v9fs_mux_rpc (v9ses->mux, &msg,NULL ); }/**
@@ -143,7 +173,7 @@ v9fs_t_stat(struct v9fs_session_info *v9 msg.id =TSTAT ; msg.params.tstat.fid = fid; -return v9fs_mux_rpc (v9ses, &msg, fcall); +return v9fs_mux_rpc (v9ses->mux, &msg, fcall); }/**
@@ -166,7 +196,7 @@ v9fs_t_wstat(struct v9fs_session_info *v msg.params.twstat.fid = fid; msg.params.twstat.stat = stat; -return v9fs_mux_rpc (v9ses, &msg, fcall); +return v9fs_mux_rpc (v9ses->mux, &msg, fcall); }/**
@@ -199,7 +229,7 @@ v9fs_t_walk(struct v9fs_session_info *v9 msg.params.twalk.nwname =0 ; } -return v9fs_mux_rpc (v9ses, &msg, fcall); +return v9fs_mux_rpc (v9ses->mux, &msg, fcall); }/**
@@ -217,14 +247,14 @@ v9fs_t_open(struct v9fs_session_info *v9 struct v9fs_fcall **fcall) {struct v9fs_fcall msg; -long errorno =-1 ; +int errorno =-1 ;dprintk (DEBUG_9P ,"fid %d mode %d\n" , fid, mode); msg.id =TOPEN ; msg.params.topen.fid = fid; msg.params.topen.mode = mode; - errorno =v9fs_mux_rpc (v9ses, &msg, fcall); + errorno =v9fs_mux_rpc (v9ses->mux, &msg, fcall);return errorno; }
@@ -246,7 +276,7 @@ v9fs_t_remove(struct v9fs_session_info *dprintk (DEBUG_9P ,"fid %d\n" , fid); msg.id =TREMOVE ; msg.params.tremove.fid = fid; -return v9fs_mux_rpc (v9ses, &msg, fcall); +return v9fs_mux_rpc (v9ses->mux, &msg, fcall); }/**
@@ -275,7 +305,7 @@ v9fs_t_create(struct v9fs_session_info * msg.params.tcreate.perm = perm; msg.params.tcreate.mode = mode; -return v9fs_mux_rpc (v9ses, &msg, fcall); +return v9fs_mux_rpc (v9ses->mux, &msg, fcall); }/**
@@ -302,7 +332,7 @@ v9fs_t_read(struct v9fs_session_info *v9 msg.params.tread.fid = fid; msg.params.tread.offset = offset; msg.params.tread.count = count; - errorno =v9fs_mux_rpc (v9ses, &msg, &rc); + errorno =v9fs_mux_rpc (v9ses->mux, &msg, &rc);if (!errorno) { errorno = rc->params.rread.count;
@@ -345,7 +375,7 @@ v9fs_t_write(struct v9fs_session_info *v msg.params.twrite.count = count; msg.params.twrite.data = data; - errorno =v9fs_mux_rpc (v9ses, &msg, &rc); + errorno =v9fs_mux_rpc (v9ses->mux, &msg, &rc);if (!errorno) errorno = rc->params.rwrite.count;
fs/9p/9p.h +7 -2
@@ -100,6 +100,9 @@ enum { V9FS_QTFILE = 0x00, }; +#define V9FS_NOTAG (u16)(~0) +#define V9FS_NOFID (u32)(~0) +/* ample room for Twrite/Rread header (iounit) */ #define V9FS_IOHDRSZ 24
@@ -303,6 +306,9 @@ struct v9fs_fcall { } params; }; +#define V9FS_FCALLHDRSZ (sizeof(struct v9fs_fcall) + \ + sizeof(struct v9fs_stat) + 16*sizeof(struct v9fs_qid) + 16) +#define FCALL_ERROR (fcall) (fcall ? fcall->params.rerror.error : "") int v9fs_t_version(struct v9fs_session_info *v9ses, u32 msize,
@@ -311,8 +317,7 @@ int v9fs_t_version(struct v9fs_session_iint v9fs_t_attach (struct v9fs_session_info *v9ses,char *uname,char *aname,u32 fid,u32 afid,struct v9fs_fcall **rcall); -int v9fs_t_clunk (struct v9fs_session_info *v9ses,u32 fid, -struct v9fs_fcall **rcall); +int v9fs_t_clunk (struct v9fs_session_info *v9ses,u32 fid);int v9fs_t_flush (struct v9fs_session_info *v9ses,u16 oldtag);
fs/9p/conv.c +45 -41
258 lines not on this page · raw message
fs/9p/conv.h +6 -7
@@ -24,13 +24,12 @@* */ -int v9fs_deserialize_stat (struct v9fs_session_info *,void *buf, -u32 buflen,struct v9fs_stat *stat,u32 statlen); -int v9fs_serialize_fcall (struct v9fs_session_info *,struct v9fs_fcall *tcall, -void *buf,u32 buflen); -int v9fs_deserialize_fcall (struct v9fs_session_info *,u32 msglen, -void *buf,u32 buflen,struct v9fs_fcall *rcall, -int rcalllen); +int v9fs_deserialize_stat (void *buf,u32 buflen,struct v9fs_stat *stat, +u32 statlen,int extended); +int v9fs_serialize_fcall (struct v9fs_fcall *tcall,void *buf,u32 buflen, +int extended); +int v9fs_deserialize_fcall (void *buf,u32 buflen,struct v9fs_fcall *rcall, +int rcalllen,int extended);/* this one is actually in error.c right now */ int v9fs_errstr2errno (char *errstr);
fs/9p/fid.c +1 -1
@@ -164,7 +164,7 @@ static struct v9fs_fid *v9fs_fid_walk_upreturn v9fs_fid_create (dentry, v9ses, fidnum,0 ); clunk_fid: -v9fs_t_clunk (v9ses, fidnum,NULL ); +v9fs_t_clunk (v9ses, fidnum);return ERR_PTR (err); }
fs/9p/mux.c +802 -334
1,253 lines not on this page · raw message
fs/9p/mux.h +31 -15
56 lines not on this page · raw message
fs/9p/trans_fd.c +46 -3
71 lines not on this page · raw message
fs/9p/trans_sock.c +104 -59
281 lines not on this page · raw message
fs/9p/transport.h +2 -2
@@ -3,6 +3,7 @@* * Transport Definition * +* Copyright (C) 2005 by Latchesar Ionkov <[email protected]> * Copyright (C) 2004 by Eric Van Hensbergen <[email protected]> * * This program is free software; you can redistribute it and/or modify
@@ -31,14 +32,13 @@ enum v9fs_transport_status {struct v9fs_transport {enum v9fs_transport_status status; -struct semaphore writelock; -struct semaphore readlock;void *priv;int (*init) (struct v9fs_session_info *,const char *,char *);int (*write) (struct v9fs_transport *,void *,int );int (*read) (struct v9fs_transport *,void *,int );void (*close) (struct v9fs_transport *); +unsigned int (*poll)(struct v9fs_transport *,struct poll_table_struct *); };extern struct v9fs_transport v9fs_trans_tcp;
fs/9p/v9fs.c +30 -11
99 lines not on this page · raw message
fs/9p/v9fs.h +5 -12
@@ -57,24 +57,14 @@ struct v9fs_session_info {/* book keeping */ struct v9fs_idpool fidpool;/* The FID pool for file descriptors */ -struct v9fs_idpool tidpool;/* The TID pool for transactions ids */ -/* transport information */ struct v9fs_transport *transport; +struct v9fs_mux_data *mux;int inprogress;/* session in progress => true */ int shutdown;/* session shutting down. no more attaches. */ unsigned char session_hung; - -/* mux private data */ -struct v9fs_fcall *curfcall; -wait_queue_head_t read_wait; -struct completion fcread; -struct completion proccmpl; -struct task_struct *recvproc; - -spinlock_t muxlock; -struct list_head mux_fcalls; +struct dentry *debugfs_dir; };/* possible values of ->proto */
@@ -84,11 +74,14 @@ enum { PROTO_FD, }; +extern struct dentry *v9fs_debugfs_root; +int v9fs_session_init (struct v9fs_session_info *,const char *,char *);struct v9fs_session_info *v9fs_inode2v9ses (struct inode *);void v9fs_session_close (struct v9fs_session_info *v9ses);int v9fs_get_idpool (struct v9fs_idpool *p);void v9fs_put_idpool (int id,struct v9fs_idpool *p); +int v9fs_check_idpool (int id,struct v9fs_idpool *p);void v9fs_session_cancel (struct v9fs_session_info *v9ses);#define V9FS_MAGIC 0x01021997
fs/9p/vfs_dentry.c +5 -8
@@ -95,24 +95,21 @@ static int v9fs_dentry_validate(struct dvoid v9fs_dentry_release (struct dentry *dentry) { +int err; +dprintk (DEBUG_VFS ," dentry: %s (%p)\n" , dentry->d_iname, dentry);if (dentry->d_fsdata !=NULL ) {struct list_head *fid_list = dentry->d_fsdata;struct v9fs_fid *temp =NULL ;struct v9fs_fid *current_fid =NULL ; -struct v9fs_fcall *fcall =NULL ;list_for_each_entry_safe (current_fid, temp, fid_list, list) { -if (v9fs_t_clunk - (current_fid->v9ses, current_fid->fid, &fcall)) -dprintk (DEBUG_ERROR ,"clunk failed: %s\n" , -FCALL_ERROR (fcall)); + err =v9fs_t_clunk (current_fid->v9ses, current_fid->fid); -v9fs_put_idpool (current_fid->fid, - ¤t_fid->v9ses->fidpool); +if (err <0 ) +dprintk (DEBUG_ERROR ,"clunk failed: %d\n" , err); -kfree (fcall);v9fs_fid_destroy (current_fid); }
fs/9p/vfs_dir.c +7 -10
@@ -74,7 +74,7 @@ static int v9fs_dir_readdir(struct filestruct inode *inode = filp->f_dentry->d_inode;struct v9fs_session_info *v9ses =v9fs_inode2v9ses (inode);struct v9fs_fid *file = filp->private_data; -unsigned int i, n; +unsigned int i, n, s;int fid =-1 ;int ret =0 ;struct v9fs_stat *mi =NULL ;
@@ -97,9 +97,9 @@ static int v9fs_dir_readdir(struct file n = file->rdir_fcall->params.rread.count; i = file->rdir_fpos;while (i < n) { -int s =v9fs_deserialize_stat (v9ses, - file->rdir_fcall->params.rread.data + i, - n - i, mi, v9ses->maxdata); + s =v9fs_deserialize_stat ( + file->rdir_fcall->params.rread.data + i, + n - i, mi, v9ses->maxdata, v9ses->extended);if (s ==0 ) { dprintk(DEBUG_ERROR,
@@ -141,9 +141,8 @@ static int v9fs_dir_readdir(struct file n = ret; i =0 ;while (i < n) { -int s =v9fs_deserialize_stat (v9ses, - fcall->params.rread.data + i, n - i, mi, - v9ses->maxdata); + s =v9fs_deserialize_stat (fcall->params.rread.data + i, + n - i, mi, v9ses->maxdata, v9ses->extended);if (s ==0 ) { dprintk(DEBUG_ERROR,
@@ -200,11 +199,9 @@ int v9fs_dir_release(struct inode *inodedprintk (DEBUG_VFS ,"fidopen: %d v9f->fid: %d\n" , fid->fidopen, fid->fid); -if (v9fs_t_clunk (v9ses, fidnum,NULL )) +if (v9fs_t_clunk (v9ses, fidnum))dprintk (DEBUG_ERROR ,"clunk failed\n" ); -v9fs_put_idpool (fid->fid, &v9ses->fidpool); -kfree (fid->rdir_fcall);kfree (fid);
fs/9p/vfs_inode.c +42 -47
173 lines not on this page · raw message
fs/9p/vfs_super.c +2 -1
@@ -129,6 +129,7 @@ static struct super_block *v9fs_get_sb(sif ((newfid =v9fs_session_init (v9ses, dev_name, data)) <0 ) {dprintk (DEBUG_ERROR ,"problem initiating session\n" ); +kfree (v9ses);return ERR_PTR (newfid); }
@@ -157,7 +158,7 @@ static struct super_block *v9fs_get_sb(s stat_result =v9fs_t_stat (v9ses, newfid, &fcall);if (stat_result <0 ) {dprintk (DEBUG_ERROR ,"stat error\n" ); -v9fs_t_clunk (v9ses, newfid,NULL ); +v9fs_t_clunk (v9ses, newfid);v9fs_put_idpool (newfid, &v9ses->fidpool); }else {/* Setup the Root Inode */
Signature · 1 line
1.0.6