aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/9p
diff options
context:
space:
mode:
authorSripathi Kodi <sripathik@in.ibm.com>2010-06-04 09:41:26 -0400
committerEric Van Hensbergen <ericvh@gmail.com>2010-08-02 15:25:07 -0400
commit7751bdb3a095ad32dd4fcff3443cf8dd4cb1e748 (patch)
tree6c7a93a546e34d86e433a1be05e3ebfcc4f77754 /include/net/9p
parent97e8442b0971ea6be9a495b3d03402985cfe5d6a (diff)
9p: readdir implementation for 9p2000.L
This patch implements the kernel part of readdir() implementation for 9p2000.L Change from V3: Instead of inode, server now sends qids for each dirent SYNOPSIS size[4] Treaddir tag[2] fid[4] offset[8] count[4] size[4] Rreaddir tag[2] count[4] data[count] DESCRIPTION The readdir request asks the server to read the directory specified by 'fid' at an offset specified by 'offset' and return as many dirent structures as possible that fit into count bytes. Each dirent structure is laid out as follows. qid.type[1] the type of the file (directory, etc.), represented as a bit vector corresponding to the high 8 bits of the file's mode word. qid.vers[4] version number for given path qid.path[8] the file server's unique identification for the file offset[8] offset into the next dirent. type[1] type of this directory entry. name[256] name of this directory entry. This patch adds v9fs_dir_readdir_dotl() as the readdir() call for 9p2000.L. This function sends P9_TREADDIR command to the server. In response the server sends a buffer filled with dirent structures. This is different from the existing v9fs_dir_readdir() call which receives stat structures from the server. This results in significant speedup of readdir() on large directories. For example, doing 'ls >/dev/null' on a directory with 10000 files on my laptop takes 1.088 seconds with the existing code, but only takes 0.339 seconds with the new readdir. Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'include/net/9p')
-rw-r--r--include/net/9p/9p.h17
-rw-r--r--include/net/9p/client.h18
2 files changed, 35 insertions, 0 deletions
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
index 156c26bb8bd7..f1b0b310265d 100644
--- a/include/net/9p/9p.h
+++ b/include/net/9p/9p.h
@@ -133,6 +133,8 @@ enum p9_msg_t {
133 P9_RSTATFS, 133 P9_RSTATFS,
134 P9_TRENAME = 20, 134 P9_TRENAME = 20,
135 P9_RRENAME, 135 P9_RRENAME,
136 P9_TREADDIR = 40,
137 P9_RREADDIR,
136 P9_TVERSION = 100, 138 P9_TVERSION = 100,
137 P9_RVERSION, 139 P9_RVERSION,
138 P9_TAUTH = 102, 140 P9_TAUTH = 102,
@@ -275,6 +277,9 @@ enum p9_qid_t {
275/* ample room for Twrite/Rread header */ 277/* ample room for Twrite/Rread header */
276#define P9_IOHDRSZ 24 278#define P9_IOHDRSZ 24
277 279
280/* Room for readdir header */
281#define P9_READDIRHDRSZ 24
282
278/** 283/**
279 * struct p9_str - length prefixed string type 284 * struct p9_str - length prefixed string type
280 * @len: length of the string 285 * @len: length of the string
@@ -485,6 +490,18 @@ struct p9_rwrite {
485 u32 count; 490 u32 count;
486}; 491};
487 492
493struct p9_treaddir {
494 u32 fid;
495 u64 offset;
496 u32 count;
497};
498
499struct p9_rreaddir {
500 u32 count;
501 u8 *data;
502};
503
504
488struct p9_tclunk { 505struct p9_tclunk {
489 u32 fid; 506 u32 fid;
490}; 507};
diff --git a/include/net/9p/client.h b/include/net/9p/client.h
index 7dd3ed85c782..2ec93685e6db 100644
--- a/include/net/9p/client.h
+++ b/include/net/9p/client.h
@@ -195,6 +195,21 @@ struct p9_fid {
195 struct list_head dlist; /* list of all fids attached to a dentry */ 195 struct list_head dlist; /* list of all fids attached to a dentry */
196}; 196};
197 197
198/**
199 * struct p9_dirent - directory entry structure
200 * @qid: The p9 server qid for this dirent
201 * @d_off: offset to the next dirent
202 * @d_type: type of file
203 * @d_name: file name
204 */
205
206struct p9_dirent {
207 struct p9_qid qid;
208 u64 d_off;
209 unsigned char d_type;
210 char d_name[256];
211};
212
198int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb); 213int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb);
199int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid, char *name); 214int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid, char *name);
200int p9_client_version(struct p9_client *); 215int p9_client_version(struct p9_client *);
@@ -217,6 +232,9 @@ int p9_client_read(struct p9_fid *fid, char *data, char __user *udata,
217 u64 offset, u32 count); 232 u64 offset, u32 count);
218int p9_client_write(struct p9_fid *fid, char *data, const char __user *udata, 233int p9_client_write(struct p9_fid *fid, char *data, const char __user *udata,
219 u64 offset, u32 count); 234 u64 offset, u32 count);
235int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset);
236int p9dirent_read(char *buf, int len, struct p9_dirent *dirent,
237 int proto_version);
220struct p9_wstat *p9_client_stat(struct p9_fid *fid); 238struct p9_wstat *p9_client_stat(struct p9_fid *fid);
221int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst); 239int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst);
222 240