Commit e5c85e1f authored by Ian Kent's avatar Ian Kent Committed by Linus Torvalds

autofs: make expire flags usage consistent with v5 params

Make the usage of the expire flags consistent by naming the expire flags
the same as it is named in the version 5 miscelaneous ioctl parameters and
only check the bit flags when needed.

Link: http://lkml.kernel.org/r/152937734046.21213.9454131988766280028.stgit@pluto.themaw.netSigned-off-by: default avatarIan Kent <raven@themaw.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 571bc35c
...@@ -153,7 +153,7 @@ int autofs_expire_run(struct super_block *, struct vfsmount *, ...@@ -153,7 +153,7 @@ int autofs_expire_run(struct super_block *, struct vfsmount *,
struct autofs_sb_info *, struct autofs_sb_info *,
struct autofs_packet_expire __user *); struct autofs_packet_expire __user *);
int autofs_do_expire_multi(struct super_block *sb, struct vfsmount *mnt, int autofs_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
struct autofs_sb_info *sbi, int when); struct autofs_sb_info *sbi, unsigned int how);
int autofs_expire_multi(struct super_block *, struct vfsmount *, int autofs_expire_multi(struct super_block *, struct vfsmount *,
struct autofs_sb_info *, int __user *); struct autofs_sb_info *, int __user *);
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
/* Check if a dentry can be expired */ /* Check if a dentry can be expired */
static inline int autofs_can_expire(struct dentry *dentry, static inline int autofs_can_expire(struct dentry *dentry,
unsigned long timeout, int do_now) unsigned long timeout, unsigned int how)
{ {
struct autofs_info *ino = autofs_dentry_ino(dentry); struct autofs_info *ino = autofs_dentry_ino(dentry);
...@@ -20,7 +20,7 @@ static inline int autofs_can_expire(struct dentry *dentry, ...@@ -20,7 +20,7 @@ static inline int autofs_can_expire(struct dentry *dentry,
if (ino == NULL) if (ino == NULL)
return 0; return 0;
if (!do_now) { if (!(how & AUTOFS_EXP_IMMEDIATE)) {
/* Too young to die */ /* Too young to die */
if (!timeout || time_after(ino->last_used + timeout, jiffies)) if (!timeout || time_after(ino->last_used + timeout, jiffies))
return 0; return 0;
...@@ -185,7 +185,7 @@ static struct dentry *get_next_positive_dentry(struct dentry *prev, ...@@ -185,7 +185,7 @@ static struct dentry *get_next_positive_dentry(struct dentry *prev,
static int autofs_direct_busy(struct vfsmount *mnt, static int autofs_direct_busy(struct vfsmount *mnt,
struct dentry *top, struct dentry *top,
unsigned long timeout, unsigned long timeout,
int do_now) unsigned int how)
{ {
pr_debug("top %p %pd\n", top, top); pr_debug("top %p %pd\n", top, top);
...@@ -200,7 +200,7 @@ static int autofs_direct_busy(struct vfsmount *mnt, ...@@ -200,7 +200,7 @@ static int autofs_direct_busy(struct vfsmount *mnt,
} }
/* Timeout of a direct mount is determined by its top dentry */ /* Timeout of a direct mount is determined by its top dentry */
if (!autofs_can_expire(top, timeout, do_now)) if (!autofs_can_expire(top, timeout, how))
return 1; return 1;
return 0; return 0;
...@@ -213,7 +213,7 @@ static int autofs_direct_busy(struct vfsmount *mnt, ...@@ -213,7 +213,7 @@ static int autofs_direct_busy(struct vfsmount *mnt,
static int autofs_tree_busy(struct vfsmount *mnt, static int autofs_tree_busy(struct vfsmount *mnt,
struct dentry *top, struct dentry *top,
unsigned long timeout, unsigned long timeout,
int do_now) unsigned int how)
{ {
struct autofs_info *top_ino = autofs_dentry_ino(top); struct autofs_info *top_ino = autofs_dentry_ino(top);
struct dentry *p; struct dentry *p;
...@@ -259,7 +259,7 @@ static int autofs_tree_busy(struct vfsmount *mnt, ...@@ -259,7 +259,7 @@ static int autofs_tree_busy(struct vfsmount *mnt,
} }
/* Timeout of a tree mount is ultimately determined by its top dentry */ /* Timeout of a tree mount is ultimately determined by its top dentry */
if (!autofs_can_expire(top, timeout, do_now)) if (!autofs_can_expire(top, timeout, how))
return 1; return 1;
return 0; return 0;
...@@ -268,7 +268,7 @@ static int autofs_tree_busy(struct vfsmount *mnt, ...@@ -268,7 +268,7 @@ static int autofs_tree_busy(struct vfsmount *mnt,
static struct dentry *autofs_check_leaves(struct vfsmount *mnt, static struct dentry *autofs_check_leaves(struct vfsmount *mnt,
struct dentry *parent, struct dentry *parent,
unsigned long timeout, unsigned long timeout,
int do_now) unsigned int how)
{ {
struct dentry *p; struct dentry *p;
...@@ -284,7 +284,7 @@ static struct dentry *autofs_check_leaves(struct vfsmount *mnt, ...@@ -284,7 +284,7 @@ static struct dentry *autofs_check_leaves(struct vfsmount *mnt,
continue; continue;
/* Can we expire this guy */ /* Can we expire this guy */
if (autofs_can_expire(p, timeout, do_now)) if (autofs_can_expire(p, timeout, how))
return p; return p;
} }
} }
...@@ -295,19 +295,18 @@ static struct dentry *autofs_check_leaves(struct vfsmount *mnt, ...@@ -295,19 +295,18 @@ static struct dentry *autofs_check_leaves(struct vfsmount *mnt,
static struct dentry *autofs_expire_direct(struct super_block *sb, static struct dentry *autofs_expire_direct(struct super_block *sb,
struct vfsmount *mnt, struct vfsmount *mnt,
struct autofs_sb_info *sbi, struct autofs_sb_info *sbi,
int how) unsigned int how)
{ {
unsigned long timeout;
struct dentry *root = dget(sb->s_root); struct dentry *root = dget(sb->s_root);
int do_now = how & AUTOFS_EXP_IMMEDIATE;
struct autofs_info *ino; struct autofs_info *ino;
unsigned long timeout;
if (!root) if (!root)
return NULL; return NULL;
timeout = sbi->exp_timeout; timeout = sbi->exp_timeout;
if (!autofs_direct_busy(mnt, root, timeout, do_now)) { if (!autofs_direct_busy(mnt, root, timeout, how)) {
spin_lock(&sbi->fs_lock); spin_lock(&sbi->fs_lock);
ino = autofs_dentry_ino(root); ino = autofs_dentry_ino(root);
/* No point expiring a pending mount */ /* No point expiring a pending mount */
...@@ -318,7 +317,7 @@ static struct dentry *autofs_expire_direct(struct super_block *sb, ...@@ -318,7 +317,7 @@ static struct dentry *autofs_expire_direct(struct super_block *sb,
ino->flags |= AUTOFS_INF_WANT_EXPIRE; ino->flags |= AUTOFS_INF_WANT_EXPIRE;
spin_unlock(&sbi->fs_lock); spin_unlock(&sbi->fs_lock);
synchronize_rcu(); synchronize_rcu();
if (!autofs_direct_busy(mnt, root, timeout, do_now)) { if (!autofs_direct_busy(mnt, root, timeout, how)) {
spin_lock(&sbi->fs_lock); spin_lock(&sbi->fs_lock);
ino->flags |= AUTOFS_INF_EXPIRING; ino->flags |= AUTOFS_INF_EXPIRING;
init_completion(&ino->expire_complete); init_completion(&ino->expire_complete);
...@@ -343,10 +342,8 @@ static struct dentry *autofs_expire_direct(struct super_block *sb, ...@@ -343,10 +342,8 @@ static struct dentry *autofs_expire_direct(struct super_block *sb,
static struct dentry *should_expire(struct dentry *dentry, static struct dentry *should_expire(struct dentry *dentry,
struct vfsmount *mnt, struct vfsmount *mnt,
unsigned long timeout, unsigned long timeout,
int how) unsigned int how)
{ {
int do_now = how & AUTOFS_EXP_IMMEDIATE;
int exp_leaves = how & AUTOFS_EXP_LEAVES;
struct autofs_info *ino = autofs_dentry_ino(dentry); struct autofs_info *ino = autofs_dentry_ino(dentry);
unsigned int ino_count; unsigned int ino_count;
...@@ -368,7 +365,7 @@ static struct dentry *should_expire(struct dentry *dentry, ...@@ -368,7 +365,7 @@ static struct dentry *should_expire(struct dentry *dentry,
return NULL; return NULL;
/* Can we expire this guy */ /* Can we expire this guy */
if (autofs_can_expire(dentry, timeout, do_now)) if (autofs_can_expire(dentry, timeout, how))
return dentry; return dentry;
return NULL; return NULL;
} }
...@@ -379,7 +376,7 @@ static struct dentry *should_expire(struct dentry *dentry, ...@@ -379,7 +376,7 @@ static struct dentry *should_expire(struct dentry *dentry,
* A symlink can't be "busy" in the usual sense so * A symlink can't be "busy" in the usual sense so
* just check last used for expire timeout. * just check last used for expire timeout.
*/ */
if (autofs_can_expire(dentry, timeout, do_now)) if (autofs_can_expire(dentry, timeout, how))
return dentry; return dentry;
return NULL; return NULL;
} }
...@@ -388,13 +385,13 @@ static struct dentry *should_expire(struct dentry *dentry, ...@@ -388,13 +385,13 @@ static struct dentry *should_expire(struct dentry *dentry,
return NULL; return NULL;
/* Case 2: tree mount, expire iff entire tree is not busy */ /* Case 2: tree mount, expire iff entire tree is not busy */
if (!exp_leaves) { if (!(how & AUTOFS_EXP_LEAVES)) {
/* Path walk currently on this dentry? */ /* Path walk currently on this dentry? */
ino_count = atomic_read(&ino->count) + 1; ino_count = atomic_read(&ino->count) + 1;
if (d_count(dentry) > ino_count) if (d_count(dentry) > ino_count)
return NULL; return NULL;
if (!autofs_tree_busy(mnt, dentry, timeout, do_now)) if (!autofs_tree_busy(mnt, dentry, timeout, how))
return dentry; return dentry;
/* /*
* Case 3: pseudo direct mount, expire individual leaves * Case 3: pseudo direct mount, expire individual leaves
...@@ -408,7 +405,7 @@ static struct dentry *should_expire(struct dentry *dentry, ...@@ -408,7 +405,7 @@ static struct dentry *should_expire(struct dentry *dentry,
if (d_count(dentry) > ino_count) if (d_count(dentry) > ino_count)
return NULL; return NULL;
expired = autofs_check_leaves(mnt, dentry, timeout, do_now); expired = autofs_check_leaves(mnt, dentry, timeout, how);
if (expired) { if (expired) {
if (expired == dentry) if (expired == dentry)
dput(dentry); dput(dentry);
...@@ -427,7 +424,7 @@ static struct dentry *should_expire(struct dentry *dentry, ...@@ -427,7 +424,7 @@ static struct dentry *should_expire(struct dentry *dentry,
static struct dentry *autofs_expire_indirect(struct super_block *sb, static struct dentry *autofs_expire_indirect(struct super_block *sb,
struct vfsmount *mnt, struct vfsmount *mnt,
struct autofs_sb_info *sbi, struct autofs_sb_info *sbi,
int how) unsigned int how)
{ {
unsigned long timeout; unsigned long timeout;
struct dentry *root = sb->s_root; struct dentry *root = sb->s_root;
...@@ -443,8 +440,6 @@ static struct dentry *autofs_expire_indirect(struct super_block *sb, ...@@ -443,8 +440,6 @@ static struct dentry *autofs_expire_indirect(struct super_block *sb,
dentry = NULL; dentry = NULL;
while ((dentry = get_next_positive_subdir(dentry, root))) { while ((dentry = get_next_positive_subdir(dentry, root))) {
int flags = how;
spin_lock(&sbi->fs_lock); spin_lock(&sbi->fs_lock);
ino = autofs_dentry_ino(dentry); ino = autofs_dentry_ino(dentry);
if (ino->flags & AUTOFS_INF_WANT_EXPIRE) { if (ino->flags & AUTOFS_INF_WANT_EXPIRE) {
...@@ -453,7 +448,7 @@ static struct dentry *autofs_expire_indirect(struct super_block *sb, ...@@ -453,7 +448,7 @@ static struct dentry *autofs_expire_indirect(struct super_block *sb,
} }
spin_unlock(&sbi->fs_lock); spin_unlock(&sbi->fs_lock);
expired = should_expire(dentry, mnt, timeout, flags); expired = should_expire(dentry, mnt, timeout, how);
if (!expired) if (!expired)
continue; continue;
...@@ -466,8 +461,8 @@ static struct dentry *autofs_expire_indirect(struct super_block *sb, ...@@ -466,8 +461,8 @@ static struct dentry *autofs_expire_indirect(struct super_block *sb,
/* Make sure a reference is not taken on found if /* Make sure a reference is not taken on found if
* things have changed. * things have changed.
*/ */
flags &= ~AUTOFS_EXP_LEAVES; how &= ~AUTOFS_EXP_LEAVES;
found = should_expire(expired, mnt, timeout, flags); found = should_expire(expired, mnt, timeout, how);
if (!found || found != expired) if (!found || found != expired)
/* Something has changed, continue */ /* Something has changed, continue */
goto next; goto next;
...@@ -580,15 +575,15 @@ int autofs_expire_run(struct super_block *sb, ...@@ -580,15 +575,15 @@ int autofs_expire_run(struct super_block *sb,
} }
int autofs_do_expire_multi(struct super_block *sb, struct vfsmount *mnt, int autofs_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
struct autofs_sb_info *sbi, int when) struct autofs_sb_info *sbi, unsigned int how)
{ {
struct dentry *dentry; struct dentry *dentry;
int ret = -EAGAIN; int ret = -EAGAIN;
if (autofs_type_trigger(sbi->type)) if (autofs_type_trigger(sbi->type))
dentry = autofs_expire_direct(sb, mnt, sbi, when); dentry = autofs_expire_direct(sb, mnt, sbi, how);
else else
dentry = autofs_expire_indirect(sb, mnt, sbi, when); dentry = autofs_expire_indirect(sb, mnt, sbi, how);
if (dentry) { if (dentry) {
struct autofs_info *ino = autofs_dentry_ino(dentry); struct autofs_info *ino = autofs_dentry_ino(dentry);
...@@ -618,10 +613,10 @@ int autofs_do_expire_multi(struct super_block *sb, struct vfsmount *mnt, ...@@ -618,10 +613,10 @@ int autofs_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
int autofs_expire_multi(struct super_block *sb, struct vfsmount *mnt, int autofs_expire_multi(struct super_block *sb, struct vfsmount *mnt,
struct autofs_sb_info *sbi, int __user *arg) struct autofs_sb_info *sbi, int __user *arg)
{ {
int do_now = 0; unsigned int how = 0;
if (arg && get_user(do_now, arg)) if (arg && get_user(how, arg))
return -EFAULT; return -EFAULT;
return autofs_do_expire_multi(sb, mnt, sbi, do_now); return autofs_do_expire_multi(sb, mnt, sbi, how);
} }
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