Skip to content

Commit

Permalink
autofs: fix inconsistent use of now variable
Browse files Browse the repository at this point in the history
The global variable "now" in fs/autofs/expire.c is used in an inconsistent
way, sometimes using jiffies directly, and sometimes using the "now"
variable, and setting it isn't done consistently either.

But the autofs dentry info last_used field is only updated during path
walks or during expire so jiffies can be used directly and the global
variable "now" removed.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ian Kent <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
raven-au authored and torvalds committed Aug 22, 2018
1 parent d4d79b8 commit 2fd9944
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions fs/autofs/expire.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

#include "autofs_i.h"

static unsigned long now;

/* Check if a dentry can be expired */
static inline int autofs_can_expire(struct dentry *dentry,
unsigned long timeout, int do_now)
Expand All @@ -24,7 +22,7 @@ static inline int autofs_can_expire(struct dentry *dentry,

if (!do_now) {
/* Too young to die */
if (!timeout || time_after(ino->last_used + timeout, now))
if (!timeout || time_after(ino->last_used + timeout, jiffies))
return 0;
}
return 1;
Expand Down Expand Up @@ -307,7 +305,6 @@ struct dentry *autofs_expire_direct(struct super_block *sb,
if (!root)
return NULL;

now = jiffies;
timeout = sbi->exp_timeout;

if (!autofs_direct_busy(mnt, root, timeout, do_now)) {
Expand Down Expand Up @@ -442,7 +439,6 @@ struct dentry *autofs_expire_indirect(struct super_block *sb,
if (!root)
return NULL;

now = jiffies;
timeout = sbi->exp_timeout;

dentry = NULL;
Expand Down Expand Up @@ -575,7 +571,7 @@ int autofs_expire_run(struct super_block *sb,
spin_lock(&sbi->fs_lock);
ino = autofs_dentry_ino(dentry);
/* avoid rapid-fire expire attempts if expiry fails */
ino->last_used = now;
ino->last_used = jiffies;
ino->flags &= ~(AUTOFS_INF_EXPIRING|AUTOFS_INF_WANT_EXPIRE);
complete_all(&ino->expire_complete);
spin_unlock(&sbi->fs_lock);
Expand Down Expand Up @@ -605,7 +601,7 @@ int autofs_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,

spin_lock(&sbi->fs_lock);
/* avoid rapid-fire expire attempts if expiry fails */
ino->last_used = now;
ino->last_used = jiffies;
ino->flags &= ~(AUTOFS_INF_EXPIRING|AUTOFS_INF_WANT_EXPIRE);
complete_all(&ino->expire_complete);
spin_unlock(&sbi->fs_lock);
Expand Down

0 comments on commit 2fd9944

Please sign in to comment.