mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-27 20:13:57 +08:00
autofs: use dentry info count instead of simple_empty()
The dentry info. field count is used to check if a dentry is in use during expire. But, to be used for this the count field must account for the presence of child dentries in a directory dentry. Therefore it can also be used to check for an empty directory dentry which can be done without having to to take an additional lock or account for the presence of a readdir cursor dentry as is done by simple_empty(). Link: https://lkml.kernel.org/r/165724459238.30914.1504611159945950108.stgit@donald.themaw.net Signed-off-by: Ian Kent <raven@themaw.net> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: David Howells <dhowells@redhat.com> Cc: Miklos Szeredi <miklos@szeredi.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
9ccbac76e7
commit
a4a8730387
@ -148,6 +148,11 @@ static inline int autofs_oz_mode(struct autofs_sb_info *sbi)
|
||||
task_pgrp(current) == sbi->oz_pgrp);
|
||||
}
|
||||
|
||||
static inline bool autofs_empty(struct autofs_info *ino)
|
||||
{
|
||||
return ino->count < 2;
|
||||
}
|
||||
|
||||
struct inode *autofs_get_inode(struct super_block *, umode_t);
|
||||
void autofs_free_ino(struct autofs_info *);
|
||||
|
||||
|
@ -371,7 +371,7 @@ static struct dentry *should_expire(struct dentry *dentry,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (simple_empty(dentry))
|
||||
if (autofs_empty(ino))
|
||||
return NULL;
|
||||
|
||||
/* Case 2: tree mount, expire iff entire tree is not busy */
|
||||
|
@ -79,6 +79,7 @@ static int autofs_dir_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct dentry *dentry = file->f_path.dentry;
|
||||
struct autofs_sb_info *sbi = autofs_sbi(dentry->d_sb);
|
||||
struct autofs_info *ino = autofs_dentry_ino(dentry);
|
||||
|
||||
pr_debug("file=%p dentry=%p %pd\n", file, dentry, dentry);
|
||||
|
||||
@ -95,7 +96,7 @@ static int autofs_dir_open(struct inode *inode, struct file *file)
|
||||
* it.
|
||||
*/
|
||||
spin_lock(&sbi->lookup_lock);
|
||||
if (!path_is_mountpoint(&file->f_path) && simple_empty(dentry)) {
|
||||
if (!path_is_mountpoint(&file->f_path) && autofs_empty(ino)) {
|
||||
spin_unlock(&sbi->lookup_lock);
|
||||
return -ENOENT;
|
||||
}
|
||||
@ -364,7 +365,7 @@ static struct vfsmount *autofs_d_automount(struct path *path)
|
||||
* the mount never trigger mounts themselves (they have an
|
||||
* autofs trigger mount mounted on them). But v4 pseudo direct
|
||||
* mounts do need the leaves to trigger mounts. In this case
|
||||
* we have no choice but to use the list_empty() check and
|
||||
* we have no choice but to use the autofs_empty() check and
|
||||
* require user space behave.
|
||||
*/
|
||||
if (sbi->version > 4) {
|
||||
@ -373,7 +374,7 @@ static struct vfsmount *autofs_d_automount(struct path *path)
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
if (!simple_empty(dentry)) {
|
||||
if (!autofs_empty(ino)) {
|
||||
spin_unlock(&sbi->fs_lock);
|
||||
goto done;
|
||||
}
|
||||
@ -428,9 +429,8 @@ static int autofs_d_manage(const struct path *path, bool rcu_walk)
|
||||
|
||||
if (rcu_walk) {
|
||||
/* We don't need fs_lock in rcu_walk mode,
|
||||
* just testing 'AUTOFS_INFO_NO_RCU' is enough.
|
||||
* simple_empty() takes a spinlock, so leave it
|
||||
* to last.
|
||||
* just testing 'AUTOFS_INF_WANT_EXPIRE' is enough.
|
||||
*
|
||||
* We only return -EISDIR when certain this isn't
|
||||
* a mount-trap.
|
||||
*/
|
||||
@ -443,9 +443,7 @@ static int autofs_d_manage(const struct path *path, bool rcu_walk)
|
||||
inode = d_inode_rcu(dentry);
|
||||
if (inode && S_ISLNK(inode->i_mode))
|
||||
return -EISDIR;
|
||||
if (list_empty(&dentry->d_subdirs))
|
||||
return 0;
|
||||
if (!simple_empty(dentry))
|
||||
if (!autofs_empty(ino))
|
||||
return -EISDIR;
|
||||
return 0;
|
||||
}
|
||||
@ -465,7 +463,7 @@ static int autofs_d_manage(const struct path *path, bool rcu_walk)
|
||||
* we can avoid needless calls ->d_automount() and avoid
|
||||
* an incorrect ELOOP error return.
|
||||
*/
|
||||
if ((!path_is_mountpoint(path) && !simple_empty(dentry)) ||
|
||||
if ((!path_is_mountpoint(path) && !autofs_empty(ino)) ||
|
||||
(d_really_is_positive(dentry) && d_is_symlink(dentry)))
|
||||
status = -EISDIR;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user