Commit 1bcf4c5c authored by Trond Myklebust's avatar Trond Myklebust

NFS: Allow getattr to also report readdirplus cache hits

If the use called stat() on an 'ls -l' workload, and the attribute
cache was successfully revalidate by READDIRPLUS, then we want to
report that back so that the readdir code continues to use
readdirplus.
Reviewed-by: default avatarBenjamin Coddington <bcodding@redhat.com>
Tested-by: default avatarBenjamin Coddington <bcodding@redhat.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 63519fbc
...@@ -459,7 +459,6 @@ bool nfs_use_readdirplus(struct inode *dir, struct dir_context *ctx) ...@@ -459,7 +459,6 @@ bool nfs_use_readdirplus(struct inode *dir, struct dir_context *ctx)
* use of readdirplus to accelerate any future lookups in the same * use of readdirplus to accelerate any future lookups in the same
* directory. * directory.
*/ */
static
void nfs_advise_use_readdirplus(struct inode *dir) void nfs_advise_use_readdirplus(struct inode *dir)
{ {
struct nfs_inode *nfsi = NFS_I(dir); struct nfs_inode *nfsi = NFS_I(dir);
......
...@@ -634,15 +634,28 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr, ...@@ -634,15 +634,28 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr,
} }
EXPORT_SYMBOL_GPL(nfs_setattr_update_inode); EXPORT_SYMBOL_GPL(nfs_setattr_update_inode);
static void nfs_request_parent_use_readdirplus(struct dentry *dentry) static void nfs_readdirplus_parent_cache_miss(struct dentry *dentry)
{ {
struct dentry *parent; struct dentry *parent;
if (!nfs_server_capable(d_inode(dentry), NFS_CAP_READDIRPLUS))
return;
parent = dget_parent(dentry); parent = dget_parent(dentry);
nfs_force_use_readdirplus(d_inode(parent)); nfs_force_use_readdirplus(d_inode(parent));
dput(parent); dput(parent);
} }
static void nfs_readdirplus_parent_cache_hit(struct dentry *dentry)
{
struct dentry *parent;
if (!nfs_server_capable(d_inode(dentry), NFS_CAP_READDIRPLUS))
return;
parent = dget_parent(dentry);
nfs_advise_use_readdirplus(d_inode(parent));
dput(parent);
}
static bool nfs_need_revalidate_inode(struct inode *inode) static bool nfs_need_revalidate_inode(struct inode *inode)
{ {
if (NFS_I(inode)->cache_validity & if (NFS_I(inode)->cache_validity &
...@@ -683,10 +696,10 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) ...@@ -683,10 +696,10 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
if (need_atime || nfs_need_revalidate_inode(inode)) { if (need_atime || nfs_need_revalidate_inode(inode)) {
struct nfs_server *server = NFS_SERVER(inode); struct nfs_server *server = NFS_SERVER(inode);
if (server->caps & NFS_CAP_READDIRPLUS) nfs_readdirplus_parent_cache_miss(dentry);
nfs_request_parent_use_readdirplus(dentry);
err = __nfs_revalidate_inode(server, inode); err = __nfs_revalidate_inode(server, inode);
} } else
nfs_readdirplus_parent_cache_hit(dentry);
if (!err) { if (!err) {
generic_fillattr(inode, stat); generic_fillattr(inode, stat);
stat->ino = nfs_compat_user_ino64(NFS_FILEID(inode)); stat->ino = nfs_compat_user_ino64(NFS_FILEID(inode));
......
...@@ -344,6 +344,7 @@ extern struct nfs_client *nfs_init_client(struct nfs_client *clp, ...@@ -344,6 +344,7 @@ extern struct nfs_client *nfs_init_client(struct nfs_client *clp,
const struct nfs_client_initdata *); const struct nfs_client_initdata *);
/* dir.c */ /* dir.c */
extern void nfs_advise_use_readdirplus(struct inode *dir);
extern void nfs_force_use_readdirplus(struct inode *dir); extern void nfs_force_use_readdirplus(struct inode *dir);
extern unsigned long nfs_access_cache_count(struct shrinker *shrink, extern unsigned long nfs_access_cache_count(struct shrinker *shrink,
struct shrink_control *sc); struct shrink_control *sc);
......
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