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

autofs: add strictexpire mount option

Commit 092a5345 ("autofs: take more care to not update last_used on
path walk") helped to (partially) resolve a problem where automounts
were not expiring due to aggressive accesses from user space.

This patch was later reverted because, for very large environments, it
meant more mount requests from clients and when there are a lot of
clients this caused a fairly significant increase in server load.

But there is a need for both types of expire check, depending on use
case, so add a mount option to allow for strict update of last use of
autofs dentrys (which just means not updating the last use on path walk
access).

Link: http://lkml.kernel.org/r/154296973880.9889.14085372741514507967.stgit@pluto-themaw-netSigned-off-by: default avatarIan Kent <raven@themaw.net>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9d8719a4
...@@ -104,6 +104,7 @@ struct autofs_wait_queue { ...@@ -104,6 +104,7 @@ struct autofs_wait_queue {
#define AUTOFS_SBI_MAGIC 0x6d4a556d #define AUTOFS_SBI_MAGIC 0x6d4a556d
#define AUTOFS_SBI_CATATONIC 0x0001 #define AUTOFS_SBI_CATATONIC 0x0001
#define AUTOFS_SBI_STRICTEXPIRE 0x0002
struct autofs_sb_info { struct autofs_sb_info {
u32 magic; u32 magic;
......
...@@ -87,6 +87,8 @@ static int autofs_show_options(struct seq_file *m, struct dentry *root) ...@@ -87,6 +87,8 @@ static int autofs_show_options(struct seq_file *m, struct dentry *root)
seq_printf(m, ",direct"); seq_printf(m, ",direct");
else else
seq_printf(m, ",indirect"); seq_printf(m, ",indirect");
if (sbi->flags & AUTOFS_SBI_STRICTEXPIRE)
seq_printf(m, ",strictexpire");
#ifdef CONFIG_CHECKPOINT_RESTORE #ifdef CONFIG_CHECKPOINT_RESTORE
if (sbi->pipe) if (sbi->pipe)
seq_printf(m, ",pipe_ino=%ld", file_inode(sbi->pipe)->i_ino); seq_printf(m, ",pipe_ino=%ld", file_inode(sbi->pipe)->i_ino);
...@@ -109,7 +111,7 @@ static const struct super_operations autofs_sops = { ...@@ -109,7 +111,7 @@ static const struct super_operations autofs_sops = {
}; };
enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto, enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto,
Opt_indirect, Opt_direct, Opt_offset}; Opt_indirect, Opt_direct, Opt_offset, Opt_strictexpire};
static const match_table_t tokens = { static const match_table_t tokens = {
{Opt_fd, "fd=%u"}, {Opt_fd, "fd=%u"},
...@@ -121,6 +123,7 @@ static const match_table_t tokens = { ...@@ -121,6 +123,7 @@ static const match_table_t tokens = {
{Opt_indirect, "indirect"}, {Opt_indirect, "indirect"},
{Opt_direct, "direct"}, {Opt_direct, "direct"},
{Opt_offset, "offset"}, {Opt_offset, "offset"},
{Opt_strictexpire, "strictexpire"},
{Opt_err, NULL} {Opt_err, NULL}
}; };
...@@ -200,6 +203,9 @@ static int parse_options(char *options, ...@@ -200,6 +203,9 @@ static int parse_options(char *options,
case Opt_offset: case Opt_offset:
set_autofs_type_offset(&sbi->type); set_autofs_type_offset(&sbi->type);
break; break;
case Opt_strictexpire:
sbi->flags |= AUTOFS_SBI_STRICTEXPIRE;
break;
default: default:
return 1; return 1;
} }
......
...@@ -275,8 +275,11 @@ static int autofs_mount_wait(const struct path *path, bool rcu_walk) ...@@ -275,8 +275,11 @@ static int autofs_mount_wait(const struct path *path, bool rcu_walk)
pr_debug("waiting for mount name=%pd\n", path->dentry); pr_debug("waiting for mount name=%pd\n", path->dentry);
status = autofs_wait(sbi, path, NFY_MOUNT); status = autofs_wait(sbi, path, NFY_MOUNT);
pr_debug("mount wait done status=%d\n", status); pr_debug("mount wait done status=%d\n", status);
ino->last_used = jiffies;
return status;
} }
ino->last_used = jiffies; if (!(sbi->flags & AUTOFS_SBI_STRICTEXPIRE))
ino->last_used = jiffies;
return status; return status;
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#define AUTOFS_MIN_PROTO_VERSION 3 #define AUTOFS_MIN_PROTO_VERSION 3
#define AUTOFS_MAX_PROTO_VERSION 5 #define AUTOFS_MAX_PROTO_VERSION 5
#define AUTOFS_PROTO_SUBVERSION 3 #define AUTOFS_PROTO_SUBVERSION 4
/* /*
* The wait_queue_token (autofs_wqt_t) is part of a structure which is passed * The wait_queue_token (autofs_wqt_t) is part of a structure which is passed
......
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