mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs: 9p: Optimize TCREATE by eliminating a redundant fid clone. 9p: cleanup: remove unneeded assignment 9p: Add mksock support fs/9p: Make sure we properly instantiate dentry. 9p: add 9P2000.L rename operation 9p: add 9P2000.L statfs operation 9p: VFS switches for 9p2000.L: VFS switches 9p: VFS switches for 9p2000.L: protocol and client changes
This commit is contained in:
commit
4fd5ec509b
9 changed files with 261 additions and 33 deletions
|
|
@ -40,7 +40,9 @@
|
|||
extern struct file_system_type v9fs_fs_type;
|
||||
extern const struct address_space_operations v9fs_addr_operations;
|
||||
extern const struct file_operations v9fs_file_operations;
|
||||
extern const struct file_operations v9fs_file_operations_dotl;
|
||||
extern const struct file_operations v9fs_dir_operations;
|
||||
extern const struct file_operations v9fs_dir_operations_dotl;
|
||||
extern const struct dentry_operations v9fs_dentry_operations;
|
||||
extern const struct dentry_operations v9fs_cached_dentry_operations;
|
||||
|
||||
|
|
|
|||
|
|
@ -203,3 +203,11 @@ const struct file_operations v9fs_dir_operations = {
|
|||
.open = v9fs_file_open,
|
||||
.release = v9fs_dir_release,
|
||||
};
|
||||
|
||||
const struct file_operations v9fs_dir_operations_dotl = {
|
||||
.read = generic_read_dir,
|
||||
.llseek = generic_file_llseek,
|
||||
.readdir = v9fs_dir_readdir,
|
||||
.open = v9fs_file_open,
|
||||
.release = v9fs_dir_release,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -296,3 +296,14 @@ const struct file_operations v9fs_file_operations = {
|
|||
.mmap = generic_file_readonly_mmap,
|
||||
.fsync = v9fs_file_fsync,
|
||||
};
|
||||
|
||||
const struct file_operations v9fs_file_operations_dotl = {
|
||||
.llseek = generic_file_llseek,
|
||||
.read = v9fs_file_read,
|
||||
.write = v9fs_file_write,
|
||||
.open = v9fs_file_open,
|
||||
.release = v9fs_dir_release,
|
||||
.lock = v9fs_file_lock,
|
||||
.mmap = generic_file_readonly_mmap,
|
||||
.fsync = v9fs_file_fsync,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -44,9 +44,12 @@
|
|||
#include "cache.h"
|
||||
|
||||
static const struct inode_operations v9fs_dir_inode_operations;
|
||||
static const struct inode_operations v9fs_dir_inode_operations_ext;
|
||||
static const struct inode_operations v9fs_dir_inode_operations_dotu;
|
||||
static const struct inode_operations v9fs_dir_inode_operations_dotl;
|
||||
static const struct inode_operations v9fs_file_inode_operations;
|
||||
static const struct inode_operations v9fs_file_inode_operations_dotl;
|
||||
static const struct inode_operations v9fs_symlink_inode_operations;
|
||||
static const struct inode_operations v9fs_symlink_inode_operations_dotl;
|
||||
|
||||
/**
|
||||
* unixmode2p9mode - convert unix mode bits to plan 9
|
||||
|
|
@ -273,25 +276,44 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
|
|||
init_special_inode(inode, inode->i_mode, inode->i_rdev);
|
||||
break;
|
||||
case S_IFREG:
|
||||
inode->i_op = &v9fs_file_inode_operations;
|
||||
inode->i_fop = &v9fs_file_operations;
|
||||
if (v9fs_proto_dotl(v9ses)) {
|
||||
inode->i_op = &v9fs_file_inode_operations_dotl;
|
||||
inode->i_fop = &v9fs_file_operations_dotl;
|
||||
} else {
|
||||
inode->i_op = &v9fs_file_inode_operations;
|
||||
inode->i_fop = &v9fs_file_operations;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case S_IFLNK:
|
||||
if (!v9fs_proto_dotu(v9ses)) {
|
||||
P9_DPRINTK(P9_DEBUG_ERROR,
|
||||
"extended modes used w/o 9P2000.u\n");
|
||||
if (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)) {
|
||||
P9_DPRINTK(P9_DEBUG_ERROR, "extended modes used with "
|
||||
"legacy protocol.\n");
|
||||
err = -EINVAL;
|
||||
goto error;
|
||||
}
|
||||
inode->i_op = &v9fs_symlink_inode_operations;
|
||||
|
||||
if (v9fs_proto_dotl(v9ses))
|
||||
inode->i_op = &v9fs_symlink_inode_operations_dotl;
|
||||
else
|
||||
inode->i_op = &v9fs_symlink_inode_operations;
|
||||
|
||||
break;
|
||||
case S_IFDIR:
|
||||
inc_nlink(inode);
|
||||
if (v9fs_proto_dotu(v9ses))
|
||||
inode->i_op = &v9fs_dir_inode_operations_ext;
|
||||
if (v9fs_proto_dotl(v9ses))
|
||||
inode->i_op = &v9fs_dir_inode_operations_dotl;
|
||||
else if (v9fs_proto_dotu(v9ses))
|
||||
inode->i_op = &v9fs_dir_inode_operations_dotu;
|
||||
else
|
||||
inode->i_op = &v9fs_dir_inode_operations;
|
||||
inode->i_fop = &v9fs_dir_operations;
|
||||
|
||||
if (v9fs_proto_dotl(v9ses))
|
||||
inode->i_fop = &v9fs_dir_operations_dotl;
|
||||
else
|
||||
inode->i_fop = &v9fs_dir_operations;
|
||||
|
||||
break;
|
||||
default:
|
||||
P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n",
|
||||
|
|
@ -432,14 +454,12 @@ static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir)
|
|||
{
|
||||
int retval;
|
||||
struct inode *file_inode;
|
||||
struct v9fs_session_info *v9ses;
|
||||
struct p9_fid *v9fid;
|
||||
|
||||
P9_DPRINTK(P9_DEBUG_VFS, "inode: %p dentry: %p rmdir: %d\n", dir, file,
|
||||
rmdir);
|
||||
|
||||
file_inode = file->d_inode;
|
||||
v9ses = v9fs_inode2v9ses(file_inode);
|
||||
v9fid = v9fs_fid_clone(file);
|
||||
if (IS_ERR(v9fid))
|
||||
return PTR_ERR(v9fid);
|
||||
|
|
@ -482,12 +502,11 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
|
|||
ofid = NULL;
|
||||
fid = NULL;
|
||||
name = (char *) dentry->d_name.name;
|
||||
dfid = v9fs_fid_clone(dentry->d_parent);
|
||||
dfid = v9fs_fid_lookup(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;
|
||||
P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
/* clone a fid to use for creation */
|
||||
|
|
@ -495,8 +514,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
|
|||
if (IS_ERR(ofid)) {
|
||||
err = PTR_ERR(ofid);
|
||||
P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
|
||||
ofid = NULL;
|
||||
goto error;
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
err = p9_client_fcreate(ofid, name, perm, mode, extension);
|
||||
|
|
@ -506,14 +524,13 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
|
|||
}
|
||||
|
||||
/* now walk from the parent so we can get unopened fid */
|
||||
fid = p9_client_walk(dfid, 1, &name, 0);
|
||||
fid = p9_client_walk(dfid, 1, &name, 1);
|
||||
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
|
||||
dfid = NULL;
|
||||
}
|
||||
|
||||
/* instantiate inode and assign the unopened fid to the dentry */
|
||||
inode = v9fs_inode_from_fid(v9ses, fid, dir->i_sb);
|
||||
|
|
@ -536,9 +553,6 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
|
|||
return ofid;
|
||||
|
||||
error:
|
||||
if (dfid)
|
||||
p9_client_clunk(dfid);
|
||||
|
||||
if (ofid)
|
||||
p9_client_clunk(ofid);
|
||||
|
||||
|
|
@ -673,8 +687,8 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
|
|||
if (IS_ERR(fid)) {
|
||||
result = PTR_ERR(fid);
|
||||
if (result == -ENOENT) {
|
||||
d_add(dentry, NULL);
|
||||
return NULL;
|
||||
inode = NULL;
|
||||
goto inst_out;
|
||||
}
|
||||
|
||||
return ERR_PTR(result);
|
||||
|
|
@ -691,7 +705,8 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
|
|||
if (result < 0)
|
||||
goto error;
|
||||
|
||||
if ((fid->qid.version) && (v9ses->cache))
|
||||
inst_out:
|
||||
if (v9ses->cache)
|
||||
dentry->d_op = &v9fs_cached_dentry_operations;
|
||||
else
|
||||
dentry->d_op = &v9fs_dentry_operations;
|
||||
|
|
@ -770,6 +785,13 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
|
|||
goto clunk_olddir;
|
||||
}
|
||||
|
||||
if (v9fs_proto_dotl(v9ses)) {
|
||||
retval = p9_client_rename(oldfid, newdirfid,
|
||||
(char *) new_dentry->d_name.name);
|
||||
if (retval != -ENOSYS)
|
||||
goto clunk_newdir;
|
||||
}
|
||||
|
||||
/* 9P can only handle file rename in the same directory */
|
||||
if (memcmp(&olddirfid->qid, &newdirfid->qid, sizeof(newdirfid->qid))) {
|
||||
P9_DPRINTK(P9_DEBUG_ERROR,
|
||||
|
|
@ -1195,6 +1217,8 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
|
|||
sprintf(name, "c %u %u", MAJOR(rdev), MINOR(rdev));
|
||||
else if (S_ISFIFO(mode))
|
||||
*name = 0;
|
||||
else if (S_ISSOCK(mode))
|
||||
*name = 0;
|
||||
else {
|
||||
__putname(name);
|
||||
return -EINVAL;
|
||||
|
|
@ -1206,7 +1230,21 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
|
|||
return retval;
|
||||
}
|
||||
|
||||
static const struct inode_operations v9fs_dir_inode_operations_ext = {
|
||||
static const struct inode_operations v9fs_dir_inode_operations_dotu = {
|
||||
.create = v9fs_vfs_create,
|
||||
.lookup = v9fs_vfs_lookup,
|
||||
.symlink = v9fs_vfs_symlink,
|
||||
.link = v9fs_vfs_link,
|
||||
.unlink = v9fs_vfs_unlink,
|
||||
.mkdir = v9fs_vfs_mkdir,
|
||||
.rmdir = v9fs_vfs_rmdir,
|
||||
.mknod = v9fs_vfs_mknod,
|
||||
.rename = v9fs_vfs_rename,
|
||||
.getattr = v9fs_vfs_getattr,
|
||||
.setattr = v9fs_vfs_setattr,
|
||||
};
|
||||
|
||||
static const struct inode_operations v9fs_dir_inode_operations_dotl = {
|
||||
.create = v9fs_vfs_create,
|
||||
.lookup = v9fs_vfs_lookup,
|
||||
.symlink = v9fs_vfs_symlink,
|
||||
|
|
@ -1237,6 +1275,11 @@ static const struct inode_operations v9fs_file_inode_operations = {
|
|||
.setattr = v9fs_vfs_setattr,
|
||||
};
|
||||
|
||||
static const struct inode_operations v9fs_file_inode_operations_dotl = {
|
||||
.getattr = v9fs_vfs_getattr,
|
||||
.setattr = v9fs_vfs_setattr,
|
||||
};
|
||||
|
||||
static const struct inode_operations v9fs_symlink_inode_operations = {
|
||||
.readlink = generic_readlink,
|
||||
.follow_link = v9fs_vfs_follow_link,
|
||||
|
|
@ -1244,3 +1287,11 @@ static const struct inode_operations v9fs_symlink_inode_operations = {
|
|||
.getattr = v9fs_vfs_getattr,
|
||||
.setattr = v9fs_vfs_setattr,
|
||||
};
|
||||
|
||||
static const struct inode_operations v9fs_symlink_inode_operations_dotl = {
|
||||
.readlink = generic_readlink,
|
||||
.follow_link = v9fs_vfs_follow_link,
|
||||
.put_link = v9fs_vfs_put_link,
|
||||
.getattr = v9fs_vfs_getattr,
|
||||
.setattr = v9fs_vfs_setattr,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include <linux/idr.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/statfs.h>
|
||||
#include <net/9p/9p.h>
|
||||
#include <net/9p/client.h>
|
||||
|
||||
|
|
@ -45,7 +46,7 @@
|
|||
#include "v9fs_vfs.h"
|
||||
#include "fid.h"
|
||||
|
||||
static const struct super_operations v9fs_super_ops;
|
||||
static const struct super_operations v9fs_super_ops, v9fs_super_ops_dotl;
|
||||
|
||||
/**
|
||||
* v9fs_set_super - set the superblock
|
||||
|
|
@ -76,7 +77,10 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,
|
|||
sb->s_blocksize_bits = fls(v9ses->maxdata - 1);
|
||||
sb->s_blocksize = 1 << sb->s_blocksize_bits;
|
||||
sb->s_magic = V9FS_MAGIC;
|
||||
sb->s_op = &v9fs_super_ops;
|
||||
if (v9fs_proto_dotl(v9ses))
|
||||
sb->s_op = &v9fs_super_ops_dotl;
|
||||
else
|
||||
sb->s_op = &v9fs_super_ops;
|
||||
sb->s_bdi = &v9ses->bdi;
|
||||
|
||||
sb->s_flags = flags | MS_ACTIVE | MS_SYNCHRONOUS | MS_DIRSYNC |
|
||||
|
|
@ -211,6 +215,42 @@ v9fs_umount_begin(struct super_block *sb)
|
|||
v9fs_session_begin_cancel(v9ses);
|
||||
}
|
||||
|
||||
static int v9fs_statfs(struct dentry *dentry, struct kstatfs *buf)
|
||||
{
|
||||
struct v9fs_session_info *v9ses;
|
||||
struct p9_fid *fid;
|
||||
struct p9_rstatfs rs;
|
||||
int res;
|
||||
|
||||
fid = v9fs_fid_lookup(dentry);
|
||||
if (IS_ERR(fid)) {
|
||||
res = PTR_ERR(fid);
|
||||
goto done;
|
||||
}
|
||||
|
||||
v9ses = v9fs_inode2v9ses(dentry->d_inode);
|
||||
if (v9fs_proto_dotl(v9ses)) {
|
||||
res = p9_client_statfs(fid, &rs);
|
||||
if (res == 0) {
|
||||
buf->f_type = rs.type;
|
||||
buf->f_bsize = rs.bsize;
|
||||
buf->f_blocks = rs.blocks;
|
||||
buf->f_bfree = rs.bfree;
|
||||
buf->f_bavail = rs.bavail;
|
||||
buf->f_files = rs.files;
|
||||
buf->f_ffree = rs.ffree;
|
||||
buf->f_fsid.val[0] = rs.fsid & 0xFFFFFFFFUL;
|
||||
buf->f_fsid.val[1] = (rs.fsid >> 32) & 0xFFFFFFFFUL;
|
||||
buf->f_namelen = rs.namelen;
|
||||
}
|
||||
if (res != -ENOSYS)
|
||||
goto done;
|
||||
}
|
||||
res = simple_statfs(dentry, buf);
|
||||
done:
|
||||
return res;
|
||||
}
|
||||
|
||||
static const struct super_operations v9fs_super_ops = {
|
||||
#ifdef CONFIG_9P_FSCACHE
|
||||
.alloc_inode = v9fs_alloc_inode,
|
||||
|
|
@ -222,6 +262,17 @@ static const struct super_operations v9fs_super_ops = {
|
|||
.umount_begin = v9fs_umount_begin,
|
||||
};
|
||||
|
||||
static const struct super_operations v9fs_super_ops_dotl = {
|
||||
#ifdef CONFIG_9P_FSCACHE
|
||||
.alloc_inode = v9fs_alloc_inode,
|
||||
.destroy_inode = v9fs_destroy_inode,
|
||||
#endif
|
||||
.statfs = v9fs_statfs,
|
||||
.clear_inode = v9fs_clear_inode,
|
||||
.show_options = generic_show_options,
|
||||
.umount_begin = v9fs_umount_begin,
|
||||
};
|
||||
|
||||
struct file_system_type v9fs_fs_type = {
|
||||
.name = "9p",
|
||||
.get_sb = v9fs_get_sb,
|
||||
|
|
|
|||
Loading…
Reference in a new issue