Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 235041
b: refs/heads/master
c: b3cbea0
h: refs/heads/master
i:
  235039: 9a47a35
v: v3
  • Loading branch information
Aneesh Kumar K.V authored and Eric Van Hensbergen committed Mar 15, 2011
1 parent 298add0 commit f763c11
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0e432703aac3b187dd88d81ac23282f7b1c71002
refs/heads/master: b3cbea03b4edbd6b625dbf813bf8c30c22213cb7
4 changes: 4 additions & 0 deletions trunk/fs/9p/v9fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,16 @@ struct v9fs_session_info {
struct p9_fid *root_fid; /* Used for file system sync */
};

/* cache_validity flags */
#define V9FS_INO_INVALID_ATTR 0x01

struct v9fs_inode {
#ifdef CONFIG_9P_FSCACHE
spinlock_t fscache_lock;
struct fscache_cookie *fscache;
struct p9_qid *fscache_key;
#endif
unsigned int cache_validity;
struct p9_fid *writeback_fid;
struct inode vfs_inode;
};
Expand Down
10 changes: 10 additions & 0 deletions trunk/fs/9p/v9fs_vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,14 @@ int v9fs_vfs_setattr_dotl(struct dentry *, struct iattr *);
int v9fs_file_fsync_dotl(struct file *filp, int datasync);
ssize_t v9fs_file_write_internal(struct inode *, struct p9_fid *,
const char __user *, size_t, loff_t *, int);
int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode);
int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode);
static inline void v9fs_invalidate_inode_attr(struct inode *inode)
{
struct v9fs_inode *v9inode;
v9inode = V9FS_I(inode);
v9inode->cache_validity |= V9FS_INO_INVALID_ATTR;
return;
}

#define P9_LOCK_TIMEOUT (30*HZ)
34 changes: 34 additions & 0 deletions trunk/fs/9p/vfs_dentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,41 @@ static void v9fs_dentry_release(struct dentry *dentry)
}
}

static int v9fs_lookup_revalidate(struct dentry *dentry, struct nameidata *nd)
{
struct p9_fid *fid;
struct inode *inode;
struct v9fs_inode *v9inode;

if (nd->flags & LOOKUP_RCU)
return -ECHILD;

inode = dentry->d_inode;
if (!inode)
goto out_valid;

v9inode = V9FS_I(inode);
if (v9inode->cache_validity & V9FS_INO_INVALID_ATTR) {
int retval;
struct v9fs_session_info *v9ses;
fid = v9fs_fid_lookup(dentry);
if (IS_ERR(fid))
return PTR_ERR(fid);

v9ses = v9fs_inode2v9ses(inode);
if (v9fs_proto_dotl(v9ses))
retval = v9fs_refresh_inode_dotl(fid, inode);
else
retval = v9fs_refresh_inode(fid, inode);
if (retval <= 0)
return retval;
}
out_valid:
return 1;
}

const struct dentry_operations v9fs_cached_dentry_operations = {
.d_revalidate = v9fs_lookup_revalidate,
.d_delete = v9fs_cached_dentry_delete,
.d_release = v9fs_dentry_release,
};
Expand Down
29 changes: 29 additions & 0 deletions trunk/fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ struct inode *v9fs_alloc_inode(struct super_block *sb)
spin_lock_init(&v9inode->fscache_lock);
#endif
v9inode->writeback_fid = NULL;
v9inode->cache_validity = 0;
return &v9inode->vfs_inode;
}

Expand Down Expand Up @@ -1010,6 +1011,7 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
char tag_name[14];
unsigned int i_nlink;
struct v9fs_session_info *v9ses = sb->s_fs_info;
struct v9fs_inode *v9inode = V9FS_I(inode);

inode->i_nlink = 1;

Expand Down Expand Up @@ -1069,6 +1071,7 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,

/* not real number of blocks, but 512 byte ones ... */
inode->i_blocks = (i_size_read(inode) + 512 - 1) >> 9;
v9inode->cache_validity &= ~V9FS_INO_INVALID_ATTR;
}

/**
Expand Down Expand Up @@ -1323,6 +1326,32 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
return retval;
}

int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode)
{
loff_t i_size;
struct p9_wstat *st;
struct v9fs_session_info *v9ses;

v9ses = v9fs_inode2v9ses(inode);
st = p9_client_stat(fid);
if (IS_ERR(st))
return PTR_ERR(st);

spin_lock(&inode->i_lock);
/*
* We don't want to refresh inode->i_size,
* because we may have cached data
*/
i_size = inode->i_size;
v9fs_stat2inode(st, inode, inode->i_sb);
if (v9ses->cache)
inode->i_size = i_size;
spin_unlock(&inode->i_lock);
p9stat_free(st);
kfree(st);
return 0;
}

static const struct inode_operations v9fs_dir_inode_operations_dotu = {
.create = v9fs_vfs_create,
.lookup = v9fs_vfs_lookup,
Expand Down
27 changes: 27 additions & 0 deletions trunk/fs/9p/vfs_inode_dotl.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
void
v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
{
struct v9fs_inode *v9inode = V9FS_I(inode);

if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) {
inode->i_atime.tv_sec = stat->st_atime_sec;
Expand Down Expand Up @@ -542,6 +543,7 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
/* Currently we don't support P9_STATS_BTIME and P9_STATS_DATA_VERSION
* because the inode structure does not have fields for them.
*/
v9inode->cache_validity &= ~V9FS_INO_INVALID_ATTR;
}

static int
Expand Down Expand Up @@ -822,6 +824,31 @@ v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
return NULL;
}

int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode)
{
loff_t i_size;
struct p9_stat_dotl *st;
struct v9fs_session_info *v9ses;

v9ses = v9fs_inode2v9ses(inode);
st = p9_client_getattr_dotl(fid, P9_STATS_ALL);
if (IS_ERR(st))
return PTR_ERR(st);

spin_lock(&inode->i_lock);
/*
* We don't want to refresh inode->i_size,
* because we may have cached data
*/
i_size = inode->i_size;
v9fs_stat2inode_dotl(st, inode);
if (v9ses->cache)
inode->i_size = i_size;
spin_unlock(&inode->i_lock);
kfree(st);
return 0;
}

const struct inode_operations v9fs_dir_inode_operations_dotl = {
.create = v9fs_vfs_create_dotl,
.lookup = v9fs_vfs_lookup,
Expand Down

0 comments on commit f763c11

Please sign in to comment.