Commit 9523a841 authored by Eric Van Hensbergen's avatar Eric Van Hensbergen

9p: cache meta-data when cache=loose

This patch expands the impact of the loose cache mode to allow for cached
metadata increasing the performance of directory listings and other metadata
read operations.
Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
parent 1d6b5602
...@@ -71,6 +71,10 @@ int v9fs_file_open(struct inode *inode, struct file *file) ...@@ -71,6 +71,10 @@ int v9fs_file_open(struct inode *inode, struct file *file)
p9_client_clunk(fid); p9_client_clunk(fid);
return err; return err;
} }
if (omode & P9_OTRUNC) {
inode->i_size = 0;
inode->i_blocks = 0;
}
} }
file->private_data = fid; file->private_data = fid;
...@@ -151,6 +155,7 @@ v9fs_file_write(struct file *filp, const char __user * data, ...@@ -151,6 +155,7 @@ v9fs_file_write(struct file *filp, const char __user * data,
{ {
int ret; int ret;
struct p9_fid *fid; struct p9_fid *fid;
struct inode *inode = filp->f_path.dentry->d_inode;
P9_DPRINTK(P9_DEBUG_VFS, "data %p count %d offset %x\n", data, P9_DPRINTK(P9_DEBUG_VFS, "data %p count %d offset %x\n", data,
(int)count, (int)*offset); (int)count, (int)*offset);
...@@ -160,7 +165,12 @@ v9fs_file_write(struct file *filp, const char __user * data, ...@@ -160,7 +165,12 @@ v9fs_file_write(struct file *filp, const char __user * data,
if (ret > 0) if (ret > 0)
*offset += ret; *offset += ret;
invalidate_inode_pages2(filp->f_path.dentry->d_inode->i_mapping); if (*offset > inode->i_size) {
inode->i_size = *offset;
inode->i_blocks = (inode->i_size + 512 - 1) >> 9;
}
invalidate_inode_pages2(inode->i_mapping);
return ret; return ret;
} }
......
...@@ -716,6 +716,9 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, ...@@ -716,6 +716,9 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry); P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry);
err = -EPERM; err = -EPERM;
v9ses = v9fs_inode2v9ses(dentry->d_inode); v9ses = v9fs_inode2v9ses(dentry->d_inode);
if (v9ses->cache == CACHE_LOOSE)
return simple_getattr(mnt, dentry, stat);
fid = v9fs_fid_lookup(dentry); fid = v9fs_fid_lookup(dentry);
if (IS_ERR(fid)) if (IS_ERR(fid))
return PTR_ERR(fid); return PTR_ERR(fid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment