aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Van Hensbergen <ericvh@ericvh-desktop.(none)>2008-03-05 08:08:09 -0500
committerEric Van Hensbergen <ericvh@opteron.9grid.us>2008-05-14 20:23:25 -0400
commitee443996a35c1e04f210cafd43d5a98d41e46085 (patch)
tree58ee72b69a02d9dbb3a98e402a4561baba0eb9a8
parentb32a09db4fb9a87246ba4e7726a979ac4709ad97 (diff)
9p: Documentation updates
The kernel-doc comments of much of the 9p system have been in disarray since reorganization. This patch fixes those problems, adds additional documentation and a template book which collects the 9p information. Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
-rw-r--r--fs/9p/fid.h15
-rw-r--r--fs/9p/v9fs.c8
-rw-r--r--fs/9p/v9fs.h85
-rw-r--r--fs/9p/vfs_addr.c2
-rw-r--r--fs/9p/vfs_dir.c2
-rw-r--r--fs/9p/vfs_file.c11
-rw-r--r--fs/9p/vfs_inode.c50
-rw-r--r--fs/9p/vfs_super.c1
-rw-r--r--include/net/9p/9p.h239
-rw-r--r--include/net/9p/client.h35
-rw-r--r--include/net/9p/transport.h43
-rw-r--r--net/9p/conv.c128
-rw-r--r--net/9p/error.c11
-rw-r--r--net/9p/fcprint.c8
-rw-r--r--net/9p/mod.c7
-rw-r--r--net/9p/trans_fd.c146
-rw-r--r--net/9p/trans_virtio.c155
-rw-r--r--net/9p/util.c32
18 files changed, 854 insertions, 124 deletions
diff --git a/fs/9p/fid.h b/fs/9p/fid.h
index 26e07df783b9..c3bbd6af996d 100644
--- a/fs/9p/fid.h
+++ b/fs/9p/fid.h
@@ -22,6 +22,21 @@
22 22
23#include <linux/list.h> 23#include <linux/list.h>
24 24
25/**
26 * struct v9fs_dentry - 9p private data stored in dentry d_fsdata
27 * @lock: protects the fidlist
28 * @fidlist: list of FIDs currently associated with this dentry
29 *
30 * This structure defines the 9p private data associated with
31 * a particular dentry. In particular, this private data is used
32 * to lookup which 9P FID handle should be used for a particular VFS
33 * operation. FID handles are associated with dentries instead of
34 * inodes in order to more closely map functionality to the Plan 9
35 * expected behavior for FID reclaimation and tracking.
36 *
37 * See Also: Mapping FIDs to Linux VFS model in
38 * Design and Implementation of the Linux 9P File System documentation
39 */
25struct v9fs_dentry { 40struct v9fs_dentry {
26 spinlock_t lock; /* protect fidlist */ 41 spinlock_t lock; /* protect fidlist */
27 struct list_head fidlist; 42 struct list_head fidlist;
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index e307fbd34fa0..79d310c00188 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -71,7 +71,6 @@ static match_table_t tokens = {
71 71
72/** 72/**
73 * v9fs_parse_options - parse mount options into session structure 73 * v9fs_parse_options - parse mount options into session structure
74 * @options: options string passed from mount
75 * @v9ses: existing v9fs session information 74 * @v9ses: existing v9fs session information
76 * 75 *
77 */ 76 */
@@ -256,9 +255,12 @@ void v9fs_session_close(struct v9fs_session_info *v9ses)
256} 255}
257 256
258/** 257/**
259 * v9fs_session_cancel - mark transport as disconnected 258 * v9fs_session_cancel - terminate a session
260 * and cancel all pending requests. 259 * @v9ses: session to terminate
260 *
261 * mark transport as disconnected and cancel all pending requests.
261 */ 262 */
263
262void v9fs_session_cancel(struct v9fs_session_info *v9ses) { 264void v9fs_session_cancel(struct v9fs_session_info *v9ses) {
263 P9_DPRINTK(P9_DEBUG_ERROR, "cancel session %p\n", v9ses); 265 P9_DPRINTK(P9_DEBUG_ERROR, "cancel session %p\n", v9ses);
264 p9_client_disconnect(v9ses->clnt); 266 p9_client_disconnect(v9ses->clnt);
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index 7d3a1018db52..a7d567192998 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -21,18 +21,69 @@
21 * 21 *
22 */ 22 */
23 23
24/* 24/**
25 * Session structure provides information for an opened session 25 * enum p9_session_flags - option flags for each 9P session
26 * 26 * @V9FS_EXTENDED: whether or not to use 9P2000.u extensions
27 */ 27 * @V9FS_ACCESS_SINGLE: only the mounting user can access the hierarchy
28 * @V9FS_ACCESS_USER: a new attach will be issued for every user (default)
29 * @V9FS_ACCESS_ANY: use a single attach for all users
30 * @V9FS_ACCESS_MASK: bit mask of different ACCESS options
31 *
32 * Session flags reflect options selected by users at mount time
33 */
34enum p9_session_flags {
35 V9FS_EXTENDED = 0x01,
36 V9FS_ACCESS_SINGLE = 0x02,
37 V9FS_ACCESS_USER = 0x04,
38 V9FS_ACCESS_ANY = 0x06,
39 V9FS_ACCESS_MASK = 0x06,
40};
41
42/* possible values of ->cache */
43/**
44 * enum p9_cache_modes - user specified cache preferences
45 * @CACHE_NONE: do not cache data, dentries, or directory contents (default)
46 * @CACHE_LOOSE: cache data, dentries, and directory contents w/no consistency
47 *
48 * eventually support loose, tight, time, session, default always none
49 */
50
51enum p9_cache_modes {
52 CACHE_NONE,
53 CACHE_LOOSE,
54};
55
56/**
57 * struct v9fs_session_info - per-instance session information
58 * @flags: session options of type &p9_session_flags
59 * @nodev: set to 1 to disable device mapping
60 * @debug: debug level
61 * @afid: authentication handle
62 * @cache: cache mode of type &p9_cache_modes
63 * @options: copy of options string given by user
64 * @uname: string user name to mount hierarchy as
65 * @aname: mount specifier for remote hierarchy
66 * @maxdata: maximum data to be sent/recvd per protocol message
67 * @dfltuid: default numeric userid to mount hierarchy as
68 * @dfltgid: default numeric groupid to mount hierarchy as
69 * @uid: if %V9FS_ACCESS_SINGLE, the numeric uid which mounted the hierarchy
70 * @clnt: reference to 9P network client instantiated for this session
71 * @debugfs_dir: reference to debugfs_dir which can be used for add'l debug
72 *
73 * This structure holds state for each session instance established during
74 * a sys_mount() .
75 *
76 * Bugs: there seems to be a lot of state which could be condensed and/or
77 * removed.
78 */
28 79
29struct v9fs_session_info { 80struct v9fs_session_info {
30 /* options */ 81 /* options */
31 unsigned char flags; /* session flags */ 82 unsigned char flags;
32 unsigned char nodev; /* set to 1 if no disable device mapping */ 83 unsigned char nodev;
33 unsigned short debug; /* debug level */ 84 unsigned short debug;
34 unsigned int afid; /* authentication fid */ 85 unsigned int afid;
35 unsigned int cache; /* cache mode */ 86 unsigned int cache;
36 87
37 char *options; /* copy of mount options */ 88 char *options; /* copy of mount options */
38 char *uname; /* user name to mount as */ 89 char *uname; /* user name to mount as */
@@ -45,22 +96,6 @@ struct v9fs_session_info {
45 struct dentry *debugfs_dir; 96 struct dentry *debugfs_dir;
46}; 97};
47 98
48/* session flags */
49enum {
50 V9FS_EXTENDED = 0x01, /* 9P2000.u */
51 V9FS_ACCESS_MASK = 0x06, /* access mask */
52 V9FS_ACCESS_SINGLE = 0x02, /* only one user can access the files */
53 V9FS_ACCESS_USER = 0x04, /* attache per user */
54 V9FS_ACCESS_ANY = 0x06, /* use the same attach for all users */
55};
56
57/* possible values of ->cache */
58/* eventually support loose, tight, time, session, default always none */
59enum {
60 CACHE_NONE, /* default */
61 CACHE_LOOSE, /* no consistency */
62};
63
64extern struct dentry *v9fs_debugfs_root; 99extern struct dentry *v9fs_debugfs_root;
65 100
66struct p9_fid *v9fs_session_init(struct v9fs_session_info *, const char *, 101struct p9_fid *v9fs_session_init(struct v9fs_session_info *, const char *,
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index 6248f0e727a3..97d3aed57983 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -43,7 +43,7 @@
43/** 43/**
44 * v9fs_vfs_readpage - read an entire page in from 9P 44 * v9fs_vfs_readpage - read an entire page in from 9P
45 * 45 *
46 * @file: file being read 46 * @filp: file being read
47 * @page: structure to page 47 * @page: structure to page
48 * 48 *
49 */ 49 */
diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c
index 0924d4477da3..88e3787c6ea9 100644
--- a/fs/9p/vfs_dir.c
+++ b/fs/9p/vfs_dir.c
@@ -60,7 +60,7 @@ static inline int dt_type(struct p9_stat *mistat)
60 60
61/** 61/**
62 * v9fs_dir_readdir - read a directory 62 * v9fs_dir_readdir - read a directory
63 * @filep: opened file structure 63 * @filp: opened file structure
64 * @dirent: directory structure ??? 64 * @dirent: directory structure ???
65 * @filldir: function to populate directory structure ??? 65 * @filldir: function to populate directory structure ???
66 * 66 *
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index a616fff8906d..0d55affe37d4 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -90,10 +90,11 @@ int v9fs_file_open(struct inode *inode, struct file *file)
90 90
91/** 91/**
92 * v9fs_file_lock - lock a file (or directory) 92 * v9fs_file_lock - lock a file (or directory)
93 * @inode: inode to be opened 93 * @filp: file to be locked
94 * @file: file being opened 94 * @cmd: lock command
95 * @fl: file lock structure
95 * 96 *
96 * XXX - this looks like a local only lock, we should extend into 9P 97 * Bugs: this looks like a local only lock, we should extend into 9P
97 * by using open exclusive 98 * by using open exclusive
98 */ 99 */
99 100
@@ -118,7 +119,7 @@ static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
118 119
119/** 120/**
120 * v9fs_file_read - read from a file 121 * v9fs_file_read - read from a file
121 * @filep: file pointer to read 122 * @filp: file pointer to read
122 * @data: data buffer to read data into 123 * @data: data buffer to read data into
123 * @count: size of buffer 124 * @count: size of buffer
124 * @offset: offset at which to read data 125 * @offset: offset at which to read data
@@ -142,7 +143,7 @@ v9fs_file_read(struct file *filp, char __user * data, size_t count,
142 143
143/** 144/**
144 * v9fs_file_write - write to a file 145 * v9fs_file_write - write to a file
145 * @filep: file pointer to write 146 * @filp: file pointer to write
146 * @data: data buffer to write data from 147 * @data: data buffer to write data from
147 * @count: size of buffer 148 * @count: size of buffer
148 * @offset: offset at which to write data 149 * @offset: offset at which to write data
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 6a28842052ea..40fa807bd929 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -129,6 +129,12 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
129 return res; 129 return res;
130} 130}
131 131
132/**
133 * v9fs_uflags2omode- convert posix open flags to plan 9 mode bits
134 * @uflags: flags to convert
135 *
136 */
137
132int v9fs_uflags2omode(int uflags) 138int v9fs_uflags2omode(int uflags)
133{ 139{
134 int ret; 140 int ret;
@@ -312,6 +318,14 @@ error:
312} 318}
313*/ 319*/
314 320
321/**
322 * v9fs_inode_from_fid - populate an inode by issuing a attribute request
323 * @v9ses: session information
324 * @fid: fid to issue attribute request for
325 * @sb: superblock on which to create inode
326 *
327 */
328
315static struct inode * 329static struct inode *
316v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid, 330v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
317 struct super_block *sb) 331 struct super_block *sb)
@@ -384,9 +398,12 @@ v9fs_open_created(struct inode *inode, struct file *file)
384 398
385/** 399/**
386 * v9fs_create - Create a file 400 * v9fs_create - Create a file
401 * @v9ses: session information
402 * @dir: directory that dentry is being created in
387 * @dentry: dentry that is being created 403 * @dentry: dentry that is being created
388 * @perm: create permissions 404 * @perm: create permissions
389 * @mode: open mode 405 * @mode: open mode
406 * @extension: 9p2000.u extension string to support devices, etc.
390 * 407 *
391 */ 408 */
392static struct p9_fid * 409static struct p9_fid *
@@ -461,7 +478,7 @@ error:
461 478
462/** 479/**
463 * v9fs_vfs_create - VFS hook to create files 480 * v9fs_vfs_create - VFS hook to create files
464 * @inode: directory inode that is being created 481 * @dir: directory inode that is being created
465 * @dentry: dentry that is being deleted 482 * @dentry: dentry that is being deleted
466 * @mode: create permissions 483 * @mode: create permissions
467 * @nd: path information 484 * @nd: path information
@@ -519,7 +536,7 @@ error:
519 536
520/** 537/**
521 * v9fs_vfs_mkdir - VFS mkdir hook to create a directory 538 * v9fs_vfs_mkdir - VFS mkdir hook to create a directory
522 * @inode: inode that is being unlinked 539 * @dir: inode that is being unlinked
523 * @dentry: dentry that is being unlinked 540 * @dentry: dentry that is being unlinked
524 * @mode: mode for new directory 541 * @mode: mode for new directory
525 * 542 *
@@ -703,9 +720,9 @@ done:
703 720
704/** 721/**
705 * v9fs_vfs_getattr - retrieve file metadata 722 * v9fs_vfs_getattr - retrieve file metadata
706 * @mnt - mount information 723 * @mnt: mount information
707 * @dentry - file to get attributes on 724 * @dentry: file to get attributes on
708 * @stat - metadata structure to populate 725 * @stat: metadata structure to populate
709 * 726 *
710 */ 727 */
711 728
@@ -928,7 +945,7 @@ done:
928/** 945/**
929 * v9fs_vfs_readlink - read a symlink's location 946 * v9fs_vfs_readlink - read a symlink's location
930 * @dentry: dentry for symlink 947 * @dentry: dentry for symlink
931 * @buf: buffer to load symlink location into 948 * @buffer: buffer to load symlink location into
932 * @buflen: length of buffer 949 * @buflen: length of buffer
933 * 950 *
934 */ 951 */
@@ -996,10 +1013,12 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
996 * v9fs_vfs_put_link - release a symlink path 1013 * v9fs_vfs_put_link - release a symlink path
997 * @dentry: dentry for symlink 1014 * @dentry: dentry for symlink
998 * @nd: nameidata 1015 * @nd: nameidata
1016 * @p: unused
999 * 1017 *
1000 */ 1018 */
1001 1019
1002static void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p) 1020static void
1021v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
1003{ 1022{
1004 char *s = nd_get_link(nd); 1023 char *s = nd_get_link(nd);
1005 1024
@@ -1008,6 +1027,15 @@ static void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void
1008 __putname(s); 1027 __putname(s);
1009} 1028}
1010 1029
1030/**
1031 * v9fs_vfs_mkspecial - create a special file
1032 * @dir: inode to create special file in
1033 * @dentry: dentry to create
1034 * @mode: mode to create special file
1035 * @extension: 9p2000.u format extension string representing special file
1036 *
1037 */
1038
1011static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, 1039static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1012 int mode, const char *extension) 1040 int mode, const char *extension)
1013{ 1041{
@@ -1037,7 +1065,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1037 * @dentry: dentry for symlink 1065 * @dentry: dentry for symlink
1038 * @symname: symlink data 1066 * @symname: symlink data
1039 * 1067 *
1040 * See 9P2000.u RFC for more information 1068 * See Also: 9P2000.u RFC for more information
1041 * 1069 *
1042 */ 1070 */
1043 1071
@@ -1058,10 +1086,6 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
1058 * 1086 *
1059 */ 1087 */
1060 1088
1061/* XXX - lots of code dup'd from symlink and creates,
1062 * figure out a better reuse strategy
1063 */
1064
1065static int 1089static int
1066v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir, 1090v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
1067 struct dentry *dentry) 1091 struct dentry *dentry)
@@ -1098,7 +1122,7 @@ clunk_fid:
1098 * @dir: inode destination for new link 1122 * @dir: inode destination for new link
1099 * @dentry: dentry for file 1123 * @dentry: dentry for file
1100 * @mode: mode for creation 1124 * @mode: mode for creation
1101 * @dev_t: device associated with special file 1125 * @rdev: device associated with special file
1102 * 1126 *
1103 */ 1127 */
1104 1128
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index a452ac67fc94..ba10f172626d 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -75,6 +75,7 @@ static int v9fs_set_super(struct super_block *s, void *data)
75 * v9fs_fill_super - populate superblock with info 75 * v9fs_fill_super - populate superblock with info
76 * @sb: superblock 76 * @sb: superblock
77 * @v9ses: session information 77 * @v9ses: session information
78 * @flags: flags propagated from v9fs_get_sb()
78 * 79 *
79 */ 80 */
80 81
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
index 585eb4496990..7bfb2f2e423c 100644
--- a/include/net/9p/9p.h
+++ b/include/net/9p/9p.h
@@ -29,14 +29,31 @@
29 29
30#ifdef CONFIG_NET_9P_DEBUG 30#ifdef CONFIG_NET_9P_DEBUG
31 31
32#define P9_DEBUG_ERROR (1<<0) 32/**
33#define P9_DEBUG_9P (1<<2) 33 * enum p9_debug_flags - bits for mount time debug parameter
34#define P9_DEBUG_VFS (1<<3) 34 * @P9_DEBUG_ERROR: more verbose error messages including original error string
35#define P9_DEBUG_CONV (1<<4) 35 * @P9_DEBUG_9P: 9P protocol tracing
36#define P9_DEBUG_MUX (1<<5) 36 * @P9_DEBUG_VFS: VFS API tracing
37#define P9_DEBUG_TRANS (1<<6) 37 * @P9_DEBUG_CONV: protocol conversion tracing
38#define P9_DEBUG_SLABS (1<<7) 38 * @P9_DEBUG_MUX: trace management of concurrent transactions
39#define P9_DEBUG_FCALL (1<<8) 39 * @P9_DEBUG_TRANS: transport tracing
40 * @P9_DEBUG_SLABS: memory management tracing
41 * @P9_DEBUG_FCALL: verbose dump of protocol messages
42 *
43 * These flags are passed at mount time to turn on various levels of
44 * verbosity and tracing which will be output to the system logs.
45 */
46
47enum p9_debug_flags {
48 P9_DEBUG_ERROR = (1<<0),
49 P9_DEBUG_9P = (1<<2),
50 P9_DEBUG_VFS = (1<<3),
51 P9_DEBUG_CONV = (1<<4),
52 P9_DEBUG_MUX = (1<<5),
53 P9_DEBUG_TRANS = (1<<6),
54 P9_DEBUG_SLABS = (1<<7),
55 P9_DEBUG_FCALL = (1<<8),
56};
40 57
41extern unsigned int p9_debug_level; 58extern unsigned int p9_debug_level;
42 59
@@ -62,9 +79,47 @@ do { \
62 format , __FUNCTION__, task_pid_nr(current), ## arg); \ 79 format , __FUNCTION__, task_pid_nr(current), ## arg); \
63} while (0) 80} while (0)
64 81
82/**
83 * enum p9_msg_t - 9P message types
84 * @P9_TVERSION: version handshake request
85 * @P9_RVERSION: version handshake response
86 * @P9_TAUTH: request to establish authentication channel
87 * @P9_RAUTH: response with authentication information
88 * @P9_TATTACH: establish user access to file service
89 * @P9_RATTACH: response with top level handle to file hierarchy
90 * @P9_TERROR: not used
91 * @P9_RERROR: response for any failed request
92 * @P9_TFLUSH: request to abort a previous request
93 * @P9_RFLUSH: response when previous request has been cancelled
94 * @P9_TWALK: descend a directory hierarchy
95 * @P9_RWALK: response with new handle for position within hierarchy
96 * @P9_TOPEN: prepare a handle for I/O on an existing file
97 * @P9_ROPEN: response with file access information
98 * @P9_TCREATE: prepare a handle for I/O on a new file
99 * @P9_RCREATE: response with file access information
100 * @P9_TREAD: request to transfer data from a file or directory
101 * @P9_RREAD: response with data requested
102 * @P9_TWRITE: reuqest to transfer data to a file
103 * @P9_RWRITE: response with out much data was transfered to file
104 * @P9_TCLUNK: forget about a handle to an entity within the file system
105 * @P9_RCLUNK: response when server has forgotten about the handle
106 * @P9_TREMOVE: request to remove an entity from the hierarchy
107 * @P9_RREMOVE: response when server has removed the entity
108 * @P9_TSTAT: request file entity attributes
109 * @P9_RSTAT: response with file entity attributes
110 * @P9_TWSTAT: request to update file entity attributes
111 * @P9_RWSTAT: response when file entity attributes are updated
112 *
113 * There are 14 basic operations in 9P2000, paired as
114 * requests and responses. The one special case is ERROR
115 * as there is no @P9_TERROR request for clients to transmit to
116 * the server, but the server may respond to any other request
117 * with an @P9_RERROR.
118 *
119 * See Also: http://plan9.bell-labs.com/sys/man/5/INDEX.html
120 */
65 121
66/* Message Types */ 122enum p9_msg_t {
67enum {
68 P9_TVERSION = 100, 123 P9_TVERSION = 100,
69 P9_RVERSION, 124 P9_RVERSION,
70 P9_TAUTH = 102, 125 P9_TAUTH = 102,
@@ -95,30 +150,71 @@ enum {
95 P9_RWSTAT, 150 P9_RWSTAT,
96}; 151};
97 152
98/* open modes */ 153/**
99enum { 154 * enum p9_open_mode_t - 9P open modes
155 * @P9_OREAD: open file for reading only
156 * @P9_OWRITE: open file for writing only
157 * @P9_ORDWR: open file for reading or writing
158 * @P9_OEXEC: open file for execution
159 * @P9_OTRUNC: truncate file to zero-length before opening it
160 * @P9_OREXEC: close the file when an exec(2) system call is made
161 * @P9_ORCLOSE: remove the file when the file is closed
162 * @P9_OAPPEND: open the file and seek to the end
163 * @P9_OEXCL: only create a file, do not open it
164 *
165 * 9P open modes differ slightly from Posix standard modes.
166 * In particular, there are extra modes which specify different
167 * semantic behaviors than may be available on standard Posix
168 * systems. For example, @P9_OREXEC and @P9_ORCLOSE are modes that
169 * most likely will not be issued from the Linux VFS client, but may
170 * be supported by servers.
171 *
172 * See Also: http://plan9.bell-labs.com/magic/man2html/2/open
173 */
174
175enum p9_open_mode_t {
100 P9_OREAD = 0x00, 176 P9_OREAD = 0x00,
101 P9_OWRITE = 0x01, 177 P9_OWRITE = 0x01,
102 P9_ORDWR = 0x02, 178 P9_ORDWR = 0x02,
103 P9_OEXEC = 0x03, 179 P9_OEXEC = 0x03,
104 P9_OEXCL = 0x04,
105 P9_OTRUNC = 0x10, 180 P9_OTRUNC = 0x10,
106 P9_OREXEC = 0x20, 181 P9_OREXEC = 0x20,
107 P9_ORCLOSE = 0x40, 182 P9_ORCLOSE = 0x40,
108 P9_OAPPEND = 0x80, 183 P9_OAPPEND = 0x80,
109}; 184 P9_OEXCL = 0x1000,
110 185};
111/* permissions */ 186
112enum { 187/**
188 * enum p9_perm_t - 9P permissions
189 * @P9_DMDIR: mode bite for directories
190 * @P9_DMAPPEND: mode bit for is append-only
191 * @P9_DMEXCL: mode bit for excluse use (only one open handle allowed)
192 * @P9_DMMOUNT: mode bite for mount points
193 * @P9_DMAUTH: mode bit for authentication file
194 * @P9_DMTMP: mode bit for non-backed-up files
195 * @P9_DMSYMLINK: mode bit for symbolic links (9P2000.u)
196 * @P9_DMLINK: mode bit for hard-link (9P2000.u)
197 * @P9_DMDEVICE: mode bit for device files (9P2000.u)
198 * @P9_DMNAMEDPIPE: mode bit for named pipe (9P2000.u)
199 * @P9_DMSOCKET: mode bit for socket (9P2000.u)
200 * @P9_DMSETUID: mode bit for setuid (9P2000.u)
201 * @P9_DMSETGID: mode bit for setgid (9P2000.u)
202 * @P9_DMSETVTX: mode bit for sticky bit (9P2000.u)
203 *
204 * 9P permissions differ slightly from Posix standard modes.
205 *
206 * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat
207 */
208enum p9_perm_t {
113 P9_DMDIR = 0x80000000, 209 P9_DMDIR = 0x80000000,
114 P9_DMAPPEND = 0x40000000, 210 P9_DMAPPEND = 0x40000000,
115 P9_DMEXCL = 0x20000000, 211 P9_DMEXCL = 0x20000000,
116 P9_DMMOUNT = 0x10000000, 212 P9_DMMOUNT = 0x10000000,
117 P9_DMAUTH = 0x08000000, 213 P9_DMAUTH = 0x08000000,
118 P9_DMTMP = 0x04000000, 214 P9_DMTMP = 0x04000000,
215/* 9P2000.u extensions */
119 P9_DMSYMLINK = 0x02000000, 216 P9_DMSYMLINK = 0x02000000,
120 P9_DMLINK = 0x01000000, 217 P9_DMLINK = 0x01000000,
121 /* 9P2000.u extensions */
122 P9_DMDEVICE = 0x00800000, 218 P9_DMDEVICE = 0x00800000,
123 P9_DMNAMEDPIPE = 0x00200000, 219 P9_DMNAMEDPIPE = 0x00200000,
124 P9_DMSOCKET = 0x00100000, 220 P9_DMSOCKET = 0x00100000,
@@ -127,8 +223,26 @@ enum {
127 P9_DMSETVTX = 0x00010000, 223 P9_DMSETVTX = 0x00010000,
128}; 224};
129 225
130/* qid.types */ 226/**
131enum { 227 * enum p9_qid_t - QID types
228 * @P9_QTDIR: directory
229 * @P9_QTAPPEND: append-only
230 * @P9_QTEXCL: excluse use (only one open handle allowed)
231 * @P9_QTMOUNT: mount points
232 * @P9_QTAUTH: authentication file
233 * @P9_QTTMP: non-backed-up files
234 * @P9_QTSYMLINK: symbolic links (9P2000.u)
235 * @P9_QTLINK: hard-link (9P2000.u)
236 * @P9_QTFILE: normal files
237 *
238 * QID types are a subset of permissions - they are primarily
239 * used to differentiate semantics for a file system entity via
240 * a jump-table. Their value is also the most signifigant 16 bits
241 * of the permission_t
242 *
243 * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat
244 */
245enum p9_qid_t {
132 P9_QTDIR = 0x80, 246 P9_QTDIR = 0x80,
133 P9_QTAPPEND = 0x40, 247 P9_QTAPPEND = 0x40,
134 P9_QTEXCL = 0x20, 248 P9_QTEXCL = 0x20,
@@ -140,6 +254,7 @@ enum {
140 P9_QTFILE = 0x00, 254 P9_QTFILE = 0x00,
141}; 255};
142 256
257/* 9P Magic Numbers */
143#define P9_NOTAG (u16)(~0) 258#define P9_NOTAG (u16)(~0)
144#define P9_NOFID (u32)(~0) 259#define P9_NOFID (u32)(~0)
145#define P9_MAXWELEM 16 260#define P9_MAXWELEM 16
@@ -147,19 +262,69 @@ enum {
147/* ample room for Twrite/Rread header */ 262/* ample room for Twrite/Rread header */
148#define P9_IOHDRSZ 24 263#define P9_IOHDRSZ 24
149 264
265/**
266 * struct p9_str - length prefixed string type
267 * @len: length of the string
268 * @str: the string
269 *
270 * The protocol uses length prefixed strings for all
271 * string data, so we replicate that for our internal
272 * string members.
273 */
274
150struct p9_str { 275struct p9_str {
151 u16 len; 276 u16 len;
152 char *str; 277 char *str;
153}; 278};
154 279
155/* qids are the unique ID for a file (like an inode */ 280/**
281 * struct p9_qid - file system entity information
282 * @type: 8-bit type &p9_qid_t
283 * @version: 16-bit monotonically incrementing version number
284 * @path: 64-bit per-server-unique ID for a file system element
285 *
286 * qids are identifiers used by 9P servers to track file system
287 * entities. The type is used to differentiate semantics for operations
288 * on the entity (ie. read means something different on a directory than
289 * on a file). The path provides a server unique index for an entity
290 * (roughly analogous to an inode number), while the version is updated
291 * every time a file is modified and can be used to maintain cache
292 * coherency between clients and serves.
293 * Servers will often differentiate purely synthetic entities by setting
294 * their version to 0, signaling that they should never be cached and
295 * should be accessed synchronously.
296 *
297 * See Also://plan9.bell-labs.com/magic/man2html/2/stat
298 */
299
156struct p9_qid { 300struct p9_qid {
157 u8 type; 301 u8 type;
158 u32 version; 302 u32 version;
159 u64 path; 303 u64 path;
160}; 304};
161 305
162/* Plan 9 file metadata (stat) structure */ 306/**
307 * struct p9_stat - file system metadata information
308 * @size: length prefix for this stat structure instance
309 * @type: the type of the server (equivilent to a major number)
310 * @dev: the sub-type of the server (equivilent to a minor number)
311 * @qid: unique id from the server of type &p9_qid
312 * @mode: Plan 9 format permissions of type &p9_perm_t
313 * @atime: Last access/read time
314 * @mtime: Last modify/write time
315 * @length: file length
316 * @name: last element of path (aka filename) in type &p9_str
317 * @uid: owner name in type &p9_str
318 * @gid: group owner in type &p9_str
319 * @muid: last modifier in type &p9_str
320 * @extension: area used to encode extended UNIX support in type &p9_str
321 * @n_uid: numeric user id of owner (part of 9p2000.u extension)
322 * @n_gid: numeric group id (part of 9p2000.u extension)
323 * @n_muid: numeric user id of laster modifier (part of 9p2000.u extension)
324 *
325 * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat
326 */
327
163struct p9_stat { 328struct p9_stat {
164 u16 size; 329 u16 size;
165 u16 type; 330 u16 type;
@@ -179,10 +344,14 @@ struct p9_stat {
179 u32 n_muid; /* 9p2000.u extensions */ 344 u32 n_muid; /* 9p2000.u extensions */
180}; 345};
181 346
182/* file metadata (stat) structure used to create Twstat message 347/*
183 The is similar to p9_stat, but the strings don't point to 348 * file metadata (stat) structure used to create Twstat message
184 the same memory block and should be freed separately 349 * The is identical to &p9_stat, but the strings don't point to
185*/ 350 * the same memory block and should be freed separately
351 *
352 * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat
353 */
354
186struct p9_wstat { 355struct p9_wstat {
187 u16 size; 356 u16 size;
188 u16 type; 357 u16 type;
@@ -335,10 +504,20 @@ struct p9_twstat {
335struct p9_rwstat { 504struct p9_rwstat {
336}; 505};
337 506
338/* 507/**
339 * fcall is the primary packet structure 508 * struct p9_fcall - primary packet structure
340 * 509 * @size: prefixed length of the structure
341 */ 510 * @id: protocol operating identifier of type &p9_msg_t
511 * @tag: transaction id of the request
512 * @sdata: payload
513 * @params: per-operation parameters
514 *
515 * &p9_fcall represents the structure for all 9P RPC
516 * transactions. Requests are packaged into fcalls, and reponses
517 * must be extracted from them.
518 *
519 * See Also: http://plan9.bell-labs.com/magic/man2html/2/fcall
520 */
342 521
343struct p9_fcall { 522struct p9_fcall {
344 u32 size; 523 u32 size;
diff --git a/include/net/9p/client.h b/include/net/9p/client.h
index e52f93d9ac5f..c936dd14de41 100644
--- a/include/net/9p/client.h
+++ b/include/net/9p/client.h
@@ -26,6 +26,23 @@
26#ifndef NET_9P_CLIENT_H 26#ifndef NET_9P_CLIENT_H
27#define NET_9P_CLIENT_H 27#define NET_9P_CLIENT_H
28 28
29/**
30 * struct p9_client - per client instance state
31 * @lock: protect @fidlist
32 * @msize: maximum data size negotiated by protocol
33 * @dotu: extension flags negotiated by protocol
34 * @trans_mod: module API instantiated with this client
35 * @trans: tranport instance state and API
36 * @conn: connection state information used by trans_fd
37 * @fidpool: fid handle accounting for session
38 * @fidlist: List of active fid handles
39 *
40 * The client structure is used to keep track of various per-client
41 * state that has been instantiated.
42 *
43 * Bugs: duplicated data and potentially unnecessary elements.
44 */
45
29struct p9_client { 46struct p9_client {
30 spinlock_t lock; /* protect client structure */ 47 spinlock_t lock; /* protect client structure */
31 int msize; 48 int msize;
@@ -38,6 +55,24 @@ struct p9_client {
38 struct list_head fidlist; 55 struct list_head fidlist;
39}; 56};
40 57
58/**
59 * struct p9_fid - file system entity handle
60 * @clnt: back pointer to instantiating &p9_client
61 * @fid: numeric identifier for this handle
62 * @mode: current mode of this fid (enum?)
63 * @qid: the &p9_qid server identifier this handle points to
64 * @iounit: the server reported maximum transaction size for this file
65 * @uid: the numeric uid of the local user who owns this handle
66 * @aux: transport specific information (unused?)
67 * @rdir_fpos: tracks offset of file position when reading directory contents
68 * @rdir_pos: (unused?)
69 * @rdir_fcall: holds response of last directory read request
70 * @flist: per-client-instance fid tracking
71 * @dlist: per-dentry fid tracking
72 *
73 * TODO: This needs lots of explanation.
74 */
75
41struct p9_fid { 76struct p9_fid {
42 struct p9_client *clnt; 77 struct p9_client *clnt;
43 u32 fid; 78 u32 fid;
diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
index d2209ae9d18b..240e0de888c6 100644
--- a/include/net/9p/transport.h
+++ b/include/net/9p/transport.h
@@ -26,12 +26,40 @@
26#ifndef NET_9P_TRANSPORT_H 26#ifndef NET_9P_TRANSPORT_H
27#define NET_9P_TRANSPORT_H 27#define NET_9P_TRANSPORT_H
28 28
29/**
30 * enum p9_trans_status - different states of underlying transports
31 * @Connected: transport is connected and healthy
32 * @Disconnected: transport has been disconnected
33 * @Hung: transport is connected by wedged
34 *
35 * This enumeration details the various states a transport
36 * instatiation can be in.
37 */
38
29enum p9_trans_status { 39enum p9_trans_status {
30 Connected, 40 Connected,
31 Disconnected, 41 Disconnected,
32 Hung, 42 Hung,
33}; 43};
34 44
45/**
46 * struct p9_trans - per-transport state and API
47 * @status: transport &p9_trans_status
48 * @msize: negotiated maximum packet size (duplicate from client)
49 * @extended: negotiated protocol extensions (duplicate from client)
50 * @priv: transport private data
51 * @close: member function to disconnect and close the transport
52 * @rpc: member function to issue a request to the transport
53 *
54 * This is the basic API for a transport instance. It is used as
55 * a handle by the client to issue requests. This interface is currently
56 * in flux during reorganization.
57 *
58 * Bugs: there is lots of duplicated data here and its not clear that
59 * the member functions need to be per-instance versus per transport
60 * module.
61 */
62
35struct p9_trans { 63struct p9_trans {
36 enum p9_trans_status status; 64 enum p9_trans_status status;
37 int msize; 65 int msize;
@@ -42,6 +70,21 @@ struct p9_trans {
42 struct p9_fcall **rc); 70 struct p9_fcall **rc);
43}; 71};
44 72
73/**
74 * struct p9_trans_module - transport module interface
75 * @list: used to maintain a list of currently available transports
76 * @name: the human-readable name of the transport
77 * @maxsize: transport provided maximum packet size
78 * @def: set if this transport should be considered the default
79 * @create: member function to create a new connection on this transport
80 *
81 * This is the basic API for a transport module which is registered by the
82 * transport module with the 9P core network module and used by the client
83 * to instantiate a new connection on a transport.
84 *
85 * Bugs: the transport module list isn't protected.
86 */
87
45struct p9_trans_module { 88struct p9_trans_module {
46 struct list_head list; 89 struct list_head list;
47 char *name; /* name of transport */ 90 char *name; /* name of transport */
diff --git a/net/9p/conv.c b/net/9p/conv.c
index 3fe35d532c87..44547201f5bc 100644
--- a/net/9p/conv.c
+++ b/net/9p/conv.c
@@ -197,7 +197,7 @@ static void buf_get_qid(struct cbuf *bufp, struct p9_qid *qid)
197 197
198/** 198/**
199 * p9_size_wstat - calculate the size of a variable length stat struct 199 * p9_size_wstat - calculate the size of a variable length stat struct
200 * @stat: metadata (stat) structure 200 * @wstat: metadata (stat) structure
201 * @dotu: non-zero if 9P2000.u 201 * @dotu: non-zero if 9P2000.u
202 * 202 *
203 */ 203 */
@@ -511,6 +511,12 @@ p9_create_common(struct cbuf *bufp, u32 size, u8 id)
511 return fc; 511 return fc;
512} 512}
513 513
514/**
515 * p9_set_tag - set the tag field of an &p9_fcall structure
516 * @fc: fcall structure to set tag within
517 * @tag: tag id to set
518 */
519
514void p9_set_tag(struct p9_fcall *fc, u16 tag) 520void p9_set_tag(struct p9_fcall *fc, u16 tag)
515{ 521{
516 fc->tag = tag; 522 fc->tag = tag;
@@ -518,6 +524,12 @@ void p9_set_tag(struct p9_fcall *fc, u16 tag)
518} 524}
519EXPORT_SYMBOL(p9_set_tag); 525EXPORT_SYMBOL(p9_set_tag);
520 526
527/**
528 * p9_create_tversion - allocates and creates a T_VERSION request
529 * @msize: requested maximum data size
530 * @version: version string to negotiate
531 *
532 */
521struct p9_fcall *p9_create_tversion(u32 msize, char *version) 533struct p9_fcall *p9_create_tversion(u32 msize, char *version)
522{ 534{
523 int size; 535 int size;
@@ -542,6 +554,16 @@ error:
542} 554}
543EXPORT_SYMBOL(p9_create_tversion); 555EXPORT_SYMBOL(p9_create_tversion);
544 556
557/**
558 * p9_create_tauth - allocates and creates a T_AUTH request
559 * @afid: handle to use for authentication protocol
560 * @uname: user name attempting to authenticate
561 * @aname: mount specifier for remote server
562 * @n_uname: numeric id for user attempting to authneticate
563 * @dotu: 9P2000.u extension flag
564 *
565 */
566
545struct p9_fcall *p9_create_tauth(u32 afid, char *uname, char *aname, 567struct p9_fcall *p9_create_tauth(u32 afid, char *uname, char *aname,
546 u32 n_uname, int dotu) 568 u32 n_uname, int dotu)
547{ 569{
@@ -580,6 +602,18 @@ error:
580} 602}
581EXPORT_SYMBOL(p9_create_tauth); 603EXPORT_SYMBOL(p9_create_tauth);
582 604
605/**
606 * p9_create_tattach - allocates and creates a T_ATTACH request
607 * @fid: handle to use for the new mount point
608 * @afid: handle to use for authentication protocol
609 * @uname: user name attempting to attach
610 * @aname: mount specifier for remote server
611 * @n_uname: numeric id for user attempting to attach
612 * @n_uname: numeric id for user attempting to attach
613 * @dotu: 9P2000.u extension flag
614 *
615 */
616
583struct p9_fcall * 617struct p9_fcall *
584p9_create_tattach(u32 fid, u32 afid, char *uname, char *aname, 618p9_create_tattach(u32 fid, u32 afid, char *uname, char *aname,
585 u32 n_uname, int dotu) 619 u32 n_uname, int dotu)
@@ -616,6 +650,12 @@ error:
616} 650}
617EXPORT_SYMBOL(p9_create_tattach); 651EXPORT_SYMBOL(p9_create_tattach);
618 652
653/**
654 * p9_create_tflush - allocates and creates a T_FLUSH request
655 * @oldtag: tag id for the transaction we are attempting to cancel
656 *
657 */
658
619struct p9_fcall *p9_create_tflush(u16 oldtag) 659struct p9_fcall *p9_create_tflush(u16 oldtag)
620{ 660{
621 int size; 661 int size;
@@ -639,6 +679,15 @@ error:
639} 679}
640EXPORT_SYMBOL(p9_create_tflush); 680EXPORT_SYMBOL(p9_create_tflush);
641 681
682/**
683 * p9_create_twalk - allocates and creates a T_FLUSH request
684 * @fid: handle we are traversing from
685 * @newfid: a new handle for this transaction
686 * @nwname: number of path elements to traverse
687 * @wnames: array of path elements
688 *
689 */
690
642struct p9_fcall *p9_create_twalk(u32 fid, u32 newfid, u16 nwname, 691struct p9_fcall *p9_create_twalk(u32 fid, u32 newfid, u16 nwname,
643 char **wnames) 692 char **wnames)
644{ 693{
@@ -677,6 +726,13 @@ error:
677} 726}
678EXPORT_SYMBOL(p9_create_twalk); 727EXPORT_SYMBOL(p9_create_twalk);
679 728
729/**
730 * p9_create_topen - allocates and creates a T_OPEN request
731 * @fid: handle we are trying to open
732 * @mode: what mode we are trying to open the file in
733 *
734 */
735
680struct p9_fcall *p9_create_topen(u32 fid, u8 mode) 736struct p9_fcall *p9_create_topen(u32 fid, u8 mode)
681{ 737{
682 int size; 738 int size;
@@ -701,6 +757,19 @@ error:
701} 757}
702EXPORT_SYMBOL(p9_create_topen); 758EXPORT_SYMBOL(p9_create_topen);
703 759
760/**
761 * p9_create_tcreate - allocates and creates a T_CREATE request
762 * @fid: handle of directory we are trying to create in
763 * @name: name of the file we are trying to create
764 * @perm: permissions for the file we are trying to create
765 * @mode: what mode we are trying to open the file in
766 * @extension: 9p2000.u extension string (for special files)
767 * @dotu: 9p2000.u enabled flag
768 *
769 * Note: Plan 9 create semantics include opening the resulting file
770 * which is why mode is included.
771 */
772
704struct p9_fcall *p9_create_tcreate(u32 fid, char *name, u32 perm, u8 mode, 773struct p9_fcall *p9_create_tcreate(u32 fid, char *name, u32 perm, u8 mode,
705 char *extension, int dotu) 774 char *extension, int dotu)
706{ 775{
@@ -736,6 +805,13 @@ error:
736} 805}
737EXPORT_SYMBOL(p9_create_tcreate); 806EXPORT_SYMBOL(p9_create_tcreate);
738 807
808/**
809 * p9_create_tread - allocates and creates a T_READ request
810 * @fid: handle of the file we are trying to read
811 * @offset: offset to start reading from
812 * @count: how many bytes to read
813 */
814
739struct p9_fcall *p9_create_tread(u32 fid, u64 offset, u32 count) 815struct p9_fcall *p9_create_tread(u32 fid, u64 offset, u32 count)
740{ 816{
741 int size; 817 int size;
@@ -761,6 +837,17 @@ error:
761} 837}
762EXPORT_SYMBOL(p9_create_tread); 838EXPORT_SYMBOL(p9_create_tread);
763 839
840/**
841 * p9_create_twrite - allocates and creates a T_WRITE request from the kernel
842 * @fid: handle of the file we are trying to write
843 * @offset: offset to start writing at
844 * @count: how many bytes to write
845 * @data: data to write
846 *
847 * This function will create a requst with data buffers from the kernel
848 * such as the page cache.
849 */
850
764struct p9_fcall *p9_create_twrite(u32 fid, u64 offset, u32 count, 851struct p9_fcall *p9_create_twrite(u32 fid, u64 offset, u32 count,
765 const char *data) 852 const char *data)
766{ 853{
@@ -794,6 +881,16 @@ error:
794} 881}
795EXPORT_SYMBOL(p9_create_twrite); 882EXPORT_SYMBOL(p9_create_twrite);
796 883
884/**
885 * p9_create_twrite_u - allocates and creates a T_WRITE request from userspace
886 * @fid: handle of the file we are trying to write
887 * @offset: offset to start writing at
888 * @count: how many bytes to write
889 * @data: data to write
890 *
891 * This function will create a request with data buffers from userspace
892 */
893
797struct p9_fcall *p9_create_twrite_u(u32 fid, u64 offset, u32 count, 894struct p9_fcall *p9_create_twrite_u(u32 fid, u64 offset, u32 count,
798 const char __user *data) 895 const char __user *data)
799{ 896{
@@ -827,6 +924,14 @@ error:
827} 924}
828EXPORT_SYMBOL(p9_create_twrite_u); 925EXPORT_SYMBOL(p9_create_twrite_u);
829 926
927/**
928 * p9_create_tclunk - allocate a request to forget about a file handle
929 * @fid: handle of the file we closing or forgetting about
930 *
931 * clunk is used both to close open files and to discard transient handles
932 * which may be created during meta-data operations and hierarchy traversal.
933 */
934
830struct p9_fcall *p9_create_tclunk(u32 fid) 935struct p9_fcall *p9_create_tclunk(u32 fid)
831{ 936{
832 int size; 937 int size;
@@ -850,6 +955,12 @@ error:
850} 955}
851EXPORT_SYMBOL(p9_create_tclunk); 956EXPORT_SYMBOL(p9_create_tclunk);
852 957
958/**
959 * p9_create_tremove - allocate and create a request to remove a file
960 * @fid: handle of the file or directory we are removing
961 *
962 */
963
853struct p9_fcall *p9_create_tremove(u32 fid) 964struct p9_fcall *p9_create_tremove(u32 fid)
854{ 965{
855 int size; 966 int size;
@@ -873,6 +984,12 @@ error:
873} 984}
874EXPORT_SYMBOL(p9_create_tremove); 985EXPORT_SYMBOL(p9_create_tremove);
875 986
987/**
988 * p9_create_tstat - allocate and populate a request for attributes
989 * @fid: handle of the file or directory we are trying to get the attributes of
990 *
991 */
992
876struct p9_fcall *p9_create_tstat(u32 fid) 993struct p9_fcall *p9_create_tstat(u32 fid)
877{ 994{
878 int size; 995 int size;
@@ -896,6 +1013,14 @@ error:
896} 1013}
897EXPORT_SYMBOL(p9_create_tstat); 1014EXPORT_SYMBOL(p9_create_tstat);
898 1015
1016/**
1017 * p9_create_tstat - allocate and populate a request to change attributes
1018 * @fid: handle of the file or directory we are trying to change
1019 * @wstat: &p9_stat structure with attributes we wish to set
1020 * @dotu: 9p2000.u enabled flag
1021 *
1022 */
1023
899struct p9_fcall *p9_create_twstat(u32 fid, struct p9_wstat *wstat, 1024struct p9_fcall *p9_create_twstat(u32 fid, struct p9_wstat *wstat,
900 int dotu) 1025 int dotu)
901{ 1026{
@@ -922,3 +1047,4 @@ error:
922 return fc; 1047 return fc;
923} 1048}
924EXPORT_SYMBOL(p9_create_twstat); 1049EXPORT_SYMBOL(p9_create_twstat);
1050
diff --git a/net/9p/error.c b/net/9p/error.c
index 64104b9cb422..388770c3631e 100644
--- a/net/9p/error.c
+++ b/net/9p/error.c
@@ -33,6 +33,13 @@
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <net/9p/9p.h> 34#include <net/9p/9p.h>
35 35
36/**
37 * struct errormap - map string errors from Plan 9 to Linux numeric ids
38 * @name: string sent over 9P
39 * @val: numeric id most closely representing @name
40 * @namelen: length of string
41 * @list: hash-table list for string lookup
42 */
36struct errormap { 43struct errormap {
37 char *name; 44 char *name;
38 int val; 45 int val;
@@ -177,8 +184,7 @@ static struct errormap errmap[] = {
177}; 184};
178 185
179/** 186/**
180 * p9_error_init - preload 187 * p9_error_init - preload mappings into hash list
181 * @errstr: error string
182 * 188 *
183 */ 189 */
184 190
@@ -206,6 +212,7 @@ EXPORT_SYMBOL(p9_error_init);
206/** 212/**
207 * errstr2errno - convert error string to error number 213 * errstr2errno - convert error string to error number
208 * @errstr: error string 214 * @errstr: error string
215 * @len: length of error string
209 * 216 *
210 */ 217 */
211 218
diff --git a/net/9p/fcprint.c b/net/9p/fcprint.c
index 40244fbd9b0d..53dd8e28dd8a 100644
--- a/net/9p/fcprint.c
+++ b/net/9p/fcprint.c
@@ -142,6 +142,14 @@ p9_printdata(char *buf, int buflen, u8 *data, int datalen)
142 return p9_dumpdata(buf, buflen, data, datalen < 16?datalen:16); 142 return p9_dumpdata(buf, buflen, data, datalen < 16?datalen:16);
143} 143}
144 144
145/**
146 * p9_printfcall - decode and print a protocol structure into a buffer
147 * @buf: buffer to deposit decoded structure into
148 * @buflen: available space in buffer
149 * @fc: protocol rpc structure of type &p9_fcall
150 * @extended: whether or not session is operating with extended protocol
151 */
152
145int 153int
146p9_printfcall(char *buf, int buflen, struct p9_fcall *fc, int extended) 154p9_printfcall(char *buf, int buflen, struct p9_fcall *fc, int extended)
147{ 155{
diff --git a/net/9p/mod.c b/net/9p/mod.c
index c285aab2af04..c6d9695949e0 100644
--- a/net/9p/mod.c
+++ b/net/9p/mod.c
@@ -39,9 +39,6 @@ module_param_named(debug, p9_debug_level, uint, 0);
39MODULE_PARM_DESC(debug, "9P debugging level"); 39MODULE_PARM_DESC(debug, "9P debugging level");
40#endif 40#endif
41 41
42extern int p9_mux_global_init(void);
43extern void p9_mux_global_exit(void);
44
45/* 42/*
46 * Dynamic Transport Registration Routines 43 * Dynamic Transport Registration Routines
47 * 44 *
@@ -52,7 +49,7 @@ static struct p9_trans_module *v9fs_default_transport;
52 49
53/** 50/**
54 * v9fs_register_trans - register a new transport with 9p 51 * v9fs_register_trans - register a new transport with 9p
55 * @m - structure describing the transport module and entry points 52 * @m: structure describing the transport module and entry points
56 * 53 *
57 */ 54 */
58void v9fs_register_trans(struct p9_trans_module *m) 55void v9fs_register_trans(struct p9_trans_module *m)
@@ -65,7 +62,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
65 62
66/** 63/**
67 * v9fs_match_trans - match transport versus registered transports 64 * v9fs_match_trans - match transport versus registered transports
68 * @arg: string identifying transport 65 * @name: string identifying transport
69 * 66 *
70 */ 67 */
71struct p9_trans_module *v9fs_match_trans(const substring_t *name) 68struct p9_trans_module *v9fs_match_trans(const substring_t *name)
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index f624dff76852..c6eda999fa7d 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -47,12 +47,29 @@
47#define SCHED_TIMEOUT 10 47#define SCHED_TIMEOUT 10
48#define MAXPOLLWADDR 2 48#define MAXPOLLWADDR 2
49 49
50/**
51 * struct p9_fd_opts - per-transport options
52 * @rfd: file descriptor for reading (trans=fd)
53 * @wfd: file descriptor for writing (trans=fd)
54 * @port: port to connect to (trans=tcp)
55 *
56 */
57
50struct p9_fd_opts { 58struct p9_fd_opts {
51 int rfd; 59 int rfd;
52 int wfd; 60 int wfd;
53 u16 port; 61 u16 port;
54}; 62};
55 63
64
65/**
66 * struct p9_trans_fd - transport state
67 * @rd: reference to file to read from
68 * @wr: reference of file to write to
69 * @conn: connection state reference
70 *
71 */
72
56struct p9_trans_fd { 73struct p9_trans_fd {
57 struct file *rd; 74 struct file *rd;
58 struct file *wr; 75 struct file *wr;
@@ -90,10 +107,24 @@ enum {
90}; 107};
91 108
92struct p9_req; 109struct p9_req;
93
94typedef void (*p9_conn_req_callback)(struct p9_req *req, void *a); 110typedef void (*p9_conn_req_callback)(struct p9_req *req, void *a);
111
112/**
113 * struct p9_req - fd mux encoding of an rpc transaction
114 * @lock: protects req_list
115 * @tag: numeric tag for rpc transaction
116 * @tcall: request &p9_fcall structure
117 * @rcall: response &p9_fcall structure
118 * @err: error state
119 * @cb: callback for when response is received
120 * @cba: argument to pass to callback
121 * @flush: flag to indicate RPC has been flushed
122 * @req_list: list link for higher level objects to chain requests
123 *
124 */
125
95struct p9_req { 126struct p9_req {
96 spinlock_t lock; /* protect request structure */ 127 spinlock_t lock;
97 int tag; 128 int tag;
98 struct p9_fcall *tcall; 129 struct p9_fcall *tcall;
99 struct p9_fcall *rcall; 130 struct p9_fcall *rcall;
@@ -104,7 +135,39 @@ struct p9_req {
104 struct list_head req_list; 135 struct list_head req_list;
105}; 136};
106 137
107struct p9_mux_poll_task; 138struct p9_mux_poll_task {
139 struct task_struct *task;
140 struct list_head mux_list;
141 int muxnum;
142};
143
144/**
145 * struct p9_conn - fd mux connection state information
146 * @lock: protects mux_list (?)
147 * @mux_list: list link for mux to manage multiple connections (?)
148 * @poll_task: task polling on this connection
149 * @msize: maximum size for connection (dup)
150 * @extended: 9p2000.u flag (dup)
151 * @trans: reference to transport instance for this connection
152 * @tagpool: id accounting for transactions
153 * @err: error state
154 * @equeue: event wait_q (?)
155 * @req_list: accounting for requests which have been sent
156 * @unsent_req_list: accounting for requests that haven't been sent
157 * @rcall: current response &p9_fcall structure
158 * @rpos: read position in current frame
159 * @rbuf: current read buffer
160 * @wpos: write position for current frame
161 * @wsize: amount of data to write for current frame
162 * @wbuf: current write buffer
163 * @poll_wait: array of wait_q's for various worker threads
164 * @poll_waddr: ????
165 * @pt: poll state
166 * @rq: current read work
167 * @wq: current write work
168 * @wsched: ????
169 *
170 */
108 171
109struct p9_conn { 172struct p9_conn {
110 spinlock_t lock; /* protect lock structure */ 173 spinlock_t lock; /* protect lock structure */
@@ -132,11 +195,16 @@ struct p9_conn {
132 unsigned long wsched; 195 unsigned long wsched;
133}; 196};
134 197
135struct p9_mux_poll_task { 198/**
136 struct task_struct *task; 199 * struct p9_mux_rpc - fd mux rpc accounting structure
137 struct list_head mux_list; 200 * @m: connection this request was issued on
138 int muxnum; 201 * @err: error state
139}; 202 * @tcall: request &p9_fcall
203 * @rcall: response &p9_fcall
204 * @wqueue: wait queue that client is blocked on for this rpc
205 *
206 * Bug: isn't this information duplicated elsewhere like &p9_req
207 */
140 208
141struct p9_mux_rpc { 209struct p9_mux_rpc {
142 struct p9_conn *m; 210 struct p9_conn *m;
@@ -207,10 +275,12 @@ static void p9_mux_put_tag(struct p9_conn *m, u16 tag)
207 275
208/** 276/**
209 * p9_mux_calc_poll_procs - calculates the number of polling procs 277 * p9_mux_calc_poll_procs - calculates the number of polling procs
210 * based on the number of mounted v9fs filesystems. 278 * @muxnum: number of mounts
211 * 279 *
280 * Calculation is based on the number of mounted v9fs filesystems.
212 * The current implementation returns sqrt of the number of mounts. 281 * The current implementation returns sqrt of the number of mounts.
213 */ 282 */
283
214static int p9_mux_calc_poll_procs(int muxnum) 284static int p9_mux_calc_poll_procs(int muxnum)
215{ 285{
216 int n; 286 int n;
@@ -331,12 +401,11 @@ static void p9_mux_poll_stop(struct p9_conn *m)
331 401
332/** 402/**
333 * p9_conn_create - allocate and initialize the per-session mux data 403 * p9_conn_create - allocate and initialize the per-session mux data
334 * Creates the polling task if this is the first session. 404 * @trans: transport structure
335 * 405 *
336 * @trans - transport structure 406 * Note: Creates the polling task if this is the first session.
337 * @msize - maximum message size
338 * @extended - extended flag
339 */ 407 */
408
340static struct p9_conn *p9_conn_create(struct p9_trans *trans) 409static struct p9_conn *p9_conn_create(struct p9_trans *trans)
341{ 410{
342 int i, n; 411 int i, n;
@@ -406,7 +475,10 @@ static struct p9_conn *p9_conn_create(struct p9_trans *trans)
406 475
407/** 476/**
408 * p9_mux_destroy - cancels all pending requests and frees mux resources 477 * p9_mux_destroy - cancels all pending requests and frees mux resources
478 * @m: mux to destroy
479 *
409 */ 480 */
481
410static void p9_conn_destroy(struct p9_conn *m) 482static void p9_conn_destroy(struct p9_conn *m)
411{ 483{
412 P9_DPRINTK(P9_DEBUG_MUX, "mux %p prev %p next %p\n", m, 484 P9_DPRINTK(P9_DEBUG_MUX, "mux %p prev %p next %p\n", m,
@@ -429,9 +501,14 @@ static void p9_conn_destroy(struct p9_conn *m)
429} 501}
430 502
431/** 503/**
432 * p9_pollwait - called by files poll operation to add v9fs-poll task 504 * p9_pollwait - add poll task to the wait queue
433 * to files wait queue 505 * @filp: file pointer being polled
506 * @wait_address: wait_q to block on
507 * @p: poll state
508 *
509 * called by files poll operation to add v9fs-poll task to files wait queue
434 */ 510 */
511
435static void 512static void
436p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p) 513p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p)
437{ 514{
@@ -462,7 +539,10 @@ p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p)
462 539
463/** 540/**
464 * p9_poll_mux - polls a mux and schedules read or write works if necessary 541 * p9_poll_mux - polls a mux and schedules read or write works if necessary
542 * @m: connection to poll
543 *
465 */ 544 */
545
466static void p9_poll_mux(struct p9_conn *m) 546static void p9_poll_mux(struct p9_conn *m)
467{ 547{
468 int n; 548 int n;
@@ -499,9 +579,14 @@ static void p9_poll_mux(struct p9_conn *m)
499} 579}
500 580
501/** 581/**
502 * p9_poll_proc - polls all v9fs transports for new events and queues 582 * p9_poll_proc - poll worker thread
503 * the appropriate work to the work queue 583 * @a: thread state and arguments
584 *
585 * polls all v9fs transports for new events and queues the appropriate
586 * work to the work queue
587 *
504 */ 588 */
589
505static int p9_poll_proc(void *a) 590static int p9_poll_proc(void *a)
506{ 591{
507 struct p9_conn *m, *mtmp; 592 struct p9_conn *m, *mtmp;
@@ -527,7 +612,10 @@ static int p9_poll_proc(void *a)
527 612
528/** 613/**
529 * p9_write_work - called when a transport can send some data 614 * p9_write_work - called when a transport can send some data
615 * @work: container for work to be done
616 *
530 */ 617 */
618
531static void p9_write_work(struct work_struct *work) 619static void p9_write_work(struct work_struct *work)
532{ 620{
533 int n, err; 621 int n, err;
@@ -638,7 +726,10 @@ static void process_request(struct p9_conn *m, struct p9_req *req)
638 726
639/** 727/**
640 * p9_read_work - called when there is some data to be read from a transport 728 * p9_read_work - called when there is some data to be read from a transport
729 * @work: container of work to be done
730 *
641 */ 731 */
732
642static void p9_read_work(struct work_struct *work) 733static void p9_read_work(struct work_struct *work)
643{ 734{
644 int n, err; 735 int n, err;
@@ -793,7 +884,9 @@ error:
793 * @tc: request to be sent 884 * @tc: request to be sent
794 * @cb: callback function to call when response is received 885 * @cb: callback function to call when response is received
795 * @cba: parameter to pass to the callback function 886 * @cba: parameter to pass to the callback function
887 *
796 */ 888 */
889
797static struct p9_req *p9_send_request(struct p9_conn *m, 890static struct p9_req *p9_send_request(struct p9_conn *m,
798 struct p9_fcall *tc, 891 struct p9_fcall *tc,
799 p9_conn_req_callback cb, void *cba) 892 p9_conn_req_callback cb, void *cba)
@@ -961,10 +1054,12 @@ p9_conn_rpc_cb(struct p9_req *req, void *a)
961/** 1054/**
962 * p9_fd_rpc- sends 9P request and waits until a response is available. 1055 * p9_fd_rpc- sends 9P request and waits until a response is available.
963 * The function can be interrupted. 1056 * The function can be interrupted.
964 * @m: mux data 1057 * @t: transport data
965 * @tc: request to be sent 1058 * @tc: request to be sent
966 * @rc: pointer where a pointer to the response is stored 1059 * @rc: pointer where a pointer to the response is stored
1060 *
967 */ 1061 */
1062
968int 1063int
969p9_fd_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc) 1064p9_fd_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc)
970{ 1065{
@@ -1041,8 +1136,10 @@ p9_fd_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc)
1041 * @m: mux data 1136 * @m: mux data
1042 * @tc: request to be sent 1137 * @tc: request to be sent
1043 * @cb: callback function to be called when response arrives 1138 * @cb: callback function to be called when response arrives
1044 * @cba: value to pass to the callback function 1139 * @a: value to pass to the callback function
1140 *
1045 */ 1141 */
1142
1046int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc, 1143int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc,
1047 p9_conn_req_callback cb, void *a) 1144 p9_conn_req_callback cb, void *a)
1048{ 1145{
@@ -1065,7 +1162,9 @@ int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc,
1065 * p9_conn_cancel - cancel all pending requests with error 1162 * p9_conn_cancel - cancel all pending requests with error
1066 * @m: mux data 1163 * @m: mux data
1067 * @err: error code 1164 * @err: error code
1165 *
1068 */ 1166 */
1167
1069void p9_conn_cancel(struct p9_conn *m, int err) 1168void p9_conn_cancel(struct p9_conn *m, int err)
1070{ 1169{
1071 struct p9_req *req, *rtmp; 1170 struct p9_req *req, *rtmp;
@@ -1099,7 +1198,7 @@ void p9_conn_cancel(struct p9_conn *m, int err)
1099/** 1198/**
1100 * v9fs_parse_options - parse mount options into session structure 1199 * v9fs_parse_options - parse mount options into session structure
1101 * @options: options string passed from mount 1200 * @options: options string passed from mount
1102 * @v9ses: existing v9fs session information 1201 * @opts: transport-specific structure to parse options into
1103 * 1202 *
1104 */ 1203 */
1105 1204
@@ -1193,11 +1292,12 @@ static int p9_socket_open(struct p9_trans *trans, struct socket *csocket)
1193 1292
1194/** 1293/**
1195 * p9_fd_read- read from a fd 1294 * p9_fd_read- read from a fd
1196 * @v9ses: session information 1295 * @trans: transport instance state
1197 * @v: buffer to receive data into 1296 * @v: buffer to receive data into
1198 * @len: size of receive buffer 1297 * @len: size of receive buffer
1199 * 1298 *
1200 */ 1299 */
1300
1201static int p9_fd_read(struct p9_trans *trans, void *v, int len) 1301static int p9_fd_read(struct p9_trans *trans, void *v, int len)
1202{ 1302{
1203 int ret; 1303 int ret;
@@ -1220,11 +1320,12 @@ static int p9_fd_read(struct p9_trans *trans, void *v, int len)
1220 1320
1221/** 1321/**
1222 * p9_fd_write - write to a socket 1322 * p9_fd_write - write to a socket
1223 * @v9ses: session information 1323 * @trans: transport instance state
1224 * @v: buffer to send data from 1324 * @v: buffer to send data from
1225 * @len: size of send buffer 1325 * @len: size of send buffer
1226 * 1326 *
1227 */ 1327 */
1328
1228static int p9_fd_write(struct p9_trans *trans, void *v, int len) 1329static int p9_fd_write(struct p9_trans *trans, void *v, int len)
1229{ 1330{
1230 int ret; 1331 int ret;
@@ -1296,6 +1397,7 @@ end:
1296 * @trans: private socket structure 1397 * @trans: private socket structure
1297 * 1398 *
1298 */ 1399 */
1400
1299static void p9_fd_close(struct p9_trans *trans) 1401static void p9_fd_close(struct p9_trans *trans)
1300{ 1402{
1301 struct p9_trans_fd *ts; 1403 struct p9_trans_fd *ts;
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index de7a9f532edc..0bab1f23590e 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -55,23 +55,69 @@ static int chan_index;
55 55
56#define P9_INIT_MAXTAG 16 56#define P9_INIT_MAXTAG 16
57 57
58#define REQ_STATUS_IDLE 0 58
59#define REQ_STATUS_SENT 1 59/**
60#define REQ_STATUS_RCVD 2 60 * enum p9_req_status_t - virtio request status
61#define REQ_STATUS_FLSH 3 61 * @REQ_STATUS_IDLE: request slot unused
62 * @REQ_STATUS_SENT: request sent to server
63 * @REQ_STATUS_RCVD: response received from server
64 * @REQ_STATUS_FLSH: request has been flushed
65 *
66 * The @REQ_STATUS_IDLE state is used to mark a request slot as unused
67 * but use is actually tracked by the idpool structure which handles tag
68 * id allocation.
69 *
70 */
71
72enum p9_req_status_t {
73 REQ_STATUS_IDLE,
74 REQ_STATUS_SENT,
75 REQ_STATUS_RCVD,
76 REQ_STATUS_FLSH,
77};
78
79/**
80 * struct p9_req_t - virtio request slots
81 * @status: status of this request slot
82 * @wq: wait_queue for the client to block on for this request
83 *
84 * The virtio transport uses an array to track outstanding requests
85 * instead of a list. While this may incurr overhead during initial
86 * allocation or expansion, it makes request lookup much easier as the
87 * tag id is a index into an array. (We use tag+1 so that we can accomodate
88 * the -1 tag for the T_VERSION request).
89 * This also has the nice effect of only having to allocate wait_queues
90 * once, instead of constantly allocating and freeing them. Its possible
91 * other resources could benefit from this scheme as well.
92 *
93 */
62 94
63struct p9_req_t { 95struct p9_req_t {
64 int status; 96 int status;
65 wait_queue_head_t *wq; 97 wait_queue_head_t *wq;
66}; 98};
67 99
68/* We keep all per-channel information in a structure. 100/**
101 * struct virtio_chan - per-instance transport information
102 * @initialized: whether the channel is initialized
103 * @inuse: whether the channel is in use
104 * @lock: protects multiple elements within this structure
105 * @vdev: virtio dev associated with this channel
106 * @vq: virtio queue associated with this channel
107 * @tagpool: accounting for tag ids (and request slots)
108 * @reqs: array of request slots
109 * @max_tag: current number of request_slots allocated
110 * @sg: scatter gather list which is used to pack a request (protected?)
111 *
112 * We keep all per-channel information in a structure.
69 * This structure is allocated within the devices dev->mem space. 113 * This structure is allocated within the devices dev->mem space.
70 * A pointer to the structure will get put in the transport private. 114 * A pointer to the structure will get put in the transport private.
115 *
71 */ 116 */
117
72static struct virtio_chan { 118static struct virtio_chan {
73 bool initialized; /* channel is initialized */ 119 bool initialized;
74 bool inuse; /* channel is in use */ 120 bool inuse;
75 121
76 spinlock_t lock; 122 spinlock_t lock;
77 123
@@ -86,7 +132,19 @@ static struct virtio_chan {
86 struct scatterlist sg[VIRTQUEUE_NUM]; 132 struct scatterlist sg[VIRTQUEUE_NUM];
87} channels[MAX_9P_CHAN]; 133} channels[MAX_9P_CHAN];
88 134
89/* Lookup requests by tag */ 135/**
136 * p9_lookup_tag - Lookup requests by tag
137 * @c: virtio channel to lookup tag within
138 * @tag: numeric id for transaction
139 *
140 * this is a simple array lookup, but will grow the
141 * request_slots as necessary to accomodate transaction
142 * ids which did not previously have a slot.
143 *
144 * Bugs: there is currently no upper limit on request slots set
145 * here, but that should be constrained by the id accounting.
146 */
147
90static struct p9_req_t *p9_lookup_tag(struct virtio_chan *c, u16 tag) 148static struct p9_req_t *p9_lookup_tag(struct virtio_chan *c, u16 tag)
91{ 149{
92 /* This looks up the original request by tag so we know which 150 /* This looks up the original request by tag so we know which
@@ -130,6 +188,15 @@ static unsigned int rest_of_page(void *data)
130 return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE); 188 return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE);
131} 189}
132 190
191/**
192 * p9_virtio_close - reclaim resources of a channel
193 * @trans: transport state
194 *
195 * This reclaims a channel by freeing its resources and
196 * reseting its inuse flag.
197 *
198 */
199
133static void p9_virtio_close(struct p9_trans *trans) 200static void p9_virtio_close(struct p9_trans *trans)
134{ 201{
135 struct virtio_chan *chan = trans->priv; 202 struct virtio_chan *chan = trans->priv;
@@ -151,6 +218,19 @@ static void p9_virtio_close(struct p9_trans *trans)
151 kfree(trans); 218 kfree(trans);
152} 219}
153 220
221/**
222 * req_done - callback which signals activity from the server
223 * @vq: virtio queue activity was received on
224 *
225 * This notifies us that the server has triggered some activity
226 * on the virtio channel - most likely a response to request we
227 * sent. Figure out which requests now have responses and wake up
228 * those threads.
229 *
230 * Bugs: could do with some additional sanity checking, but appears to work.
231 *
232 */
233
154static void req_done(struct virtqueue *vq) 234static void req_done(struct virtqueue *vq)
155{ 235{
156 struct virtio_chan *chan = vq->vdev->priv; 236 struct virtio_chan *chan = vq->vdev->priv;
@@ -169,6 +249,20 @@ static void req_done(struct virtqueue *vq)
169 spin_unlock_irqrestore(&chan->lock, flags); 249 spin_unlock_irqrestore(&chan->lock, flags);
170} 250}
171 251
252/**
253 * pack_sg_list - pack a scatter gather list from a linear buffer
254 * @sg: scatter/gather list to pack into
255 * @start: which segment of the sg_list to start at
256 * @limit: maximum segment to pack data to
257 * @data: data to pack into scatter/gather list
258 * @count: amount of data to pack into the scatter/gather list
259 *
260 * sg_lists have multiple segments of various sizes. This will pack
261 * arbitrary data into an existing scatter gather list, segmenting the
262 * data as necessary within constraints.
263 *
264 */
265
172static int 266static int
173pack_sg_list(struct scatterlist *sg, int start, int limit, char *data, 267pack_sg_list(struct scatterlist *sg, int start, int limit, char *data,
174 int count) 268 int count)
@@ -189,6 +283,14 @@ pack_sg_list(struct scatterlist *sg, int start, int limit, char *data,
189 return index-start; 283 return index-start;
190} 284}
191 285
286/**
287 * p9_virtio_rpc - issue a request and wait for a response
288 * @t: transport state
289 * @tc: &p9_fcall request to transmit
290 * @rc: &p9_fcall to put reponse into
291 *
292 */
293
192static int 294static int
193p9_virtio_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc) 295p9_virtio_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc)
194{ 296{
@@ -263,6 +365,16 @@ p9_virtio_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc)
263 return 0; 365 return 0;
264} 366}
265 367
368/**
369 * p9_virtio_probe - probe for existence of 9P virtio channels
370 * @vdev: virtio device to probe
371 *
372 * This probes for existing virtio channels. At present only
373 * a single channel is in use, so in the future more work may need
374 * to be done here.
375 *
376 */
377
266static int p9_virtio_probe(struct virtio_device *vdev) 378static int p9_virtio_probe(struct virtio_device *vdev)
267{ 379{
268 int err; 380 int err;
@@ -307,11 +419,28 @@ fail:
307 return err; 419 return err;
308} 420}
309 421
310/* This sets up a transport channel for 9p communication. Right now 422
423/**
424 * p9_virtio_create - allocate a new virtio channel
425 * @devname: string identifying the channel to connect to (unused)
426 * @args: args passed from sys_mount() for per-transport options (unused)
427 * @msize: requested maximum packet size
428 * @extended: 9p2000.u enabled flag
429 *
430 * This sets up a transport channel for 9p communication. Right now
311 * we only match the first available channel, but eventually we couldlook up 431 * we only match the first available channel, but eventually we couldlook up
312 * alternate channels by matching devname versus a virtio_config entry. 432 * alternate channels by matching devname versus a virtio_config entry.
313 * We use a simple reference count mechanism to ensure that only a single 433 * We use a simple reference count mechanism to ensure that only a single
314 * mount has a channel open at a time. */ 434 * mount has a channel open at a time.
435 *
436 * Bugs: doesn't allow identification of a specific channel
437 * to allocate, channels are allocated sequentially. This was
438 * a pragmatic decision to get things rolling, but ideally some
439 * way of identifying the channel to attach to would be nice
440 * if we are going to support multiple channels.
441 *
442 */
443
315static struct p9_trans * 444static struct p9_trans *
316p9_virtio_create(const char *devname, char *args, int msize, 445p9_virtio_create(const char *devname, char *args, int msize,
317 unsigned char extended) 446 unsigned char extended)
@@ -360,6 +489,12 @@ p9_virtio_create(const char *devname, char *args, int msize,
360 return trans; 489 return trans;
361} 490}
362 491
492/**
493 * p9_virtio_remove - clean up resources associated with a virtio device
494 * @vdev: virtio device to remove
495 *
496 */
497
363static void p9_virtio_remove(struct virtio_device *vdev) 498static void p9_virtio_remove(struct virtio_device *vdev)
364{ 499{
365 struct virtio_chan *chan = vdev->priv; 500 struct virtio_chan *chan = vdev->priv;
diff --git a/net/9p/util.c b/net/9p/util.c
index ef7215565d88..4d5646045330 100644
--- a/net/9p/util.c
+++ b/net/9p/util.c
@@ -32,11 +32,23 @@
32#include <linux/idr.h> 32#include <linux/idr.h>
33#include <net/9p/9p.h> 33#include <net/9p/9p.h>
34 34
35/**
36 * struct p9_idpool - per-connection accounting for tag idpool
37 * @lock: protects the pool
38 * @pool: idr to allocate tag id from
39 *
40 */
41
35struct p9_idpool { 42struct p9_idpool {
36 spinlock_t lock; 43 spinlock_t lock;
37 struct idr pool; 44 struct idr pool;
38}; 45};
39 46
47/**
48 * p9_idpool_create - create a new per-connection id pool
49 *
50 */
51
40struct p9_idpool *p9_idpool_create(void) 52struct p9_idpool *p9_idpool_create(void)
41{ 53{
42 struct p9_idpool *p; 54 struct p9_idpool *p;
@@ -52,6 +64,11 @@ struct p9_idpool *p9_idpool_create(void)
52} 64}
53EXPORT_SYMBOL(p9_idpool_create); 65EXPORT_SYMBOL(p9_idpool_create);
54 66
67/**
68 * p9_idpool_destroy - create a new per-connection id pool
69 * @p: idpool to destory
70 */
71
55void p9_idpool_destroy(struct p9_idpool *p) 72void p9_idpool_destroy(struct p9_idpool *p)
56{ 73{
57 idr_destroy(&p->pool); 74 idr_destroy(&p->pool);
@@ -61,9 +78,9 @@ EXPORT_SYMBOL(p9_idpool_destroy);
61 78
62/** 79/**
63 * p9_idpool_get - allocate numeric id from pool 80 * p9_idpool_get - allocate numeric id from pool
64 * @p - pool to allocate from 81 * @p: pool to allocate from
65 * 82 *
66 * XXX - This seems to be an awful generic function, should it be in idr.c with 83 * Bugs: This seems to be an awful generic function, should it be in idr.c with
67 * the lock included in struct idr? 84 * the lock included in struct idr?
68 */ 85 */
69 86
@@ -94,9 +111,10 @@ EXPORT_SYMBOL(p9_idpool_get);
94 111
95/** 112/**
96 * p9_idpool_put - release numeric id from pool 113 * p9_idpool_put - release numeric id from pool
97 * @p - pool to allocate from 114 * @id: numeric id which is being released
115 * @p: pool to release id into
98 * 116 *
99 * XXX - This seems to be an awful generic function, should it be in idr.c with 117 * Bugs: This seems to be an awful generic function, should it be in idr.c with
100 * the lock included in struct idr? 118 * the lock included in struct idr?
101 */ 119 */
102 120
@@ -111,11 +129,13 @@ EXPORT_SYMBOL(p9_idpool_put);
111 129
112/** 130/**
113 * p9_idpool_check - check if the specified id is available 131 * p9_idpool_check - check if the specified id is available
114 * @id - id to check 132 * @id: id to check
115 * @p - pool 133 * @p: pool to check
116 */ 134 */
135
117int p9_idpool_check(int id, struct p9_idpool *p) 136int p9_idpool_check(int id, struct p9_idpool *p)
118{ 137{
119 return idr_find(&p->pool, id) != NULL; 138 return idr_find(&p->pool, id) != NULL;
120} 139}
121EXPORT_SYMBOL(p9_idpool_check); 140EXPORT_SYMBOL(p9_idpool_check);
141