Skip to content

Commit

Permalink
9p: rework client code to use new protocol support functions
Browse files Browse the repository at this point in the history
Now that the new protocol functions are in place, this patch switches
the client code to using the new support code.

Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
  • Loading branch information
Eric Van Hensbergen committed Oct 17, 2008
1 parent cb19813 commit 51a87c5
Show file tree
Hide file tree
Showing 12 changed files with 611 additions and 544 deletions.
4 changes: 2 additions & 2 deletions fs/9p/v9fs_vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ extern struct dentry_operations v9fs_cached_dentry_operations;

struct inode *v9fs_get_inode(struct super_block *sb, int mode);
ino_t v9fs_qid2ino(struct p9_qid *qid);
void v9fs_stat2inode(struct p9_stat *, struct inode *, struct super_block *);
void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *);
int v9fs_dir_release(struct inode *inode, struct file *filp);
int v9fs_file_open(struct inode *inode, struct file *file);
void v9fs_inode2stat(struct inode *inode, struct p9_stat *stat);
void v9fs_inode2stat(struct inode *inode, struct p9_wstat *stat);
void v9fs_dentry_release(struct dentry *);
int v9fs_uflags2omode(int uflags, int extended);

Expand Down
4 changes: 2 additions & 2 deletions fs/9p/vfs_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ static int v9fs_dir_readdir(struct file *filp, void *dirent, filldir_t filldir)
return -ENOMEM;

while (1) {
err = v9fs_file_readn(filp, statbuf, NULL, fid->rdir_fpos,
buflen);
err = v9fs_file_readn(filp, statbuf, NULL, buflen,
fid->rdir_fpos);
if (err <= 0)
break;

Expand Down
2 changes: 1 addition & 1 deletion fs/9p/vfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count,
int n, total;
struct p9_fid *fid = filp->private_data;

P9_DPRINTK(P9_DEBUG_9P, "fid %d offset %llu count %d\n", fid->fid,
P9_DPRINTK(P9_DEBUG_VFS, "fid %d offset %llu count %d\n", fid->fid,
(long long unsigned) offset, count);

n = 0;
Expand Down
38 changes: 18 additions & 20 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
{
int err, umode;
struct inode *ret;
struct p9_stat *st;
struct p9_wstat *st;

ret = NULL;
st = p9_client_stat(fid);
Expand Down Expand Up @@ -417,13 +417,16 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
struct p9_fid *dfid, *ofid, *fid;
struct inode *inode;

P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name);

err = 0;
ofid = NULL;
fid = NULL;
name = (char *) dentry->d_name.name;
dfid = v9fs_fid_clone(dentry->d_parent);
if (IS_ERR(dfid)) {
err = PTR_ERR(dfid);
P9_DPRINTK(P9_DEBUG_VFS, "fid clone failed %d\n", err);
dfid = NULL;
goto error;
}
Expand All @@ -432,18 +435,22 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
ofid = p9_client_walk(dfid, 0, NULL, 1);
if (IS_ERR(ofid)) {
err = PTR_ERR(ofid);
P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
ofid = NULL;
goto error;
}

err = p9_client_fcreate(ofid, name, perm, mode, extension);
if (err < 0)
if (err < 0) {
P9_DPRINTK(P9_DEBUG_VFS, "p9_client_fcreate failed %d\n", err);
goto error;
}

/* now walk from the parent so we can get unopened fid */
fid = p9_client_walk(dfid, 1, &name, 0);
if (IS_ERR(fid)) {
err = PTR_ERR(fid);
P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
fid = NULL;
goto error;
} else
Expand All @@ -453,6 +460,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
goto error;
}

Expand Down Expand Up @@ -734,7 +742,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
int err;
struct v9fs_session_info *v9ses;
struct p9_fid *fid;
struct p9_stat *st;
struct p9_wstat *st;

P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry);
err = -EPERM;
Expand Down Expand Up @@ -815,10 +823,9 @@ static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr)
*/

void
v9fs_stat2inode(struct p9_stat *stat, struct inode *inode,
v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
struct super_block *sb)
{
int n;
char ext[32];
struct v9fs_session_info *v9ses = sb->s_fs_info;

Expand All @@ -842,11 +849,7 @@ v9fs_stat2inode(struct p9_stat *stat, struct inode *inode,
int major = -1;
int minor = -1;

n = stat->extension.len;
if (n > sizeof(ext)-1)
n = sizeof(ext)-1;
memmove(ext, stat->extension.str, n);
ext[n] = 0;
strncpy(ext, stat->extension, sizeof(ext));
sscanf(ext, "%c %u %u", &type, &major, &minor);
switch (type) {
case 'c':
Expand All @@ -857,8 +860,8 @@ v9fs_stat2inode(struct p9_stat *stat, struct inode *inode,
break;
default:
P9_DPRINTK(P9_DEBUG_ERROR,
"Unknown special type %c (%.*s)\n", type,
stat->extension.len, stat->extension.str);
"Unknown special type %c %s\n", type,
stat->extension);
};
inode->i_rdev = MKDEV(major, minor);
} else
Expand Down Expand Up @@ -904,7 +907,7 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)

struct v9fs_session_info *v9ses;
struct p9_fid *fid;
struct p9_stat *st;
struct p9_wstat *st;

P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
retval = -EPERM;
Expand All @@ -926,15 +929,10 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
}

/* copy extension buffer into buffer */
if (st->extension.len < buflen)
buflen = st->extension.len + 1;

memmove(buffer, st->extension.str, buflen - 1);
buffer[buflen-1] = 0;
strncpy(buffer, st->extension, buflen);

P9_DPRINTK(P9_DEBUG_VFS,
"%s -> %.*s (%s)\n", dentry->d_name.name, st->extension.len,
st->extension.str, buffer);
"%s -> %s (%s)\n", dentry->d_name.name, st->extension, buffer);

retval = buflen;

Expand Down
6 changes: 5 additions & 1 deletion fs/9p/vfs_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
struct inode *inode = NULL;
struct dentry *root = NULL;
struct v9fs_session_info *v9ses = NULL;
struct p9_stat *st = NULL;
struct p9_wstat *st = NULL;
int mode = S_IRWXUGO | S_ISVTX;
uid_t uid = current->fsuid;
gid_t gid = current->fsgid;
Expand Down Expand Up @@ -161,10 +161,14 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,

sb->s_root = root;
root->d_inode->i_ino = v9fs_qid2ino(&st->qid);

v9fs_stat2inode(st, root->d_inode, sb);

v9fs_fid_add(root, fid);
p9stat_free(st);
kfree(st);

P9_DPRINTK(P9_DEBUG_VFS, " return simple set mount\n");
return simple_set_mnt(mnt, sb);

release_sb:
Expand Down
7 changes: 6 additions & 1 deletion include/net/9p/9p.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* @P9_DEBUG_TRANS: transport tracing
* @P9_DEBUG_SLABS: memory management tracing
* @P9_DEBUG_FCALL: verbose dump of protocol messages
* @P9_DEBUG_FID: fid allocation/deallocation tracking
*
* These flags are passed at mount time to turn on various levels of
* verbosity and tracing which will be output to the system logs.
Expand All @@ -53,13 +54,17 @@ enum p9_debug_flags {
P9_DEBUG_TRANS = (1<<6),
P9_DEBUG_SLABS = (1<<7),
P9_DEBUG_FCALL = (1<<8),
P9_DEBUG_FID = (1<<9),
};

extern unsigned int p9_debug_level;

#define P9_DPRINTK(level, format, arg...) \
do { \
if ((p9_debug_level & level) == level) \
if (level == P9_DEBUG_9P) \
printk(KERN_NOTICE "(%8.8d) " \
format , task_pid_nr(current) , ## arg); \
else if ((p9_debug_level & level) == level) \
printk(KERN_NOTICE "-- %s (%d): " \
format , __func__, task_pid_nr(current) , ## arg); \
} while (0)
Expand Down
7 changes: 5 additions & 2 deletions include/net/9p/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ enum p9_req_status_t {
* struct p9_req_t - request slots
* @status: status of this request slot
* @t_err: transport error
* @flush_tag: tag of request being flushed (for flush requests)
* @wq: wait_queue for the client to block on for this request
* @tc: the request fcall structure
* @rc: the response fcall structure
Expand All @@ -97,10 +98,10 @@ enum p9_req_status_t {
struct p9_req_t {
int status;
int t_err;
u16 flush_tag;
wait_queue_head_t *wq;
struct p9_fcall *tc;
struct p9_fcall *rc;
u16 flush_tag;
void *aux;

struct list_head req_list;
Expand Down Expand Up @@ -199,10 +200,12 @@ int p9_client_read(struct p9_fid *fid, char *data, char __user *udata,
u64 offset, u32 count);
int p9_client_write(struct p9_fid *fid, char *data, const char __user *udata,
u64 offset, u32 count);
struct p9_stat *p9_client_stat(struct p9_fid *fid);
struct p9_wstat *p9_client_stat(struct p9_fid *fid);
int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst);

struct p9_req_t *p9_tag_lookup(struct p9_client *, u16);
void p9_client_cb(struct p9_client *c, struct p9_req_t *req);

void p9stat_free(struct p9_wstat *);

#endif /* NET_9P_CLIENT_H */
Loading

0 comments on commit 51a87c5

Please sign in to comment.