kernfs: move revalidate to be near lookup
While the dentry operation kernfs_dop_revalidate() is grouped with dentry type functions it also has a strong affinity to the inode operation ->lookup(). It makes sense to locate this function near to kernfs_iop_lookup() because we will be adding VFS negative dentry caching to reduce path lookup overhead for non-existent paths. There's no functional change from this patch. Signed-off-by: Ian Kent <raven@themaw.net> Reviewed-by: Miklos Szeredi <mszeredi@redhat.com> Link: https://lore.kernel.org/r/162375275365.232295.8995526416263659926.stgit@web.messagingengine.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
68afbd8459
commit
d826e03651
@ -548,49 +548,6 @@ void kernfs_put(struct kernfs_node *kn)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(kernfs_put);
|
||||
|
||||
static int kernfs_dop_revalidate(struct dentry *dentry, unsigned int flags)
|
||||
{
|
||||
struct kernfs_node *kn;
|
||||
|
||||
if (flags & LOOKUP_RCU)
|
||||
return -ECHILD;
|
||||
|
||||
/* Always perform fresh lookup for negatives */
|
||||
if (d_really_is_negative(dentry))
|
||||
goto out_bad_unlocked;
|
||||
|
||||
kn = kernfs_dentry_node(dentry);
|
||||
mutex_lock(&kernfs_mutex);
|
||||
|
||||
/* The kernfs node has been deactivated */
|
||||
if (!kernfs_active(kn))
|
||||
goto out_bad;
|
||||
|
||||
/* The kernfs node has been moved? */
|
||||
if (kernfs_dentry_node(dentry->d_parent) != kn->parent)
|
||||
goto out_bad;
|
||||
|
||||
/* The kernfs node has been renamed */
|
||||
if (strcmp(dentry->d_name.name, kn->name) != 0)
|
||||
goto out_bad;
|
||||
|
||||
/* The kernfs node has been moved to a different namespace */
|
||||
if (kn->parent && kernfs_ns_enabled(kn->parent) &&
|
||||
kernfs_info(dentry->d_sb)->ns != kn->ns)
|
||||
goto out_bad;
|
||||
|
||||
mutex_unlock(&kernfs_mutex);
|
||||
return 1;
|
||||
out_bad:
|
||||
mutex_unlock(&kernfs_mutex);
|
||||
out_bad_unlocked:
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct dentry_operations kernfs_dops = {
|
||||
.d_revalidate = kernfs_dop_revalidate,
|
||||
};
|
||||
|
||||
/**
|
||||
* kernfs_node_from_dentry - determine kernfs_node associated with a dentry
|
||||
* @dentry: the dentry in question
|
||||
@ -1073,6 +1030,49 @@ struct kernfs_node *kernfs_create_empty_dir(struct kernfs_node *parent,
|
||||
return ERR_PTR(rc);
|
||||
}
|
||||
|
||||
static int kernfs_dop_revalidate(struct dentry *dentry, unsigned int flags)
|
||||
{
|
||||
struct kernfs_node *kn;
|
||||
|
||||
if (flags & LOOKUP_RCU)
|
||||
return -ECHILD;
|
||||
|
||||
/* Always perform fresh lookup for negatives */
|
||||
if (d_really_is_negative(dentry))
|
||||
goto out_bad_unlocked;
|
||||
|
||||
kn = kernfs_dentry_node(dentry);
|
||||
mutex_lock(&kernfs_mutex);
|
||||
|
||||
/* The kernfs node has been deactivated */
|
||||
if (!kernfs_active(kn))
|
||||
goto out_bad;
|
||||
|
||||
/* The kernfs node has been moved? */
|
||||
if (kernfs_dentry_node(dentry->d_parent) != kn->parent)
|
||||
goto out_bad;
|
||||
|
||||
/* The kernfs node has been renamed */
|
||||
if (strcmp(dentry->d_name.name, kn->name) != 0)
|
||||
goto out_bad;
|
||||
|
||||
/* The kernfs node has been moved to a different namespace */
|
||||
if (kn->parent && kernfs_ns_enabled(kn->parent) &&
|
||||
kernfs_info(dentry->d_sb)->ns != kn->ns)
|
||||
goto out_bad;
|
||||
|
||||
mutex_unlock(&kernfs_mutex);
|
||||
return 1;
|
||||
out_bad:
|
||||
mutex_unlock(&kernfs_mutex);
|
||||
out_bad_unlocked:
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct dentry_operations kernfs_dops = {
|
||||
.d_revalidate = kernfs_dop_revalidate,
|
||||
};
|
||||
|
||||
static struct dentry *kernfs_iop_lookup(struct inode *dir,
|
||||
struct dentry *dentry,
|
||||
unsigned int flags)
|
||||
|
Loading…
Reference in New Issue
Block a user