mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-04-02 04:14:14 +00:00
fs/9p: track open fids
This patch adds accounting of open fids in a list hanging off the i_private field of the corresponding inode. This allows faster lookups compared to searching the full 9p client list. The lookup code is modified accordingly. Link: http://lkml.kernel.org/r/20200923141146.90046-3-jianyong.wu@arm.com Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com> Signed-off-by: Jianyong Wu <jianyong.wu@arm.com> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
This commit is contained in:
parent
154372e67d
commit
987a648509
7 changed files with 35 additions and 10 deletions
32
fs/9p/fid.c
32
fs/9p/fid.c
|
@ -39,7 +39,7 @@ void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* v9fs_fid_find_inode - search for a fid off of the client list
|
* v9fs_fid_find_inode - search for an open fid off of the inode list
|
||||||
* @inode: return a fid pointing to a specific inode
|
* @inode: return a fid pointing to a specific inode
|
||||||
* @uid: return a fid belonging to the specified user
|
* @uid: return a fid belonging to the specified user
|
||||||
*
|
*
|
||||||
|
@ -47,24 +47,38 @@ void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
|
||||||
|
|
||||||
static struct p9_fid *v9fs_fid_find_inode(struct inode *inode, kuid_t uid)
|
static struct p9_fid *v9fs_fid_find_inode(struct inode *inode, kuid_t uid)
|
||||||
{
|
{
|
||||||
struct p9_client *clnt = v9fs_inode2v9ses(inode)->clnt;
|
struct hlist_head *h;
|
||||||
struct p9_fid *fid, *fidptr, *ret = NULL;
|
struct p9_fid *fid, *ret = NULL;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
p9_debug(P9_DEBUG_VFS, " inode: %p\n", inode);
|
p9_debug(P9_DEBUG_VFS, " inode: %p\n", inode);
|
||||||
|
|
||||||
spin_lock_irqsave(&clnt->lock, flags);
|
spin_lock(&inode->i_lock);
|
||||||
list_for_each_entry_safe(fid, fidptr, &clnt->fidlist, flist) {
|
h = (struct hlist_head *)&inode->i_private;
|
||||||
if (uid_eq(fid->uid, uid) &&
|
hlist_for_each_entry(fid, h, ilist) {
|
||||||
(inode->i_ino == v9fs_qid2ino(&fid->qid))) {
|
if (uid_eq(fid->uid, uid)) {
|
||||||
ret = fid;
|
ret = fid;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&clnt->lock, flags);
|
spin_unlock(&inode->i_lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* v9fs_open_fid_add - add an open fid to an inode
|
||||||
|
* @dentry: inode that the fid is being added to
|
||||||
|
* @fid: fid to add
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
void v9fs_open_fid_add(struct inode *inode, struct p9_fid *fid)
|
||||||
|
{
|
||||||
|
spin_lock(&inode->i_lock);
|
||||||
|
hlist_add_head(&fid->ilist, (struct hlist_head *)&inode->i_private);
|
||||||
|
spin_unlock(&inode->i_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* v9fs_fid_find - retrieve a fid that belongs to the specified uid
|
* v9fs_fid_find - retrieve a fid that belongs to the specified uid
|
||||||
* @dentry: dentry to look for fid in
|
* @dentry: dentry to look for fid in
|
||||||
|
|
|
@ -15,6 +15,7 @@ static inline struct p9_fid *v9fs_parent_fid(struct dentry *dentry)
|
||||||
}
|
}
|
||||||
void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid);
|
void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid);
|
||||||
struct p9_fid *v9fs_writeback_fid(struct dentry *dentry);
|
struct p9_fid *v9fs_writeback_fid(struct dentry *dentry);
|
||||||
|
void v9fs_open_fid_add(struct inode *inode, struct p9_fid *fid);
|
||||||
static inline struct p9_fid *clone_fid(struct p9_fid *fid)
|
static inline struct p9_fid *clone_fid(struct p9_fid *fid)
|
||||||
{
|
{
|
||||||
return IS_ERR(fid) ? fid : p9_client_walk(fid, 0, NULL, 1);
|
return IS_ERR(fid) ? fid : p9_client_walk(fid, 0, NULL, 1);
|
||||||
|
|
|
@ -210,6 +210,9 @@ int v9fs_dir_release(struct inode *inode, struct file *filp)
|
||||||
fid = filp->private_data;
|
fid = filp->private_data;
|
||||||
p9_debug(P9_DEBUG_VFS, "inode: %p filp: %p fid: %d\n",
|
p9_debug(P9_DEBUG_VFS, "inode: %p filp: %p fid: %d\n",
|
||||||
inode, filp, fid ? fid->fid : -1);
|
inode, filp, fid ? fid->fid : -1);
|
||||||
|
spin_lock(&inode->i_lock);
|
||||||
|
hlist_del(&fid->ilist);
|
||||||
|
spin_unlock(&inode->i_lock);
|
||||||
if (fid)
|
if (fid)
|
||||||
p9_client_clunk(fid);
|
p9_client_clunk(fid);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -96,6 +96,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
|
||||||
mutex_unlock(&v9inode->v_mutex);
|
mutex_unlock(&v9inode->v_mutex);
|
||||||
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
|
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
|
||||||
v9fs_cache_inode_set_cookie(inode, file);
|
v9fs_cache_inode_set_cookie(inode, file);
|
||||||
|
v9fs_open_fid_add(inode, fid);
|
||||||
return 0;
|
return 0;
|
||||||
out_error:
|
out_error:
|
||||||
p9_client_clunk(file->private_data);
|
p9_client_clunk(file->private_data);
|
||||||
|
|
|
@ -256,6 +256,7 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses,
|
||||||
inode->i_rdev = rdev;
|
inode->i_rdev = rdev;
|
||||||
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
|
inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
|
||||||
inode->i_mapping->a_ops = &v9fs_addr_operations;
|
inode->i_mapping->a_ops = &v9fs_addr_operations;
|
||||||
|
inode->i_private = NULL;
|
||||||
|
|
||||||
switch (mode & S_IFMT) {
|
switch (mode & S_IFMT) {
|
||||||
case S_IFIFO:
|
case S_IFIFO:
|
||||||
|
@ -796,6 +797,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
|
||||||
struct v9fs_session_info *v9ses;
|
struct v9fs_session_info *v9ses;
|
||||||
struct p9_fid *fid, *inode_fid;
|
struct p9_fid *fid, *inode_fid;
|
||||||
struct dentry *res = NULL;
|
struct dentry *res = NULL;
|
||||||
|
struct inode *inode;
|
||||||
|
|
||||||
if (d_in_lookup(dentry)) {
|
if (d_in_lookup(dentry)) {
|
||||||
res = v9fs_vfs_lookup(dir, dentry, 0);
|
res = v9fs_vfs_lookup(dir, dentry, 0);
|
||||||
|
@ -824,7 +826,8 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
|
||||||
}
|
}
|
||||||
|
|
||||||
v9fs_invalidate_inode_attr(dir);
|
v9fs_invalidate_inode_attr(dir);
|
||||||
v9inode = V9FS_I(d_inode(dentry));
|
inode = d_inode(dentry);
|
||||||
|
v9inode = V9FS_I(inode);
|
||||||
mutex_lock(&v9inode->v_mutex);
|
mutex_lock(&v9inode->v_mutex);
|
||||||
if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) &&
|
if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) &&
|
||||||
!v9inode->writeback_fid &&
|
!v9inode->writeback_fid &&
|
||||||
|
@ -852,6 +855,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
|
||||||
file->private_data = fid;
|
file->private_data = fid;
|
||||||
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
|
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
|
||||||
v9fs_cache_inode_set_cookie(d_inode(dentry), file);
|
v9fs_cache_inode_set_cookie(d_inode(dentry), file);
|
||||||
|
v9fs_open_fid_add(inode, fid);
|
||||||
|
|
||||||
file->f_mode |= FMODE_CREATED;
|
file->f_mode |= FMODE_CREATED;
|
||||||
out:
|
out:
|
||||||
|
|
|
@ -342,6 +342,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
|
||||||
file->private_data = ofid;
|
file->private_data = ofid;
|
||||||
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
|
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
|
||||||
v9fs_cache_inode_set_cookie(inode, file);
|
v9fs_cache_inode_set_cookie(inode, file);
|
||||||
|
v9fs_open_fid_add(inode, ofid);
|
||||||
file->f_mode |= FMODE_CREATED;
|
file->f_mode |= FMODE_CREATED;
|
||||||
out:
|
out:
|
||||||
v9fs_put_acl(dacl, pacl);
|
v9fs_put_acl(dacl, pacl);
|
||||||
|
|
|
@ -152,6 +152,7 @@ struct p9_fid {
|
||||||
void *rdir;
|
void *rdir;
|
||||||
|
|
||||||
struct hlist_node dlist; /* list of all fids attached to a dentry */
|
struct hlist_node dlist; /* list of all fids attached to a dentry */
|
||||||
|
struct hlist_node ilist;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue