Skip to contentSkip to conversation

fyi ... current patch list

PATCH New Ian Kent 1 participant 35 messages Apr 24, 2017

Subsystems (2)
lore
Share & tools
lore

Ian Kent

author maintainer
#0 lore raw

cover fyi ... current patch list

Here is my current patch list.

If there are no concerns from anyone I expect to commit them to the repo. some time in the next few days.

Most notable change is the addition of browse support for amd format maps.

I'd like to get the amd browse changes into a release so hopefully that will follow not too long after the commit.

---

David Jeffery (1):
autofs-5.1.2 - honor last rw in mount options when doing a bind mount

Ian Kent (30):
autofs-5.1.2 - fix included master map not found return autofs-5.1.2 - dont exit on master map read fail timeout autofs-5.1.2 - set sane default master read wait timeout autofs-5.1.2 - don't return until after master map retry read autofs-5.1.2 - make lookup_nss_read_master() return nss status autofs-5.1.2 - check NFS server availability on local mount fallback autofs-5.1.2 - make set_direct_mount_catatonic() more general autofs-5.1.2 - set autofs mounts catatonic at exit autofs-5.1.2 - fix typos in README.amd-maps
autofs-5.1.2 - add ref counting to struct map_source autofs-5.1.2 - add support for amd browsable option autofs-5.1.2 - add function conf_amd_get_map_name() autofs-5.1.2 - add function conf_amd_get_mount_paths() autofs-5.1.2 - include amd mount section mounts in master mounts list autofs-5.1.2 - check for conflicting amd section mounts autofs-5.1.2 - add function conf_amd_get_map_options() autofs-5.1.2 - capture cache option and its settings during parsing autofs-5.1.2 - handle map_option cache for top level mounts autofs-5.1.2 - handle amd cache option all in amd type auto mounts autofs-5.1.2 - fix bogus check in expire_cleanup() autofs-5.1.2 - delay submount exit for amd submounts autofs-5.1.2 - factor out set_thread_mount_request_log_id() autofs-5.1.2 - add config option to use mount request log id autofs-5.1.2 - use autofs_point to store expire timeout where possibe autofs-5.1.2 - fix possible NULL derefernce
autofs-5.1.2 - fix work around sss startup delay autofs-5.1.2 - fix invalid reference in remount_active_mount() autofs-5.1.2 - use malloc for expanded map location autofs-5.1.2 - fix offset mount location multiple expansion autofs-5.1.2 - increase worker thread per-thread stack size

Lars R. Damerow (3):
autofs-5.1.2 - add the mount requestor's pid to pending_args autofs-5.1.2 - create thread-local ID for mount attempts autofs-5.1.2 - log functions to prefix messages with attempt_id if available

 CHANGELOG                      |   34 +++++++
 README.amd-maps                |   64 ++++++++++---
 daemon/automount.c             |   89 +++++++++++++-----
 daemon/direct.c                |   85 ++---------------
 daemon/indirect.c              |   15 ++-
 daemon/lookup.c                |  126 ++++++++++++++++++++-----
 daemon/state.c                 |   34 +++++--
 include/automount.h            |   12 ++
 include/defaults.h             |    7 +
 include/master.h               |    4 +
 include/mounts.h               |    4 +
 include/parse_amd.h            |    7 +
 lib/defaults.c                 |  121 ++++++++++++++++++++++++
 lib/log.c                      |  164 +++++++++++++++++++++++++++-----
 lib/master.c                   |  202 ++++++++++++++++++++++++++++++++++++++++
 lib/master_parse.y             |   55 ++++++++---
 lib/mounts.c                   |  160 ++++++++++++++++++++++++++++++--
 lib/rpc_subs.c                 |   11 ++
 man/autofs.conf.5.in           |   25 ++++-
 modules/amd_parse.y            |   15 ++-
 modules/amd_tok.l              |    2 
 modules/lookup_dir.c           |    2 
 modules/lookup_file.c          |   20 +++-
 modules/lookup_ldap.c          |   10 +-
 modules/lookup_nisplus.c       |   10 +-
 modules/lookup_sss.c           |   18 ++--
 modules/lookup_yp.c            |   10 +-
 modules/mount_autofs.c         |   79 ++++++++++------
 modules/mount_nfs.c            |   17 +++
 modules/parse_amd.c            |    2 
 modules/parse_sun.c            |   90 +++++++++++++++---
 redhat/autofs.conf.default.in  |   20 +++-
 samples/autofs.conf.default.in |   20 +++-
 33 files changed, 1236 insertions(+), 298 deletions(-)

--
Ian
--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#1 lore raw

PATCH 1/34 autofs-5.1.2 - fix included master map not found return

When retrying the master map read at startup a not found return is needed when there is no map rather than an unknown or unavailable for the retry logic to work.

---
 CHANGELOG             |    1 +
 daemon/lookup.c       |    6 ++++--
 modules/lookup_file.c |   18 ++++++++++++------
 3 files changed, 17 insertions(+), 8 deletions(-)
CHANGELOG +1 -0
index 38c4a2a..5822aeb 100644
@@ -27,6 +27,7 @@ xx/xx/2016 autofs-5.1.3
 - work around sss startup delay.
 - add sss master map wait config option.
 - fix quoted key handling in sanitize_path().
+- fix included master map not found return.
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/lookup.c +4 -2
index 0c2a01f..a46740e 100644
@@ -241,7 +241,7 @@ int lookup_nss_read_master(struct master *master, time_t age)
 	}
 
 	/* First one gets it */
-	result = NSS_STATUS_UNKNOWN;
+	result = NSS_STATUS_SUCCESS;
 	head = &nsslist;
 	list_for_each(p, head) {
 		struct nss_source *this;
@@ -282,8 +282,10 @@ int lookup_nss_read_master(struct master *master, time_t age)
 			}
 		}
 
-		if (result == NSS_STATUS_UNKNOWN) {
+		if (result == NSS_STATUS_UNKNOWN ||
+		    result == NSS_STATUS_NOTFOUND) {
 			debug(logopt, "no map - continuing to next source");
+			result = NSS_STATUS_SUCCESS;
 			continue;
 		}
 
modules/lookup_file.c +12 -6
index d5f8c9e..cb00ee5 100644
@@ -464,6 +464,8 @@ int lookup_read_master(struct master *master, time_t age, void *context)
 
 	f = open_fopen_r(ctxt->mapname);
 	if (!f) {
+		if (errno == ENOENT)
+			return NSS_STATUS_NOTFOUND;
 		error(logopt,
 		      MODPREFIX "could not open master map file %s",
 		      ctxt->mapname);
@@ -507,12 +509,14 @@ int lookup_read_master(struct master *master, time_t age, void *context)
 				     MODPREFIX
 				     "failed to read included master map %s",
 				     master->name);
-				/*
-				 * If we're starting up wee need the whole
-				 * master map initially, so tell the upper
-				 * layer to retry.
-				 */
-				master->read_fail = 1;
+				if (status != NSS_STATUS_NOTFOUND) {
+					/*
+					 * If we're starting up wee need the whole
+					 * master map initially, so tell the upper
+					 * layer to retry.
+					 */
+					master->read_fail = 1;
+				}
 			}
 			master->depth--;
 			master->recurse = 0;
@@ -713,6 +717,8 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
 
 	f = open_fopen_r(ctxt->mapname);
 	if (!f) {
+		if (errno == ENOENT)
+			return NSS_STATUS_NOTFOUND;
 		error(ap->logopt,
 		      MODPREFIX "could not open map file %s", ctxt->mapname);
 		return NSS_STATUS_UNAVAIL;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#2 lore raw

PATCH 2/34 autofs-5.1.2 - dont exit on master map read fail timeout

In reply to Ian Kent

If there is a persistent master map read failure autofs should continue on after the configured retry wait, as it would have done previously.

---
 CHANGELOG          |    1 +
 daemon/automount.c |   12 ++++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)
CHANGELOG +1 -0
index 5822aeb..85b1480 100644
@@ -28,6 +28,7 @@ xx/xx/2016 autofs-5.1.3
 - add sss master map wait config option.
 - fix quoted key handling in sanitize_path().
 - fix included master map not found return.
+- dont exit on master map read fail timeout.
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/automount.c +8 -4
index 72c980e..95b8969 100644
@@ -2533,10 +2533,14 @@ int main(int argc, char *argv[])
 		 * error.
 		 */
 		if (!do_master_read_master(master_list, master_wait)) {
-			logerr("%s: failed to read master map!", program);
-			master_kill(master_list);
-			release_flag_file();
-			exit(3);
+			logmsg("%s: warning: could not read at least one "
+				"map source after waiting, continuing ...",
+				 program);
+			/*
+			 * Failed to read master map, continue with what
+			 * we have anyway.
+			 */
+			master_read_master(master_list, age, 1);
 		}
 	}
 

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#3 lore raw

PATCH 3/34 autofs-5.1.2 - set sane default master read wait timeout

In reply to Ian Kent

If an unused map source is configured in nss, with the default of waiting indefinitely, autofs will not start.

To restore the previous behaviour of this case set a sensible default timeout for the configuration option master_wait.

---
 CHANGELOG                      |    1 +
 include/defaults.h             |    2 +-
 man/autofs.conf.5.in           |    4 ++--
 redhat/autofs.conf.default.in  |    6 +++---
 samples/autofs.conf.default.in |    6 +++---
 5 files changed, 10 insertions(+), 9 deletions(-)
CHANGELOG +1 -0
index 85b1480..92a6ea9 100644
@@ -29,6 +29,7 @@ xx/xx/2016 autofs-5.1.3
 - fix quoted key handling in sanitize_path().
 - fix included master map not found return.
 - dont exit on master map read fail timeout.
+- set sane default master read wait timeout.
 
 15/06/2016 autofs-5.1.2
 =======================
include/defaults.h +1 -1
index 1dea48c..b93fda3 100644
@@ -25,7 +25,7 @@
 #define DEFAULT_MASTER_MAP_NAME	"auto.master"
 
 #define DEFAULT_TIMEOUT			"600"
-#define DEFAULT_MASTER_WAIT		"-1"
+#define DEFAULT_MASTER_WAIT		"10"
 #define DEFAULT_NEGATIVE_TIMEOUT	"60"
 #define DEFAULT_MOUNT_WAIT		"-1"
 #define DEFAULT_UMOUNT_WAIT		"12"
man/autofs.conf.5.in +2 -2
index 93ff7af..a9a08f9 100644
@@ -32,8 +32,8 @@ with earlier autofs releases.
 .TP
 .B master_wait
 sets the default maximum time to wait for the master map to become
-available if it cannot be read at program start (program default -1,
-wait forever).
+available if it cannot be read at program start (program default 10,
+wait for 10 seconds then continue).
 .TP
 .B negative_timeout
 .br
redhat/autofs.conf.default.in +3 -3
index 9bceab3..c7e4d97 100644
@@ -16,10 +16,10 @@ timeout = 300
 #
 # master_wait - set the default maximum time to wait for the
 # 		master map to become available if it cannot
-# 		be read at program start (default -1, wait
-# 		forever).
+# 		be read at program start (default 10, wait
+# 		for 10 seconds then continue).
 #
-#master_wait = -1
+#master_wait = 10
 #
 # negative_timeout - set the default negative timeout for
 # 		     failed mount attempts (default 60).
samples/autofs.conf.default.in +3 -3
index a275e08..d52ad85 100644
@@ -16,10 +16,10 @@ timeout = 300
 #
 # master_wait - set the default maximum time to wait for the
 # 		master map to become available if it cannot
-# 		be read at program start (default -1, wait
-# 		forever).
+# 		be read at program start (default 10, wait
+# 		for 10 seconds then continue).
 #
-# master_wait = -1
+# master_wait = 10
 #
 # negative_timeout - set the default negative timeout for
 # 		     failed mount attempts (default 60).

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#4 lore raw

PATCH 4/34 autofs-5.1.2 - don't return until after master map retry read

In reply to Ian Kent

The master map read retry needs to be done before returning success at startup or there can be problems trying to access automount mounts before they are mounted.

---
 CHANGELOG          |    1 +
 daemon/automount.c |   31 ++++++++++---------------------
 2 files changed, 11 insertions(+), 21 deletions(-)
CHANGELOG +1 -0
index 92a6ea9..7337ec6 100644
@@ -30,6 +30,7 @@ xx/xx/2016 autofs-5.1.3
 - fix included master map not found return.
 - dont exit on master map read fail timeout.
 - set sane default master read wait timeout.
+- don't return until after master map retry read.
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/automount.c +10 -21
index 95b8969..15dadb5 100644
@@ -2506,27 +2506,6 @@ int main(int argc, char *argv[])
 
 	master_read = master_read_master(master_list, age, 0);
 	if (!master_read) {
-		if (foreground)
-			logerr("%s: failed to read master map, "
-			       "will retry!",
-			       program);
-		else
-			logerr("%s: failed to read master map, "
-			       "will retry in background!",
-			       program);
-	}
-
-	/*
-	 * Mmm ... reset force unlink umount so we don't also do this
-	 * in future when we receive a HUP signal.
-	 */
-	do_force_unlink = 0;
-
-	st_stat = 0;
-	res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
-	close(start_pipefd[1]);
-
-	if (!master_read) {
 		/*
 		 * Read master map, waiting until it is available, unless
 		 * a signal is received, in which case exit returning an
@@ -2544,6 +2523,16 @@ int main(int argc, char *argv[])
 		}
 	}
 
+	/*
+	 * Mmm ... reset force unlink umount so we don't also do this
+	 * in future when we receive a HUP signal.
+	 */
+	do_force_unlink = 0;
+
+	st_stat = 0;
+	res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
+	close(start_pipefd[1]);
+
 	state_mach_thid = pthread_self();
 	statemachine(NULL);
 

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#5 lore raw

PATCH 5/34 autofs-5.1.2 - make lookup_nss_read_master() return nss status

In reply to Ian Kent

Currently lookup_nss_read_master() uses a boolean return but in order for the master map retry read to function properly when trying to read plus included maps it needs to return an NSS status instead.

---
 CHANGELOG             |    1 +
 daemon/lookup.c       |   14 ++++++++++----
 modules/lookup_dir.c  |    2 +-
 modules/lookup_file.c |    2 +-
 4 files changed, 13 insertions(+), 6 deletions(-)
CHANGELOG +1 -0
index 7337ec6..408edf8 100644
@@ -31,6 +31,7 @@ xx/xx/2016 autofs-5.1.3
 - dont exit on master map read fail timeout.
 - set sane default master read wait timeout.
 - don't return until after master map retry read.
+- make lookup_nss_read_master() return nss status.
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/lookup.c +10 -4
index a46740e..5ff837d 100644
@@ -175,7 +175,7 @@ int lookup_nss_read_master(struct master *master, time_t age)
 		if (result == NSS_STATUS_UNAVAIL)
 			master->read_fail = 1;
 
-		return !result;
+		return result;
 	} else {
 		char *name = master->name;
 		char *tmp;
@@ -225,7 +225,7 @@ int lookup_nss_read_master(struct master *master, time_t age)
 				if (result == NSS_STATUS_UNAVAIL)
 					master->read_fail = 1;
 
-				return !result;
+				return result;
 			}
 		}
 	}
@@ -237,7 +237,7 @@ int lookup_nss_read_master(struct master *master, time_t age)
 		if (!list_empty(&nsslist))
 			free_sources(&nsslist);
 		error(logopt, "can't to read name service switch config.");
-		return 0;
+		return NSS_STATUS_UNAVAIL;
 	}
 
 	/* First one gets it */
@@ -282,6 +282,12 @@ int lookup_nss_read_master(struct master *master, time_t age)
 			}
 		}
 
+		/* We've been instructed to move onto the next source */
+		if (result == NSS_STATUS_TRYAGAIN) {
+			result = NSS_STATUS_SUCCESS;
+			continue;
+		}
+
 		if (result == NSS_STATUS_UNKNOWN ||
 		    result == NSS_STATUS_NOTFOUND) {
 			debug(logopt, "no map - continuing to next source");
@@ -302,7 +308,7 @@ int lookup_nss_read_master(struct master *master, time_t age)
 	if (!list_empty(&nsslist))
 		free_sources(&nsslist);
 
-	return !result;
+	return result;
 }
 
 static int do_read_map(struct autofs_point *ap, struct map_source *map, time_t age)
modules/lookup_dir.c +1 -1
index 2880447..ab1d82f 100644
@@ -174,7 +174,7 @@ static int include_file(struct master *master, time_t age, struct lookup_context
 	master->depth++;
 	debug(logopt, MODPREFIX "include: %s", master->name);
 	status = lookup_nss_read_master(master, age);
-	if (!status) {
+	if (status != NSS_STATUS_SUCCESS) {
 		warn(logopt,
 		     MODPREFIX
 		     "failed to read included master map %s",
modules/lookup_file.c +1 -1
index cb00ee5..36247c5 100644
@@ -504,7 +504,7 @@ int lookup_read_master(struct master *master, time_t age, void *context)
 				master->recurse = 1;
 			master->depth++;
 			status = lookup_nss_read_master(master, age);
-			if (!status) {
+			if (status != NSS_STATUS_SUCCESS) {
 				warn(logopt,
 				     MODPREFIX
 				     "failed to read included master map %s",

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#6 lore raw

PATCH 6/34 autofs-5.1.2 - check NFS server availability on local mount fallback

In reply to Ian Kent

The availability probe isn't done for anything autofs thinks is a local mount because it's the local machine.

It first tries a bind mount and if that fails it falls back to trying a local NFS mount. If the local NFS server is not running mount.nfs(8) can suffer a lengthy timeout.

So check for the bind mount fallback case and check if an NFS server is responding before trying the mount.

---
 CHANGELOG           |    1 +
 lib/rpc_subs.c      |   11 +++++++++++
 modules/mount_nfs.c |   15 ++++++++++++++-
 3 files changed, 26 insertions(+), 1 deletion(-)
CHANGELOG +1 -0
index 408edf8..c43ebc9 100644
@@ -32,6 +32,7 @@ xx/xx/2016 autofs-5.1.3
 - set sane default master read wait timeout.
 - don't return until after master map retry read.
 - make lookup_nss_read_master() return nss status.
+- check NFS server availability on local mount fallback.
 
 15/06/2016 autofs-5.1.2
 =======================
lib/rpc_subs.c +11 -0
index d0d4cf5..386c7ba 100644
@@ -1039,6 +1039,7 @@ static int __rpc_ping(const char *host,
 
 int rpc_ping(const char *host, long seconds, long micros, unsigned int option)
 {
+	unsigned long vers4 = NFS4_VERSION;
 	unsigned long vers3 = NFS3_VERSION;
 	unsigned long vers2 = NFS2_VERSION;
 	int status;
@@ -1051,6 +1052,12 @@ int rpc_ping(const char *host, long seconds, long micros, unsigned int option)
 	if (status > 0)
 		return RPC_PING_V3 | RPC_PING_UDP;
 
+	/* UDP isn't recommended for NFSv4, don't bother checking it.
+	status = __rpc_ping(host, vers4, IPPROTO_UDP, seconds, micros, option);
+	if (status > 0)
+		return RPC_PING_V4 | RPC_PING_UDP;
+	*/
+
 	status = __rpc_ping(host, vers2, IPPROTO_TCP, seconds, micros, option);
 	if (status > 0)
 		return RPC_PING_V2 | RPC_PING_TCP;
@@ -1059,6 +1066,10 @@ int rpc_ping(const char *host, long seconds, long micros, unsigned int option)
 	if (status > 0)
 		return RPC_PING_V3 | RPC_PING_TCP;
 
+	status = __rpc_ping(host, vers4, IPPROTO_TCP, seconds, micros, option);
+	if (status > 0)
+		return RPC_PING_V4 | RPC_PING_TCP;
+
 	return status;
 }
 
modules/mount_nfs.c +14 -1
index 0af814b..2712140 100644
@@ -348,6 +348,19 @@ dont_probe:
 		strcat(loc, ":");
 		strcat(loc, this->path);
 
+		/* If this is a fallback from a bind mount failure
+		 * check if the local NFS server is available to try
+		 * and prevent lengthy mount failure waits.
+		 */
+		if (this->proximity == PROXIMITY_LOCAL) {
+			char *host = this->name ? this->name : "localhost";
+			int ret;
+
+			ret = rpc_ping(host, 2, 0, RPC_CLOSE_DEFAULT);
+			if (ret <= 0)
+				goto next;
+		}
+
 		if (nfsoptions && *nfsoptions) {
 			debug(ap->logopt,
 			      MODPREFIX "calling mount -t %s " SLOPPY 
@@ -370,7 +383,7 @@ dont_probe:
 			free_host_list(&hosts);
 			return 0;
 		}
-
+next:
 		free(loc);
 		this = this->next;
 	}

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#7 lore raw

PATCH 7/34 autofs-5.1.2 - make set_direct_mount_catatonic() more general

In reply to Ian Kent

Setting direct mounts catatonic at exit doesn't go far enough.

To avoid possible hang on access of automount managed paths when the daemon has exited all mounted autofs file systems must be set catatonic when the daemon exits.

Start by making set_direct_mount_catatonic() able to handle the different types of autofs mounts and move it to the mounts function library.

---
 CHANGELOG        |    1 +
 daemon/direct.c  |   69 ++++--------------------------------------------------
 include/mounts.h |    1 +
 lib/mounts.c     |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 71 insertions(+), 64 deletions(-)
CHANGELOG +1 -0
index c43ebc9..8b7de5f 100644
@@ -33,6 +33,7 @@ xx/xx/2016 autofs-5.1.3
 - don't return until after master map retry read.
 - make lookup_nss_read_master() return nss status.
 - check NFS server availability on local mount fallback.
+- make set_direct_mount_catatonic() more general.
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/direct.c +5 -64

101 lines not on this page · raw message

include/mounts.h +1 -0
index 489025c..9ec6bd9 100644
@@ -113,6 +113,7 @@ void set_tsd_user_vars(unsigned int, uid_t, gid_t);
 const char *mount_type_str(unsigned int);
 void notify_mount_result(struct autofs_point *, const char *, time_t, const char *);
 int try_remount(struct autofs_point *, struct mapent *, unsigned int);
+int set_mount_catatonic(struct autofs_point *, struct mapent *, int);
 int umount_ent(struct autofs_point *, const char *);
 int mount_multi_triggers(struct autofs_point *, struct mapent *, const char *, unsigned int, const char *);
 int umount_multi_triggers(struct autofs_point *, struct mapent *, char *, const char *);
lib/mounts.c +64 -0

70 lines not on this page · raw message

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#8 lore raw

PATCH 8/34 autofs-5.1.2 - set autofs mounts catatonic at exit

In reply to Ian Kent

Setting direct mounts catatonic at exit doesn't go far enough.

To avoid possible hang on access of automount managed paths when the daemon has exited all mounted autofs file systems must be set catatonic when the daemon exits.

---
 CHANGELOG          |    1 +
 daemon/automount.c |    1 +
 daemon/direct.c    |   17 +++++--------
 daemon/indirect.c  |    3 --
 include/mounts.h   |    3 ++
 lib/mounts.c       |   69 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 6 files changed, 78 insertions(+), 16 deletions(-)
CHANGELOG +1 -0
index 8b7de5f..8eedad3 100644
@@ -34,6 +34,7 @@ xx/xx/2016 autofs-5.1.3
 - make lookup_nss_read_master() return nss status.
 - check NFS server availability on local mount fallback.
 - make set_direct_mount_catatonic() more general.
+- set autofs mounts catatonic at exit.
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/automount.c +1 -0
index 15dadb5..6ebe885 100644
@@ -1756,6 +1756,7 @@ int handle_mounts_exit(struct autofs_point *ap)
 	 */
 	ret = umount_autofs(ap, NULL, 1);
 	if (!ret) {
+		set_indirect_mount_tree_catatonic(ap);
 		handle_mounts_cleanup(ap);
 		return 1;
 	}
daemon/direct.c +6 -11
index 81f6e67..7a8d309 100644
@@ -130,20 +130,16 @@ int do_umount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, stru
 				error(ap->logopt,
 				      "ask umount returned busy for %s",
 				      me->key);
-				if (ap->state != ST_READMAP)
-					set_mount_catatonic(ap, me, ioctlfd);
 				if (opened)
 					ops->close(ap->logopt, ioctlfd);
 				return 1;
 			} else {
 				me->ioctlfd = -1;
-				set_mount_catatonic(ap, me, ioctlfd);
 				ops->close(ap->logopt, ioctlfd);
 				goto force_umount;
 			}
 		}
 		me->ioctlfd = -1;
-		set_mount_catatonic(ap, me, ioctlfd);
 		ops->close(ap->logopt, ioctlfd);
 	} else {
 		error(ap->logopt,
@@ -173,8 +169,11 @@ int do_umount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, stru
 			warn(ap->logopt, "mount point %s is in use", me->key);
 			if (ap->state == ST_SHUTDOWN_FORCE)
 				goto force_umount;
-			else
+			else {
+				if (ap->state != ST_READMAP)
+					set_direct_mount_tree_catatonic(ap, me);
 				return 0;
+			}
 			break;
 		case ENOTDIR:
 			error(ap->logopt, "mount point is not a directory");
@@ -238,12 +237,8 @@ int umount_autofs_direct(struct autofs_point *ap)
 			if (!error)
 				goto done;
 
-			error = set_mount_catatonic(ap, me, me->ioctlfd);
-			if (!error)
-				goto done;
-
-			/* We really need to set this, last ditch attempt */
-			set_mount_catatonic(ap, me, -1);
+			if (ap->state != ST_READMAP)
+				set_direct_mount_tree_catatonic(ap, me);
 done:
 			me = cache_enumerate(mc, me);
 		}
daemon/indirect.c +0 -3
index 4c32bdb..8171fb0 100644
@@ -290,9 +290,6 @@ int umount_autofs_indirect(struct autofs_point *ap, const char *root)
 #endif
 	}
 
-	if (ap->shutdown)
-		ops->catatonic(ap->logopt, ap->ioctlfd);
-
 	ops->close(ap->logopt, ap->ioctlfd);
 	ap->ioctlfd = -1;
 	sched_yield();
include/mounts.h +2 -1
index 9ec6bd9..8425818 100644
@@ -113,7 +113,8 @@ void set_tsd_user_vars(unsigned int, uid_t, gid_t);
 const char *mount_type_str(unsigned int);
 void notify_mount_result(struct autofs_point *, const char *, time_t, const char *);
 int try_remount(struct autofs_point *, struct mapent *, unsigned int);
-int set_mount_catatonic(struct autofs_point *, struct mapent *, int);
+void set_indirect_mount_tree_catatonic(struct autofs_point *);
+void set_direct_mount_tree_catatonic(struct autofs_point *, struct mapent *);
 int umount_ent(struct autofs_point *, const char *);
 int mount_multi_triggers(struct autofs_point *, struct mapent *, const char *, unsigned int, const char *);
 int umount_multi_triggers(struct autofs_point *, struct mapent *, char *, const char *);
lib/mounts.c +68 -1

87 lines not on this page · raw message

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#9 lore raw

PATCH 9/34 autofs-5.1.2 - honor last rw in mount options when doing a bind mount

In reply to Ian Kent

From: David Jeffery <[email protected]>

mount(8) will use the last ro/rw option in its options list. e.g. "mount -o ro,rw" will make a read-write mount while "mount -o rw,ro" will make a read-only mount.

The patch changes the option parsing for mount_mount() in modules/mount_nfs.c to clear the ro variable when a "rw" option is seen. This will handle occurrences of both "ro" and "rw" options, resulting in a read-only option being passed to a bind mount only if the option order would also have resulted in an nfs mount being read-only.

---
 CHANGELOG           |    1 +
 modules/mount_nfs.c |    2 ++
 2 files changed, 3 insertions(+)
CHANGELOG +1 -0
index 8eedad3..f841eaa 100644
@@ -35,6 +35,7 @@ xx/xx/2016 autofs-5.1.3
 - check NFS server availability on local mount fallback.
 - make set_direct_mount_catatonic() more general.
 - set autofs mounts catatonic at exit.
+- honor last rw in mount options when doing a bind mount.
 
 15/06/2016 autofs-5.1.2
 =======================
modules/mount_nfs.c +2 -0
index 2712140..c558a73 100644
@@ -180,6 +180,8 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
 				   with bind mounts */
 				else if (_strncmp("ro", cp, o_len) == 0)
 					ro = 1;
+				else if (_strncmp("rw", cp, o_len) == 0)
+					ro = 0;
 				/* and jump over trailing white space */
 				memcpy(nfsp, cp, comma - cp + 1);
 				nfsp += comma - cp + 1;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#10 lore raw

PATCH 10/34 autofs-5.1.2 - fix typos in README.amd-maps

In reply to Ian Kent

Fix a few typos and try and clearify some statements in the README.

---
 CHANGELOG       |    1 +
 README.amd-maps |   15 ++++++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)
CHANGELOG +1 -0
index f841eaa..c347fcb 100644
@@ -36,6 +36,7 @@ xx/xx/2016 autofs-5.1.3
 - make set_direct_mount_catatonic() more general.
 - set autofs mounts catatonic at exit.
 - honor last rw in mount options when doing a bind mount.
+- fix typos in README.amd-maps.
 
 15/06/2016 autofs-5.1.2
 =======================
README.amd-maps +8 -7
index b31a7db..e79f521 100644
@@ -7,7 +7,8 @@ The ability to parse amd format maps has been added to autofs.
 How to use amd maps in autofs
 -----------------------------
 
-To add amd map parsing to autofs new "format" module has been added.
+To add amd map parsing to autofs a new "format" module has been added.
+
 To use this new map format module the existing master map syntax is
 used as described below.
 
@@ -20,7 +21,7 @@ For amd format maps this becomes:
 /amd/mp   file,amd:amd.mp
 
 which will use file as the map source and the amd format parser for
-the map. But see the section below on configuration below for how to
+the map. But see the section below on configuration for how to
 eliminate the need to specify "map-type,format" in the master map.
 
 Configuration sub-system changes
@@ -42,18 +43,18 @@ All that's needed to add an existing amd configuration to autofs is to
 add it below the autofs configuration. Apart from changing the amd
 "[ global ]" section name to "[ amd ]" nothing else should need to be
 changed. However, quite a few amd configuration options don't have
-meaning within autofs. When these options are seen it should be logged.
+meaning within autofs. When these options are seen they are logged.
 
 Be aware that, if the an old configuration exists and the configuration
 hasn't been updated after the installation, changes to the the old
 configuration will override changes to the new configuration because
 backward compatibility takes priority over the new implementation.
 
-The amd per-map sections have two functions, to allow per-mount
+The amd per-mount sections have two functions, to allow per-mount
 configuration, as it does in amd, and to allow master map entries to
 avoid the need to specify the "type,format" part of the master map
-entry so they can use the nsswitch map source functionality in the
-same way autofs master map entries do.
+entry. This allows them to use the nsswitch map source functionality
+in the same way autofs master map entries do.
 
 If a section for an amd mount is added below the global amd section
 using the mount point path (as is done in amd.conf) then autofs will
@@ -63,7 +64,7 @@ be given in the master map entry the map_name option is not mandatory
 as it is in amd and will no be used.
 
 If a mount point is present in the master map and the source of the
-map is nis then it should be sufficient to use (for example):
+map is nis then it is sufficient to use (for example):
 
 /amd/mp           amd.mp
 

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#11 lore raw

PATCH 11/34 autofs-5.1.2 - add ref counting to struct map_source

In reply to Ian Kent

amd map format maps that are type "auto" frequently refer to the current map in their map entries.

While this isn't a problem for relatively small maps it can be very wasteful for large maps and even more so for maps that have multi- component keys that trigger type "auto" mounts as they progress down the directory tree.

So add a reference count in order for amd type "auto" mounts to use the parent map if it matches.

sun format maps are much less likley to use the same map and if they do they are usually trivial, one line maps, so it isn't a problem.

But, more importantly, sun format maps need to track recursive inclusion and inclusion depth for a given map source when plus map inclusion is used which prevents the map soucre from being shared.

---
 CHANGELOG              |    1 +
 daemon/indirect.c      |    7 +++++-
 include/master.h       |    3 ++
 lib/master.c           |   22 +++++++++++++++++
 modules/mount_autofs.c |   61 ++++++++++++++++++++++++++++++++----------------
 5 files changed, 73 insertions(+), 21 deletions(-)
CHANGELOG +1 -0
index c347fcb..fb6243b 100644
@@ -37,6 +37,7 @@ xx/xx/2016 autofs-5.1.3
 - set autofs mounts catatonic at exit.
 - honor last rw in mount options when doing a bind mount.
 - fix typos in README.amd-maps.
+- add ref counting to struct map_source.
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/indirect.c +6 -1
index 8171fb0..72a23c3 100644
@@ -97,7 +97,12 @@ static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root)
 	int ret;
 	int err;
 
-	ap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
+	/* If the map is being shared the exp_timeout can't be inherited
+	 * from the map source since it may be different so the autofs
+	 * point exp_runfreq must have already been set.
+	 */
+	if (ap->entry->maps->ref <= 1)
+		ap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
 
 	if (ops->version && !do_force_unlink) {
 		ap->flags |= MOUNT_FLAG_REMOUNT;
include/master.h +3 -0
index 3f97acd..3947cd5 100644
@@ -23,6 +23,7 @@
 #define MAP_FLAG_FORMAT_AMD	0x0001
 
 struct map_source {
+	unsigned int ref;
 	unsigned int flags;
 	char *type;
 	char *format;
@@ -89,6 +90,8 @@ struct map_source *
 master_add_map_source(struct master_mapent *, char *, char *, time_t, int, const char **);
 struct map_source *
 master_find_map_source(struct master_mapent *, const char *, const char *, int, const char **);
+struct map_source *
+master_get_map_source(struct master_mapent *, const char *, const char *, int, const char **);
 void master_free_map_source(struct map_source *, unsigned int);
 struct map_source *
 master_find_source_instance(struct map_source *, const char *, const char *, int, const char **);
lib/master.c +22 -0
index 4c6e79b..fceb5dd 100644
@@ -181,6 +181,7 @@ master_add_map_source(struct master_mapent *entry,
 	if (!source)
 		return NULL;
 	memset(source, 0, sizeof(struct map_source));
+	source->ref = 1;
 
 	if (type) {
 		ntype = strdup(type);
@@ -232,6 +233,8 @@ master_add_map_source(struct master_mapent *entry,
 
 		this = __master_find_map_source(entry, type, format, argc, tmpargv);
 		if (this) {
+			error(entry->ap->logopt,
+			      "map source used without taking reference");
 			this->age = age;
 			master_free_map_source(source, 0);
 			master_source_unlock(entry);
@@ -330,8 +333,27 @@ struct map_source *master_find_map_source(struct master_mapent *entry,
 	return source;
 }
 
+struct map_source *
+master_get_map_source(struct master_mapent *entry,
+		      const char *type, const char *format,
+		      int argc, const char **argv)
+{
+	struct map_source *source = NULL;
+
+	master_source_readlock(entry);
+	source = __master_find_map_source(entry, type, format, argc, argv);
+	if (source)
+		source->ref++;
+	master_source_unlock(entry);
+
+	return source;
+}
+
 static void __master_free_map_source(struct map_source *source, unsigned int free_cache)
 {
+	/* instance map sources are not ref counted */
+	if (source->ref && --source->ref)
+		return;
 	if (source->type)
 		free(source->type);
 	if (source->format)
modules/mount_autofs.c +41 -20

89 lines not on this page · raw message

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#12 lore raw

PATCH 12/34 autofs-5.1.2 - add support for amd browsable option

In reply to Ian Kent

From: Ian Kent <[email protected]>

Add support for the "browsable_dirs" configuration option and the pseudo mount option "browsable" of amd format maps.

Note that support for the configuration option "browsable_dirs = full" and the pseudo mount option "fullybrowsable" of type auto map entries cannot be implemented using the existing kernel to user space autofs implementation.

---
 CHANGELOG                      |    1 
 README.amd-maps                |    2 -
 daemon/lookup.c                |  106 ++++++++++++++++++++++++++++++++--------
 lib/master_parse.y             |   14 ++++-
 man/autofs.conf.5.in           |    7 ++-
 modules/amd_parse.y            |    3 -
 modules/mount_autofs.c         |    8 ++-
 modules/parse_amd.c            |    2 -
 redhat/autofs.conf.default.in  |    7 ++-
 samples/autofs.conf.default.in |    7 ++-
 10 files changed, 120 insertions(+), 37 deletions(-)
CHANGELOG +1 -0
index fb6243b..b67fd56 100644
@@ -38,6 +38,7 @@ xx/xx/2016 autofs-5.1.3
 - honor last rw in mount options when doing a bind mount.
 - fix typos in README.amd-maps.
 - add ref counting to struct map_source.
+- add support for amd browsable option.
 
 15/06/2016 autofs-5.1.2
 =======================
README.amd-maps +1 -1
index e79f521..4f1d58d 100644
@@ -101,7 +101,7 @@ What hasn't been implemented
 ----------------------------
 
 The configuration options fully_qualified_hosts, unmount_on_exit and
-browsable_dirs (and a couple of others) aren't implemented.
+browsable_dirs = full (and a couple of others) aren't implemented.
 
 Map types (sources) ndbm, passwd are not implemented.
 The map source "sss" can't be used for amd format maps.
daemon/lookup.c +85 -21

160 lines not on this page · raw message

lib/master_parse.y +11 -3
index 0011429..7536324 100644
@@ -811,14 +811,22 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
 
 	if (format && !strcmp(format, "amd")) {
 		unsigned int loglevel = conf_amd_get_log_options();
+		unsigned int flags = conf_amd_get_flags(path);
+
 		if (loglevel <= LOG_DEBUG && loglevel > LOG_INFO)
 			logopt = LOGOPT_DEBUG;
 		else if (loglevel <= LOG_INFO && loglevel > LOG_ERR)
 			logopt = LOGOPT_VERBOSE;
-		/* amd mounts don't support browse mode */
-		ghost = 0;
-	}
 
+		/* It isn't possible to provide the fullybrowsable amd
+		 * browsing functionality within the autofs framework.
+		 * This flag will not be set if browsable_dirs = full
+		 * in the configuration or fullybrowsable is present as
+		 * an option.
+		 */
+		if (flags & CONF_BROWSABLE_DIRS)
+			ghost = 1;
+	}
 
 	if (timeout < 0) {
 		/*
man/autofs.conf.5.in +6 -1
index a9a08f9..a9ed1c3 100644
@@ -355,7 +355,12 @@ and that will be done.
 .TP
 .B browsable_dirs
 .br
-Not yet implemented.
+Allow map keys to be shown in directory listings. This option
+can have values of "yes" or "no". The default is "no". A variation
+of this option, "browsable", can be used as a pseudo mount option
+in type "auto" map entries to provide provide browsing funtionality
+in sub-mounts. The amd "browsable_dirs = full" option cannot be
+implemented within the current autofs framework and is not supported.
 .TP
 .B exec_map_timeout
 .br
modules/amd_parse.y +1 -2
index bfa1d51..b33250a 100644
@@ -433,8 +433,7 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
 
 options: OPTION
 	{
-		if (!strcmp($1, "browsable") ||
-		    !strcmp($1, "fullybrowsable") ||
+		if (!strcmp($1, "fullybrowsable") ||
 		    !strcmp($1, "nounmount") ||
 		    !strcmp($1, "unmount")) {
 			sprintf(msg_buf, "option %s is not currently "
modules/mount_autofs.c +4 -4
index 3ba5271..e404c83 100644
@@ -121,11 +121,13 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 			while (*comma != '\0' && *comma != ',')
 				comma++;
 
-			if (_strncmp("nobrowse", cp, 8) == 0)
+			if (_strncmp("nobrowse", cp, 8) == 0 ||
+			    _strncmp("nobrowsable", cp, 11) == 0)
 				ghost = 0;
 			else if (_strncmp("nobind", cp, 6) == 0)
 				nobind = 1;
-			else if (_strncmp("browse", cp, 6) == 0)
+			else if (_strncmp("browse", cp, 6) == 0 ||
+				 _strncmp("browsable", cp, 9) == 0)
 				ghost = 1;
 			else if (_strncmp("symlink", cp, 7) == 0)
 				symlnk = 1;
@@ -287,8 +289,6 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 			nap->pref = am_entry->pref;
 			am_entry->pref = NULL;
 		}
-		/* amd mounts don't support browse mode */
-		nap->flags &= ~MOUNT_FLAG_GHOST;
 	}
 
 	if (handle_mounts_startup_cond_init(&suc)) {
modules/parse_amd.c +1 -1
index 38d76b8..2ff43fa 100644
@@ -930,7 +930,7 @@ static int do_auto_mount(struct autofs_point *ap, const char *name,
 	}
 
 	return do_mount(ap, ap->path,
-			name, strlen(name), target, "autofs", NULL);
+			name, strlen(name), target, "autofs", entry->opts);
 }
 
 static int do_link_mount(struct autofs_point *ap, const char *name,
redhat/autofs.conf.default.in +5 -2
index c7e4d97..4a4b582 100644
@@ -274,8 +274,6 @@ mount_nfs_default_protocol = 4
 #	is a sensible option to implement and that will be
 #	done.
 #
-# browsable_dirs - not yet implemented.
-#
 # exec_map_timeout - a timeout is not currently used for
 #	for program maps, might be implemented.
 #
@@ -318,6 +316,11 @@ mount_nfs_default_protocol = 4
 #	takes its default value from the autofs internal default
 #	of 600 seconds.
 #
+# browsable_dirs - make map keys visible in directory listings.
+#	Note that support for the "fullybrowsable" option cannot
+#	be added using the existing kernel to user space autofs
+#	implementation.
+#
 # autofs_use_lofs - if set to "yes" autofs will attempt to use bind
 #	mounts for type "auto" when possible.
 #
samples/autofs.conf.default.in +5 -2
index d52ad85..4af05aa 100644
@@ -273,8 +273,6 @@ browse_mode = no
 #	is a sensible option to implement and that will be
 #	done.
 #
-# browsable_dirs - not yet implemented.
-#
 # exec_map_timeout - a timeout is not currently used for
 #	for program maps, might be implemented.
 #
@@ -317,6 +315,11 @@ browse_mode = no
 #	takes its default value from the autofs internal default
 #	of 600 seconds.
 #
+# browsable_dirs - make map keys visible in directory listings.
+#	Note that support for the "fullybrowsable" option cannot
+#	be added using the existing kernel to user space autofs
+#	implementation.
+#
 # autofs_use_lofs - if set to "yes" autofs will attempt to use bind
 #	mounts for type "auto" when possible.
 #

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#13 lore raw

PATCH 13/34 autofs-5.1.2 - add function conf_amd_get_map_name()

In reply to Ian Kent

Add configuration function to get the map_name option from an amd mount configuration section.

---
 CHANGELOG          |    1 +
 include/defaults.h |    1 +
 lib/defaults.c     |   10 ++++++++++
 3 files changed, 12 insertions(+)
CHANGELOG +1 -0
index b67fd56..ac195ed 100644
@@ -39,6 +39,7 @@ xx/xx/2016 autofs-5.1.3
 - fix typos in README.amd-maps.
 - add ref counting to struct map_source.
 - add support for amd browsable option.
+- add function conf_amd_get_map_name().
 
 15/06/2016 autofs-5.1.2
 =======================
include/defaults.h +1 -0
index b93fda3..650f3e6 100644
@@ -194,6 +194,7 @@ char *conf_amd_get_nfs_proto(void);
 char *conf_amd_get_nis_domain(void);
 unsigned int conf_amd_set_nis_domain(const char *);
 char *conf_amd_get_map_defaults(const char *);
+char *conf_amd_get_map_name(const char *);
 char *conf_amd_get_map_type(const char *);
 char *conf_amd_get_search_path(const char *);
 unsigned int conf_amd_get_dismount_interval(const char *);
lib/defaults.c +10 -0
index 3ac231b..fba5d78 100644
@@ -108,6 +108,7 @@
 #define NAME_AMD_MAP_DEFAULTS			"map_defaults"
 #define NAME_AMD_MAP_OPTIONS			"map_options"
 #define NAME_AMD_MAP_RELOAD_INTERVAL		"map_reload_interval"
+#define NAME_AMD_MAP_NAME			"map_name"
 #define NAME_AMD_MAP_TYPE			"map_type"
 #define NAME_AMD_MOUNT_TYPE			"mount_type"
 #define NAME_AMD_PID_FILE			"pid_file"
@@ -1934,6 +1935,15 @@ char *conf_amd_get_map_defaults(const char *section)
 	return tmp;
 }
 
+char *conf_amd_get_map_name(const char *section)
+{
+	char *tmp = NULL;
+	if (section)
+		tmp = conf_get_string(section, NAME_AMD_MAP_NAME);
+
+	return tmp;
+}
+
 char *conf_amd_get_map_type(const char *section)
 {
 	char *tmp = NULL;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#14 lore raw

PATCH 14/34 autofs-5.1.2 - add function conf_amd_get_mount_paths()

In reply to Ian Kent

Add configuration function to get an array of amd mount section paths.

---
 CHANGELOG          |    1 +
 include/defaults.h |    1 +
 lib/defaults.c     |   80 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+)
CHANGELOG +1 -0
index ac195ed..750b803 100644
@@ -40,6 +40,7 @@ xx/xx/2016 autofs-5.1.3
 - add ref counting to struct map_source.
 - add support for amd browsable option.
 - add function conf_amd_get_map_name().
+- add function conf_amd_get_mount_paths().
 
 15/06/2016 autofs-5.1.2
 =======================
include/defaults.h +1 -0
index 650f3e6..7766196 100644
@@ -174,6 +174,7 @@ unsigned int defaults_disable_not_found_message(void);
 unsigned int defaults_get_sss_master_map_wait(void);
 
 unsigned int conf_amd_mount_section_exists(const char *);
+char **conf_amd_get_mount_paths(void);
 char *conf_amd_get_arch(void);
 char *conf_amd_get_karch(void);
 char *conf_amd_get_os(void);
lib/defaults.c +80 -0

92 lines not on this page · raw message

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#15 lore raw

PATCH 15/34 autofs-5.1.2 - include amd mount section mounts in master mounts list

In reply to Ian Kent

Currently a master map entry is required for amd format maps and top level amd mount path configuration sections can only used to provide additional per-mount configuration.

But being able to use the top level amd format mount path configuration sections alone allows potentially incompatible master map entries to not be included in the master map.

---
 CHANGELOG       |    1 +
 README.amd-maps |   49 +++++++++++++++++++++----
 lib/master.c    |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 152 insertions(+), 7 deletions(-)
CHANGELOG +1 -0
index 750b803..4e677e2 100644
@@ -41,6 +41,7 @@ xx/xx/2016 autofs-5.1.3
 - add support for amd browsable option.
 - add function conf_amd_get_map_name().
 - add function conf_amd_get_mount_paths().
+- include amd mount sections mounts in master mounts list.
 
 15/06/2016 autofs-5.1.2
 =======================
README.amd-maps +42 -7

76 lines not on this page · raw message

lib/master.c +109 -0

121 lines not on this page · raw message

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#16 lore raw

PATCH 16/34 autofs-5.1.2 - check for conflicting amd section mounts

In reply to Ian Kent

Allowing the addition of amd section mounts to the master mounts list can lead to conflicting mount point paths.

Check for conflicts and skip the amd mount section mounts if a conflict with the master map mounts is found.

---
 CHANGELOG        |    1 +
 include/master.h |    1 +
 lib/master.c     |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 58 insertions(+), 3 deletions(-)
CHANGELOG +1 -0
index 4e677e2..3615de7 100644
@@ -42,6 +42,7 @@ xx/xx/2016 autofs-5.1.3
 - add function conf_amd_get_map_name().
 - add function conf_amd_get_mount_paths().
 - include amd mount sections mounts in master mounts list.
+- check for conflicting amd section mounts.
 
 15/06/2016 autofs-5.1.2
 =======================
include/master.h +1 -0
index 3947cd5..087ddbe 100644
@@ -106,6 +106,7 @@ void master_source_lock_cleanup(void *);
 void master_source_current_wait(struct master_mapent *);
 void master_source_current_signal(struct master_mapent *);
 struct master_mapent *master_find_mapent(struct master *, const char *);
+unsigned int master_partial_match_mapent(struct master *, const char *);
 struct autofs_point *__master_find_submount(struct autofs_point *, const char *);
 struct autofs_point *master_find_submount(struct autofs_point *, const char *);
 struct amd_entry *__master_find_amdmount(struct autofs_point *, const char *);
lib/master.c +56 -3

72 lines not on this page · raw message

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#17 lore raw

PATCH 17/34 autofs-5.1.2 - add function conf_amd_get_map_options()

In reply to Ian Kent

Add configuration function to get the map_options option from an amd mount configuration section.

---
 CHANGELOG          |    1 +
 include/defaults.h |    1 +
 lib/defaults.c     |   14 ++++++++++++++
 3 files changed, 16 insertions(+)
CHANGELOG +1 -0
index 3615de7..115afdb 100644
@@ -43,6 +43,7 @@ xx/xx/2016 autofs-5.1.3
 - add function conf_amd_get_mount_paths().
 - include amd mount sections mounts in master mounts list.
 - check for conflicting amd section mounts.
+- add function conf_get_map_options().
 
 15/06/2016 autofs-5.1.2
 =======================
include/defaults.h +1 -0
index 7766196..7f0129b 100644
@@ -196,6 +196,7 @@ char *conf_amd_get_nis_domain(void);
 unsigned int conf_amd_set_nis_domain(const char *);
 char *conf_amd_get_map_defaults(const char *);
 char *conf_amd_get_map_name(const char *);
+char *conf_amd_get_map_options(const char *);
 char *conf_amd_get_map_type(const char *);
 char *conf_amd_get_search_path(const char *);
 unsigned int conf_amd_get_dismount_interval(const char *);
lib/defaults.c +14 -0
index 102eda5..4a14367 100644
@@ -501,6 +501,11 @@ static int conf_load_amd_defaults(void)
 	if (ret == CFG_FAIL)
 		goto error;
 
+	ret = conf_update(sec, NAME_AMD_MAP_OPTIONS,
+			  DEFAULT_AMD_MAP_OPTIONS, CONF_NONE);
+	if (ret == CFG_FAIL)
+		goto error;
+
 	ret = conf_update(sec, NAME_AMD_MAP_TYPE,
 			  DEFAULT_AMD_MAP_TYPE, CONF_NONE);
 	if (ret == CFG_FAIL)
@@ -2024,6 +2029,15 @@ char *conf_amd_get_map_name(const char *section)
 	return tmp;
 }
 
+char *conf_amd_get_map_options(const char *section)
+{
+	char *tmp = NULL;
+	if (section)
+		tmp = conf_get_string(section, NAME_AMD_MAP_OPTIONS);
+
+	return tmp;
+}
+
 char *conf_amd_get_map_type(const char *section)
 {
 	char *tmp = NULL;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#18 lore raw

PATCH 18/34 autofs-5.1.2 - capture cache option and its settings during parsing

In reply to Ian Kent

The amd map format parser was not aware of the optional sync parameter of the cache option.

Make the parser aware of the sync option and capture the cache option and its settings during map parsing.

---
 CHANGELOG           |    1 +
 include/parse_amd.h |    7 +++++++
 modules/amd_parse.y |   12 +++++++++---
 modules/amd_tok.l   |    2 +-
 4 files changed, 18 insertions(+), 4 deletions(-)
CHANGELOG +1 -0
index 115afdb..3999298 100644
@@ -44,6 +44,7 @@ xx/xx/2016 autofs-5.1.3
 - include amd mount sections mounts in master mounts list.
 - check for conflicting amd section mounts.
 - add function conf_get_map_options().
+- capture cache option and its settings during parsing.
 
 15/06/2016 autofs-5.1.2
 =======================
include/parse_amd.h +7 -0
index 313edd5..1664947 100644
@@ -39,9 +39,16 @@
 #define AMD_DEFAULTS_RESET	0x02000000
 #define AMD_DEFAULTS_MASK	0xff000000
 
+#define AMD_CACHE_OPTION_NONE	0x0000
+#define AMD_CACHE_OPTION_INC	0x0001
+#define AMD_CACHE_OPTION_ALL	0x0002
+#define AMD_CACHE_OPTION_REGEXP	0x0004
+#define AMD_CACHE_OPTION_SYNC	0x8000
+
 struct amd_entry {
 	char *path;
 	unsigned long flags;
+	unsigned int cache_opts;
 	char *type;
 	char *map_type;
 	char *pref;
modules/amd_parse.y +9 -3
index b33250a..e99820b 100644
@@ -425,9 +425,14 @@ option_assignment: MAP_OPTION OPTION_ASSIGN FS_TYPE
 	}
 	| MAP_OPTION OPTION_ASSIGN CACHE_OPTION
 	{
-		sprintf(msg_buf, "option %s is not used, autofs "
-				 "default caching is always used", $1);
-		amd_info(msg_buf);
+		if (strncmp($3, "inc", 3))
+			entry.cache_opts = AMD_CACHE_OPTION_INC;
+		else if (strncmp($3, "all", 3))
+			entry.cache_opts = AMD_CACHE_OPTION_ALL;
+		else if (strncmp($3, "re", 2))
+			entry.cache_opts = AMD_CACHE_OPTION_REGEXP;
+		if (strstr($3, "sync"))
+			entry.cache_opts |= AMD_CACHE_OPTION_SYNC;
 	}
 	;
 
@@ -535,6 +540,7 @@ static int amd_msg(const char *s)
 static void local_init_vars(void)
 {
 	memset(&entry, 0, sizeof(entry));
+	entry.cache_opts = AMD_CACHE_OPTION_NONE;
 	memset(opts, 0, sizeof(opts));
 }
 
modules/amd_tok.l +1 -1
index 03e716f..2eac5cb 100644
@@ -101,7 +101,7 @@ NOPT		({SSTR}|(({IP4ADDR}(\/{V4MASK})?)|({IP6ADDR}(\/{V6MASK})?)))
 MAPOPT		(fs|type|maptype|pref|sublink|cache)
 MNTOPT		(opts|addopts|remopts)
 FSOPTS		(rhost|rfs|dev|cachedir|mount|unmount|umount|delay)
-CHEOPT		(mapdefault|none|inc|re|regexp|all)
+CHEOPT		((mapdefault|none|inc|re|regexp|all)(,sync)?)
 MAPTYPE		(file|nis|nisplus|ldap|hesiod|exec|ndbm|passwd|union)
 FSTYPE_LOCAL	(link|linkx|lofs|ufs|ext2|ext3|ext4|xfs|jfs|cdfs|cachefs)
 FSTYPE_NET	(nfs|nfsx|nfsl|host)

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#19 lore raw

PATCH 19/34 autofs-5.1.2 - handle map_option cache for top level mounts

In reply to Ian Kent

In order to read in the map at mount time autofs top level mounts must be set as browsasble but amd top level mounts that have the map_option cache:=all set need to read in the map without the browse option being set.

---
 CHANGELOG            |    1 +
 include/automount.h  |    3 +++
 lib/master.c         |   15 +++++++++++++++
 lib/master_parse.y   |   16 ++++++++++++++++
 man/autofs.conf.5.in |    8 ++++++--
 5 files changed, 41 insertions(+), 2 deletions(-)
CHANGELOG +1 -0
index 3999298..3415b18 100644
@@ -45,6 +45,7 @@ xx/xx/2016 autofs-5.1.3
 - check for conflicting amd section mounts.
 - add function conf_get_map_options().
 - capture cache option and its settings during parsing.
+- handle map_option cache for top level mounts.
 
 15/06/2016 autofs-5.1.2
 =======================
include/automount.h +3 -0
index f643f84..1d378c2 100644
@@ -528,6 +528,9 @@ struct kernel_mod_version {
 /* Use symlinks instead of bind mounting local mounts */
 #define MOUNT_FLAG_SYMLINK		0x0040
 
+/* Read amd map even if it's not to be ghosted (browsable) */
+#define MOUNT_FLAG_AMD_CACHE_ALL	0x0080
+
 struct autofs_point {
 	pthread_t thid;
 	char *path;			/* Mount point name */
lib/master.c +15 -0
index 6beae87..3f91808 100644
@@ -983,6 +983,7 @@ static void master_add_amd_mount_section_mounts(struct master *master, time_t ag
 		unsigned int ghost = 0;
 		char *type = NULL;
 		char *map = NULL;
+		char *opts;
 
 		ret = master_partial_match_mapent(master, path);
 		if (ret) {
@@ -1037,6 +1038,20 @@ static void master_add_amd_mount_section_mounts(struct master *master, time_t ag
 			goto next;
 		}
 
+		opts = conf_amd_get_map_options(path);
+		if (opts) {
+			/* autofs uses the equivalent of cache:=inc,sync
+			 * (except for file maps which use cache:=all,sync)
+			 * but if the map is large then it may be necessary
+			 * to read the whole map at startup even if browsing
+			 * is is not enabled, so look for cache:=all in the
+			 * map_options configuration entry.
+			 */
+			if (strstr(opts, "cache:=all"))
+				entry->ap->flags |= MOUNT_FLAG_AMD_CACHE_ALL;
+			free(opts);
+		}
+
 		type = conf_amd_get_map_type(path);
 		argv[0] = map;
 		argv[1] = NULL;
lib/master_parse.y +16 -0
index 7536324..29bc3fc 100644
@@ -863,6 +863,22 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
 	if (mode && mode < LONG_MAX)
 		entry->ap->mode = mode;
 
+	if (format && !strcmp(format, "amd")) {
+		char *opts = conf_amd_get_map_options(path);
+		if (opts) {
+			/* autofs uses the equivalent of cache:=inc,sync
+			 * (except for file maps which use cache:=all,sync)
+			 * but if the map is large then it may be necessary
+			 * to read the whole map at startup even if browsing
+			 * is is not enabled, so look for cache:=all in the
+			 * map_options configuration entry.
+			 */
+			if (strstr(opts, "cache:=all"))
+				entry->ap->flags |= MOUNT_FLAG_AMD_CACHE_ALL;
+			free(opts);
+		}
+	}
+
 /*
 	source = master_find_map_source(entry, type, format,
 					local_argc, (const char **) local_argv); 
man/autofs.conf.5.in +6 -2
index a9ed1c3..360570d 100644
@@ -291,8 +291,12 @@ protocol version.
 .BR cache_duration ", " map_reload_interval ", " map_options
 .br
 The map	entry cache is continually updated and stale entries
-cleaned on re-load, which is done when map changes aredetected
-so these configuration entries are not used by autofs.
+cleaned on re-load, which is done when map changes are detected
+so these configuration entries are not used by autofs. An
+exception to this is the case where the map is large. In this
+case it may be necessary to read the whole map at startup even if
+browsing is is not enabled. Adding the cache:=all option to
+map_options can be used to for this.
 .TP
 .B localhost_address
 This is not used within autofs. This configuration option was

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#20 lore raw

PATCH 20/34 autofs-5.1.2 - handle amd cache option all in amd type auto mounts

In reply to Ian Kent

In order to read in the map at mount time autofs submounts must be set as browasble but amd type auto mounts that have the cache:=all option set need to read in the map without the browse option being set.

---
 CHANGELOG                |    1 +
 modules/lookup_ldap.c    |   10 ++++++----
 modules/lookup_nisplus.c |   10 ++++++----
 modules/lookup_sss.c     |   10 ++++++----
 modules/lookup_yp.c      |   10 ++++++----
 modules/mount_autofs.c   |    3 +++
 6 files changed, 28 insertions(+), 16 deletions(-)
CHANGELOG +1 -0
index 3415b18..9248bb9 100644
@@ -46,6 +46,7 @@ xx/xx/2016 autofs-5.1.3
 - add function conf_get_map_options().
 - capture cache option and its settings during parsing.
 - handle map_option cache for top level mounts.
+- handle amd cache option all in amd type auto mounts.
 
 15/06/2016 autofs-5.1.2
 =======================
modules/lookup_ldap.c +6 -4
index 45100ab..98701e5 100644
@@ -2797,11 +2797,13 @@ static int read_one_map(struct autofs_point *ap,
 	int rv, l;
 
 	/*
-	 * If we don't need to create directories then there's no use
-	 * reading the map. We always need to read the whole map for
-	 * direct mounts in order to mount the triggers.
+	 * If we don't need to create directories (or don't need
+	 * to read an amd cache:=all map) then there's no use
+	 * reading the map. We always need to read the whole map
+	 * for direct mounts in order to mount the triggers.
 	 */
-	if (!(ap->flags & MOUNT_FLAG_GHOST) && ap->type != LKP_DIRECT) {
+	if (ap->type != LKP_DIRECT &&
+	    !(ap->flags & (MOUNT_FLAG_GHOST|MOUNT_FLAG_AMD_CACHE_ALL))) {
 		debug(ap->logopt, "map read not needed, so not done");
 		return NSS_STATUS_SUCCESS;
 	}
modules/lookup_nisplus.c +6 -4
index c8b75e6..6430b89 100644
@@ -239,11 +239,13 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
 	master_source_current_signal(ap->entry);
 
 	/*
-	 * If we don't need to create directories then there's no use
-	 * reading the map. We always need to read the whole map for
-	 * direct mounts in order to mount the triggers.
+	 * If we don't need to create directories (or don't need
+	 * to read an amd cache:=all map) then there's no use
+	 * reading the map. We always need to read the whole map
+	 * for direct mounts in order to mount the triggers.
 	 */
-	if (!(ap->flags & MOUNT_FLAG_GHOST) && ap->type != LKP_DIRECT) {
+	if (ap->type != LKP_DIRECT &&
+	    !(ap->flags & (MOUNT_FLAG_GHOST|MOUNT_FLAG_AMD_CACHE_ALL))) {
 		debug(ap->logopt, "map read not needed, so not done");
 		return NSS_STATUS_SUCCESS;
 	}
modules/lookup_sss.c +6 -4
index ce4d0ed..6d924cf 100644
@@ -402,11 +402,13 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
 	mc = source->mc;
 
 	/*
-	 * If we don't need to create directories then there's no use
-	 * reading the map. We always need to read the whole map for
-	 * direct mounts in order to mount the triggers.
+	 * If we don't need to create directories (or don't need
+	 * to read an amd cache:=all map) then there's no use
+	 * reading the map. We always need to read the whole map
+	 * for direct mounts in order to mount the triggers.
 	 */
-	if (!(ap->flags & MOUNT_FLAG_GHOST) && ap->type != LKP_DIRECT) {
+	if (ap->type != LKP_DIRECT &&
+	    !(ap->flags & (MOUNT_FLAG_GHOST|MOUNT_FLAG_AMD_CACHE_ALL))) {
 		debug(ap->logopt, "map read not needed, so not done");
 		return NSS_STATUS_SUCCESS;
 	}
modules/lookup_yp.c +6 -4
index 0d319fd..b139b28 100644
@@ -401,11 +401,13 @@ int lookup_read_map(struct autofs_point *ap, time_t age, void *context)
 	master_source_current_signal(ap->entry);
 
 	/*
-	 * If we don't need to create directories then there's no use
-	 * reading the map. We always need to read the whole map for
-	 * direct mounts in order to mount the triggers.
+	 * If we don't need to create directories (or don't need
+	 * to read an amd cache:=all map) then there's no use
+	 * reading the map. We always need to read the whole map
+	 * for direct mounts in order to mount the triggers.
 	 */
-	if (!(ap->flags & MOUNT_FLAG_GHOST) && ap->type != LKP_DIRECT) {
+	if (ap->type != LKP_DIRECT &&
+	    !(ap->flags & (MOUNT_FLAG_GHOST|MOUNT_FLAG_AMD_CACHE_ALL))) {
 		debug(ap->logopt, "map read not needed, so not done");
 		return NSS_STATUS_SUCCESS;
 	}
modules/mount_autofs.c +3 -0
index e404c83..20bcd11 100644
@@ -289,6 +289,9 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 			nap->pref = am_entry->pref;
 			am_entry->pref = NULL;
 		}
+
+		if (am_entry->cache_opts & AMD_CACHE_OPTION_ALL)
+			nap->flags |= MOUNT_FLAG_AMD_CACHE_ALL;
 	}
 
 	if (handle_mounts_startup_cond_init(&suc)) {

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#21 lore raw

PATCH 21/34 autofs-5.1.2 - fix bogus check in expire_cleanup()

In reply to Ian Kent

ap->submount can never be 0 here.

---
 CHANGELOG      |    1 +
 daemon/state.c |    4 +---
 2 files changed, 2 insertions(+), 3 deletions(-)
CHANGELOG +1 -0
index 9248bb9..eaff2de 100644
@@ -47,6 +47,7 @@ xx/xx/2016 autofs-5.1.3
 - capture cache option and its settings during parsing.
 - handle map_option cache for top level mounts.
 - handle amd cache option all in amd type auto mounts.
+- fix bogus check in expire_cleanup().
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/state.c +1 -3
index 5d81438..41a5f6a 100644
@@ -139,9 +139,7 @@ void expire_cleanup(void *arg)
 					next = ST_SHUTDOWN_PENDING;
 					break;
 				}
-
-				if (ap->submount++ == 0)
-					ap->submount = 2;
+				ap->submount++;
 			}
 
 			if (ap->state == ST_EXPIRE && !ap->submount)

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#22 lore raw

PATCH 22/34 autofs-5.1.2 - delay submount exit for amd submounts

In reply to Ian Kent

For amd format maps it's better to not expire away submounts (amd type "auto" mounts) straight way.

This is because of the common heavy reuse of maps in amd maps and we want to try and avoid constantly re-reading large maps.

---
 CHANGELOG      |    1 +
 daemon/state.c |   18 +++++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)
CHANGELOG +1 -0
index eaff2de..a456146 100644
@@ -48,6 +48,7 @@ xx/xx/2016 autofs-5.1.3
 - handle map_option cache for top level mounts.
 - handle amd cache option all in amd type auto mounts.
 - fix bogus check in expire_cleanup().
+- delay submount exit for amd submounts.
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/state.c +15 -3
index 41a5f6a..be5a834 100644
@@ -132,15 +132,27 @@ void expire_cleanup(void *arg)
 			 * mount expires in a reasonable time. Just skip
 			 * one expire check after it's no longer busy before
 			 * allowing it to shutdown.
+			 *
+			 * But if this mount point is an amd format map it
+			 * is better to keep the mount around longer. This
+			 * is because of the common heavy reuse of maps in
+			 * amd maps and we want to try and avoid constantly
+			 * re-reading large maps.
 			 */
 			if (ap->submount && !success) {
 				rv = ops->askumount(ap->logopt, ap->ioctlfd, &idle);
 				if (!rv && idle && ap->submount > 1) {
-					next = ST_SHUTDOWN_PENDING;
-					break;
+					struct map_source *map = ap->entry->maps;
+
+					if (ap->submount > 4 ||
+					   !(map->flags & MAP_FLAG_FORMAT_AMD)) {
+						next = ST_SHUTDOWN_PENDING;
+						break;
+					}
 				}
 				ap->submount++;
-			}
+			} else if (ap->submount > 1)
+				ap->submount = 1;
 
 			if (ap->state == ST_EXPIRE && !ap->submount)
 				alarm_add(ap, ap->exp_runfreq);

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#23 lore raw

PATCH 23/34 autofs-5.1.2 - add the mount requestor's pid to pending_args

In reply to Ian Kent

From: Lars R. Damerow <[email protected]>

This will make it easier to log more information about the requesting process as the mount request proceeds.

---
 CHANGELOG           |    1 +
 daemon/direct.c     |    1 +
 daemon/indirect.c   |    1 +
 include/automount.h |    1 +
 4 files changed, 4 insertions(+)
CHANGELOG +1 -0
index a456146..cf9b62c 100644
@@ -49,6 +49,7 @@ xx/xx/2016 autofs-5.1.3
 - handle amd cache option all in amd type auto mounts.
 - fix bogus check in expire_cleanup().
 - delay submount exit for amd submounts.
+- add the mount requestor's pid to pending_args.
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/direct.c +1 -0
index 7a8d309..33faaea 100644
@@ -1462,6 +1462,7 @@ int handle_packet_missing_direct(struct autofs_point *ap, autofs_packet_missing_
 	mt->type = NFY_MOUNT;
 	mt->uid = pkt->uid;
 	mt->gid = pkt->gid;
+	mt->pid = pkt->pid;
 	mt->wait_queue_token = pkt->wait_queue_token;
 
 	status = pthread_create(&thid, &th_attr_detached, do_mount_direct, mt);
daemon/indirect.c +1 -0
index 72a23c3..0db2749 100644
@@ -857,6 +857,7 @@ int handle_packet_missing_indirect(struct autofs_point *ap, autofs_packet_missin
 	mt->dev = pkt->dev;
 	mt->uid = pkt->uid;
 	mt->gid = pkt->gid;
+	mt->pid = pkt->pid;
 	mt->wait_queue_token = pkt->wait_queue_token;
 
 	status = pthread_create(&thid, &th_attr_detached, do_mount_indirect, mt);
include/automount.h +1 -0
index 1d378c2..58c45a9 100644
@@ -427,6 +427,7 @@ struct pending_args {
 	unsigned int len;		/* Name field len */
 	uid_t uid;			/* uid of requester */
 	gid_t gid;			/* gid of requester */
+	pid_t pid;			/* pid of requestor */
 	unsigned long wait_queue_token;	/* Associated kernel wait token */
 };
 

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#24 lore raw

PATCH 24/34 autofs-5.1.2 - create thread-local ID for mount attempts

In reply to Ian Kent

From: Lars R. Damerow <[email protected]>

This patch creates key_thread_attempt_id as a pthread key and populates it in each new thread serving a mount attempt. This ID can be used in output logs as an easy string to grep for, allowing admins to quickly see a mount attempt's log entries without the messages from other attempts interleaved.

The contents of the ID are intended to be opaque, but to get a chance at a unique value for each mount attempt, this patch does a very simple hash computation of the thread's wait_queue_token, the pid of the requesting process, and the key for the mount. The hash is based on the public domain sdbm library.

---
 CHANGELOG           |    1 +
 daemon/automount.c  |   24 ++++++++++++++++++++++++
 daemon/direct.c     |   17 +++++++++++++++++
 daemon/indirect.c   |   17 +++++++++++++++++
 include/automount.h |    6 ++++++
 5 files changed, 65 insertions(+)
CHANGELOG +1 -0
index cf9b62c..0cd0d45 100644
@@ -50,6 +50,7 @@ xx/xx/2016 autofs-5.1.3
 - fix bogus check in expire_cleanup().
 - delay submount exit for amd submounts.
 - add the mount requestor's pid to pending_args.
+- create thread-local ID for mount attempts.
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/automount.c +24 -0
index 6ebe885..2b23dec 100644
@@ -89,6 +89,7 @@ struct startup_cond suc = {
 	PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0};
 
 pthread_key_t key_thread_stdenv_vars;
+pthread_key_t key_thread_attempt_id = (pthread_key_t) 0L;
 
 #define MAX_OPEN_FILES		10240
 
@@ -98,6 +99,17 @@ static int umount_all(struct autofs_point *ap, int force);
 
 extern struct master *master_list;
 
+/* simple string hash based on public domain sdbm library */
+unsigned long sdbm_hash(const char *str, unsigned long seed)
+{
+	unsigned long hash = seed;
+	char c;
+
+	while ((c = *str++))
+		hash = c + (hash << 6) + (hash << 16) - hash;
+	return hash;
+}
+
 static int is_remote_fstype(unsigned int fs_type)
 {
 	int ret = 0;
@@ -2468,6 +2480,18 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
+	status = pthread_key_create(&key_thread_attempt_id, free);
+	if (status) {
+		logerr("%s: failed to create thread data key for attempt ID!",
+		       program);
+		master_kill(master_list);
+		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
+		close(start_pipefd[1]);
+		release_flag_file();
+		macro_free_global_table();
+		exit(1);
+	}
+
 	init_ioctl_ctl();
 
 	if (!alarm_start_handler()) {
daemon/direct.c +17 -0
index 33faaea..6f1329b 100644
@@ -1210,6 +1210,8 @@ static void *do_mount_direct(void *arg)
 	struct autofs_point *ap;
 	struct stat st;
 	int status, state;
+	char attempt_id_comp[20];
+	unsigned long *attempt_id;
 
 	args = (struct pending_args *) arg;
 
@@ -1219,6 +1221,21 @@ static void *do_mount_direct(void *arg)
 
 	ap = mt.ap;
 
+	attempt_id = pthread_getspecific(key_thread_attempt_id);
+	if (attempt_id == NULL) {
+		attempt_id = (unsigned long *) calloc(1, sizeof(unsigned long));
+		if (attempt_id == NULL)
+			fatal(ENOMEM);
+		snprintf(attempt_id_comp, 20, "%ld", mt.wait_queue_token);
+		*attempt_id = sdbm_hash(attempt_id_comp, 0);
+		snprintf(attempt_id_comp, 20, "%u", mt.pid);
+		*attempt_id = sdbm_hash(attempt_id_comp, *attempt_id);
+		*attempt_id = sdbm_hash(mt.name, *attempt_id);
+		status = pthread_setspecific(key_thread_attempt_id, attempt_id);
+		if (status != 0)
+			fatal(status);
+	}
+
 	args->signaled = 1;
 	status = pthread_cond_signal(&args->cond);
 	if (status)
daemon/indirect.c +17 -0
index 0db2749..3ed47e8 100644
@@ -726,6 +726,8 @@ static void *do_mount_indirect(void *arg)
 	char buf[PATH_MAX + 1];
 	struct stat st;
 	int len, status, state;
+	char attempt_id_comp[20];
+	unsigned long *attempt_id;
 
 	args = (struct pending_args *) arg;
 
@@ -735,6 +737,21 @@ static void *do_mount_indirect(void *arg)
 
 	ap = mt.ap;
 
+	attempt_id = pthread_getspecific(key_thread_attempt_id);
+	if (attempt_id == NULL) {
+		attempt_id = (unsigned long *) calloc(1, sizeof(unsigned long));
+		if (attempt_id  == NULL)
+			fatal(ENOMEM);
+		snprintf(attempt_id_comp, 20, "%ld", mt.wait_queue_token);
+		*attempt_id = sdbm_hash(attempt_id_comp, 0);
+		snprintf(attempt_id_comp, 20, "%u", mt.pid);
+		*attempt_id = sdbm_hash(attempt_id_comp, *attempt_id);
+		*attempt_id = sdbm_hash(mt.name, *attempt_id);
+		status = pthread_setspecific(key_thread_attempt_id, attempt_id);
+		if (status != 0)
+			fatal(status);
+	}
+
 	args->signaled = 1;
 	status = pthread_cond_signal(&args->cond);
 	if (status)
include/automount.h +6 -0
index 58c45a9..1800c21 100644
@@ -78,6 +78,8 @@ int load_autofs4_module(void);
 #define NCP_SUPER_MAGIC    0x0000564CL
 #define NFS_SUPER_MAGIC    0x00006969L
 
+#define ATTEMPT_ID_SIZE 24
+
 /* This sould be enough for at least 20 host aliases */
 #define HOST_ENT_BUF_SIZE	2048
 
@@ -243,6 +245,8 @@ const char **copy_argv(int argc, const char **argv);
 int compare_argv(int argc1, const char **argv1, int argc2, const char **argv2);
 int free_argv(int argc, const char **argv);
 
+unsigned long sdbm_hash(const char *str, unsigned long seed);
+
 void dump_core(void);
 int aquire_lock(void);
 void release_lock(void);
@@ -503,6 +507,8 @@ struct thread_stdenv_vars {
 
 extern pthread_key_t key_thread_stdenv_vars;
 
+extern pthread_key_t key_thread_attempt_id;
+
 struct kernel_mod_version {
 	unsigned int major;
 	unsigned int minor;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#25 lore raw

PATCH 25/34 autofs-5.1.2 - log functions to prefix messages with attempt_id if available

In reply to Ian Kent

From: Lars R. Damerow <[email protected]>

Now that there should be a mount attempt id try and include it in log entries.

---
 CHANGELOG |    1 
 lib/log.c |  164 +++++++++++++++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 137 insertions(+), 28 deletions(-)
CHANGELOG +1 -0
index 0cd0d45..eed9697 100644
@@ -51,6 +51,7 @@ xx/xx/2016 autofs-5.1.3
 - delay submount exit for amd submounts.
 - add the mount requestor's pid to pending_args.
 - create thread-local ID for mount attempts.
+- log functions to prefix messages with attempt_id if available.
 
 15/06/2016 autofs-5.1.2
 =======================
lib/log.c +136 -28

266 lines not on this page · raw message

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#26 lore raw

PATCH 26/34 autofs-5.1.2 - factor out set_thread_mount_request_log_id()

In reply to Ian Kent

Factor out setting the thread mount request log id.

---
 CHANGELOG           |    1 +
 daemon/automount.c  |   24 +++++++++++++++++++++++-
 daemon/direct.c     |   17 +----------------
 daemon/indirect.c   |   17 +----------------
 include/automount.h |    3 ++-
 5 files changed, 28 insertions(+), 34 deletions(-)
CHANGELOG +1 -0
index eed9697..7add032 100644
@@ -52,6 +52,7 @@ xx/xx/2016 autofs-5.1.3
 - add the mount requestor's pid to pending_args.
 - create thread-local ID for mount attempts.
 - log functions to prefix messages with attempt_id if available.
+- factor out set_thread_mount_request_log_id().
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/automount.c +23 -1
index 2b23dec..203d21f 100644
@@ -100,7 +100,7 @@ static int umount_all(struct autofs_point *ap, int force);
 extern struct master *master_list;
 
 /* simple string hash based on public domain sdbm library */
-unsigned long sdbm_hash(const char *str, unsigned long seed)
+static unsigned long sdbm_hash(const char *str, unsigned long seed)
 {
 	unsigned long hash = seed;
 	char c;
@@ -110,6 +110,28 @@ unsigned long sdbm_hash(const char *str, unsigned long seed)
 	return hash;
 }
 
+void set_thread_mount_request_log_id(struct pending_args *mt)
+{
+	char attempt_id_comp[20];
+	unsigned long *attempt_id;
+	int status;
+
+	attempt_id = pthread_getspecific(key_thread_attempt_id);
+	if (attempt_id == NULL) {
+		attempt_id = (unsigned long *) calloc(1, sizeof(unsigned long));
+		if (attempt_id  == NULL)
+			fatal(ENOMEM);
+		snprintf(attempt_id_comp, 20, "%ld", mt->wait_queue_token);
+		*attempt_id = sdbm_hash(attempt_id_comp, 0);
+		snprintf(attempt_id_comp, 20, "%u", mt->pid);
+		*attempt_id = sdbm_hash(attempt_id_comp, *attempt_id);
+		*attempt_id = sdbm_hash(mt->name, *attempt_id);
+		status = pthread_setspecific(key_thread_attempt_id, attempt_id);
+		if (status != 0)
+			fatal(status);
+	}
+}
+
 static int is_remote_fstype(unsigned int fs_type)
 {
 	int ret = 0;
daemon/direct.c +1 -16
index 6f1329b..b682346 100644
@@ -1210,8 +1210,6 @@ static void *do_mount_direct(void *arg)
 	struct autofs_point *ap;
 	struct stat st;
 	int status, state;
-	char attempt_id_comp[20];
-	unsigned long *attempt_id;
 
 	args = (struct pending_args *) arg;
 
@@ -1221,20 +1219,7 @@ static void *do_mount_direct(void *arg)
 
 	ap = mt.ap;
 
-	attempt_id = pthread_getspecific(key_thread_attempt_id);
-	if (attempt_id == NULL) {
-		attempt_id = (unsigned long *) calloc(1, sizeof(unsigned long));
-		if (attempt_id == NULL)
-			fatal(ENOMEM);
-		snprintf(attempt_id_comp, 20, "%ld", mt.wait_queue_token);
-		*attempt_id = sdbm_hash(attempt_id_comp, 0);
-		snprintf(attempt_id_comp, 20, "%u", mt.pid);
-		*attempt_id = sdbm_hash(attempt_id_comp, *attempt_id);
-		*attempt_id = sdbm_hash(mt.name, *attempt_id);
-		status = pthread_setspecific(key_thread_attempt_id, attempt_id);
-		if (status != 0)
-			fatal(status);
-	}
+	set_thread_mount_request_log_id(&mt);
 
 	args->signaled = 1;
 	status = pthread_cond_signal(&args->cond);
daemon/indirect.c +1 -16
index 3ed47e8..00b2622 100644
@@ -726,8 +726,6 @@ static void *do_mount_indirect(void *arg)
 	char buf[PATH_MAX + 1];
 	struct stat st;
 	int len, status, state;
-	char attempt_id_comp[20];
-	unsigned long *attempt_id;
 
 	args = (struct pending_args *) arg;
 
@@ -737,20 +735,7 @@ static void *do_mount_indirect(void *arg)
 
 	ap = mt.ap;
 
-	attempt_id = pthread_getspecific(key_thread_attempt_id);
-	if (attempt_id == NULL) {
-		attempt_id = (unsigned long *) calloc(1, sizeof(unsigned long));
-		if (attempt_id  == NULL)
-			fatal(ENOMEM);
-		snprintf(attempt_id_comp, 20, "%ld", mt.wait_queue_token);
-		*attempt_id = sdbm_hash(attempt_id_comp, 0);
-		snprintf(attempt_id_comp, 20, "%u", mt.pid);
-		*attempt_id = sdbm_hash(attempt_id_comp, *attempt_id);
-		*attempt_id = sdbm_hash(mt.name, *attempt_id);
-		status = pthread_setspecific(key_thread_attempt_id, attempt_id);
-		if (status != 0)
-			fatal(status);
-	}
+	set_thread_mount_request_log_id(&mt);
 
 	args->signaled = 1;
 	status = pthread_cond_signal(&args->cond);
include/automount.h +2 -1
index 1800c21..eb4fcc4 100644
@@ -245,7 +245,8 @@ const char **copy_argv(int argc, const char **argv);
 int compare_argv(int argc1, const char **argv1, int argc2, const char **argv2);
 int free_argv(int argc, const char **argv);
 
-unsigned long sdbm_hash(const char *str, unsigned long seed);
+struct pending_args;
+void set_thread_mount_request_log_id(struct pending_args *mt);
 
 void dump_core(void);
 int aquire_lock(void);

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#27 lore raw

PATCH 27/34 autofs-5.1.2 - add config option to use mount request log id

In reply to Ian Kent

Add a configuration option to control whether request ids are added to mount request log entries. It's default value is to not include the additional id.

---
 CHANGELOG                      |    1 +
 daemon/automount.c             |    3 +++
 include/defaults.h             |    2 ++
 lib/defaults.c                 |   17 +++++++++++++++++
 man/autofs.conf.5.in           |    6 ++++++
 redhat/autofs.conf.default.in  |    7 +++++++
 samples/autofs.conf.default.in |    7 +++++++
 7 files changed, 43 insertions(+)
CHANGELOG +1 -0
index 7add032..5e3ca0d 100644
@@ -53,6 +53,7 @@ xx/xx/2016 autofs-5.1.3
 - create thread-local ID for mount attempts.
 - log functions to prefix messages with attempt_id if available.
 - factor out set_thread_mount_request_log_id().
+- add config option to use mount request log id.
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/automount.c +3 -0
index 203d21f..d27804d 100644
@@ -116,6 +116,9 @@ void set_thread_mount_request_log_id(struct pending_args *mt)
 	unsigned long *attempt_id;
 	int status;
 
+	if (!defaults_get_use_mount_request_log_id())
+		return;
+
 	attempt_id = pthread_getspecific(key_thread_attempt_id);
 	if (attempt_id == NULL) {
 		attempt_id = (unsigned long *) calloc(1, sizeof(unsigned long));
include/defaults.h +2 -0
index 7f0129b..b28fde3 100644
@@ -52,6 +52,7 @@
 #define DEFAULT_DISABLE_NOT_FOUND_MESSAGE "0"
 
 #define DEFAULT_SSS_MASTER_MAP_WAIT	"0"
+#define DEFAULT_USE_MOUNT_REQUEST_LOG_ID "0"
 
 /* Config entry flags */
 #define CONF_NONE			0x00000000
@@ -172,6 +173,7 @@ unsigned int defaults_get_map_hash_table_size(void);
 unsigned int defaults_use_hostname_for_mounts(void);
 unsigned int defaults_disable_not_found_message(void);
 unsigned int defaults_get_sss_master_map_wait(void);
+unsigned int defaults_get_use_mount_request_log_id(void);
 
 unsigned int conf_amd_mount_section_exists(const char *);
 char **conf_amd_get_mount_paths(void);
lib/defaults.c +17 -0
index 4a14367..d20c190 100644
@@ -78,6 +78,7 @@
 #define NAME_DISABLE_NOT_FOUND_MESSAGE	"disable_not_found_message"
 
 #define NAME_SSS_MASTER_MAP_WAIT	"sss_master_map_wait"
+#define NAME_USE_MOUNT_REQUEST_LOG_ID	"use_mount_request_log_id"
 
 #define NAME_AMD_ARCH				"arch"
 #define NAME_AMD_AUTO_ATTRCACHE			"auto_attrcache"
@@ -362,6 +363,11 @@ static int conf_load_autofs_defaults(void)
 	if (ret == CFG_FAIL)
 		goto error;
 
+	ret = conf_update(sec, NAME_USE_MOUNT_REQUEST_LOG_ID,
+			  DEFAULT_USE_MOUNT_REQUEST_LOG_ID, CONF_ENV);
+	if (ret == CFG_FAIL)
+		goto error;
+
 	/* LDAP_URI and SEARCH_BASE can occur multiple times */
 	while ((co = conf_lookup(sec, NAME_LDAP_URI)))
 		conf_delete(co->section, co->name);
@@ -1852,6 +1858,17 @@ unsigned int defaults_get_sss_master_map_wait(void)
 	return res;
 }
 
+unsigned int defaults_get_use_mount_request_log_id(void)
+{
+	int res;
+
+	res = conf_get_yesno(autofs_gbl_sec, NAME_USE_MOUNT_REQUEST_LOG_ID);
+	if (res < 0)
+		res = atoi(DEFAULT_USE_MOUNT_REQUEST_LOG_ID);
+
+	return res;
+}
+
 unsigned int conf_amd_mount_section_exists(const char *section)
 {
 	return conf_section_exists(section);
man/autofs.conf.5.in +6 -0
index 360570d..a777c58 100644
@@ -148,6 +148,12 @@ Set the time to wait and retry if sssd returns "no such entry" when starting
 up. When sssd is starting up it can sometimes return "no such entry" for a
 short time until it has read in the LDAP map information. Default is 0 seconds,
 don't wait.
+.TP
+.B use_mount_request_log_id
+.br
+Set whether to use a mount request log id so that log entries for specific
+mount requests can be easily identified in logs that have multiple conncurrent
+requests. Default is don't use mount request log ids.
 .SS LDAP Configuration
 .P
 Configuration settings available are:
redhat/autofs.conf.default.in +7 -0
index 4a4b582..3c6a316 100644
@@ -71,6 +71,13 @@ mount_nfs_default_protocol = 4
 #
 # force_standard_program_map_env = no
 #
+# use_mount_request_log_id - Set whether to use a mount request log
+#			id so that log entries for specific mount
+#			requests can be easily identified in logs
+#			that have multiple conncurrent requests.
+#
+#use_mount_request_log_id = no
+#
 # Define base dn for map dn lookup.
 #
 # Define server URIs
samples/autofs.conf.default.in +7 -0
index 4af05aa..3ea3dd1 100644
@@ -70,6 +70,13 @@ browse_mode = no
 #
 # force_standard_program_map_env = no
 #
+# use_mount_request_log_id - Set whether to use a mount request log
+#			id so that log entries for specific mount
+#			requests can be easily identified in logs
+#			that have multiple conncurrent requests.
+#
+#use_mount_request_log_id = no
+#
 # Define base dn for map dn lookup.
 #
 # Define server URIs

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#28 lore raw

PATCH 28/34 autofs-5.1.2 - use autofs_point to store expire timeout where possibe

In reply to Ian Kent

For technical reasons the expire timeout is stored in the map entry source rather than the struct autofs_point and must be stored in the map source for direct (and offset) mounts.

But with the map source re-use needed by amd format type "auto" mounts the timeout can't be stored in the map source since the it may be different for mounts that share the map source.

So use the struct autofs_point where possible.

---
 CHANGELOG              |    1 +
 daemon/direct.c        |    6 +++---
 daemon/indirect.c      |    2 +-
 daemon/state.c         |   12 +++++++-----
 include/automount.h    |    1 +
 include/mounts.h       |    2 ++
 lib/master.c           |    5 ++++-
 lib/master_parse.y     |   27 +++++++++++++--------------
 lib/mounts.c           |   27 +++++++++++++++++++++------
 modules/mount_autofs.c |   12 ++++--------
 10 files changed, 57 insertions(+), 38 deletions(-)
CHANGELOG +1 -0
index 5e3ca0d..1a4a8d9 100644
@@ -54,6 +54,7 @@ xx/xx/2016 autofs-5.1.3
 - log functions to prefix messages with attempt_id if available.
 - factor out set_thread_mount_request_log_id().
 - add config option to use mount request log id.
+- use autofs_point to store expire timeout where possibe.
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/direct.c +3 -3
index b682346..9a13435 100644
@@ -312,7 +312,7 @@ static int unlink_active_mounts(struct autofs_point *ap, struct mnt_list *mnts,
 
 	if (tree_get_mnt_list(mnts, &list, me->key, 1)) {
 		if (ap->state == ST_READMAP) {
-			time_t tout = me->source->exp_timeout;
+			time_t tout = get_exp_timeout(ap, me->source);
 			int save_ioctlfd, ioctlfd;
 
 			save_ioctlfd = ioctlfd = me->ioctlfd;
@@ -522,7 +522,7 @@ int mount_autofs_direct(struct autofs_point *ap)
 		}
 
 		mc = map->mc;
-		timeout = map->exp_timeout;
+		timeout = get_exp_timeout(ap, map);
 		cache_readlock(mc);
 		pthread_cleanup_push(cache_lock_cleanup, mc);
 		me = cache_enumerate(mc, NULL);
@@ -678,7 +678,7 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char *
 	struct ioctl_ops *ops = get_ioctl_ops();
 	char buf[MAX_ERR_BUF];
 	struct mnt_params *mp;
-	time_t timeout = me->source->exp_timeout;
+	time_t timeout = get_exp_timeout(ap, me->source);
 	struct stat st;
 	int ioctlfd, status, ret;
 	const char *hosts_map_name = "-hosts";
daemon/indirect.c +1 -1
index 00b2622..ffb11b8 100644
@@ -87,7 +87,7 @@ static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root)
 {
 	const char *str_indirect = mount_type_str(t_indirect);
 	struct ioctl_ops *ops = get_ioctl_ops();
-	time_t timeout = ap->entry->maps->exp_timeout;
+	time_t timeout = get_exp_timeout(ap, ap->entry->maps);
 	char *options = NULL;
 	const char *hosts_map_name = "-hosts";
 	const char *map_name = hosts_map_name;
daemon/state.c +7 -5
index be5a834..cd0dd93 100644
@@ -407,6 +407,7 @@ static void do_readmap_mount(struct autofs_point *ap, struct mnt_list *mnts,
 		if (valid) {
 			struct mapent_cache *vmc = valid->mc;
 			struct ioctl_ops *ops = get_ioctl_ops();
+			time_t timeout;
 			time_t runfreq;
 
 			cache_unlock(vmc);
@@ -428,9 +429,10 @@ static void do_readmap_mount(struct autofs_point *ap, struct mnt_list *mnts,
 			cache_set_ino_index(vmc, me->key, me->dev, me->ino);
 			cache_unlock(vmc);
 			/* Set timeout and calculate the expire run frequency */
-			ops->timeout(ap->logopt, valid->ioctlfd, map->exp_timeout);
-			if (map->exp_timeout) {
-				runfreq = (map->exp_timeout + CHECK_RATIO - 1) / CHECK_RATIO;
+			timeout = get_exp_timeout(ap, map);
+			ops->timeout(ap->logopt, valid->ioctlfd, timeout);
+			if (timeout) {
+				runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
 				if (ap->exp_runfreq)
 					ap->exp_runfreq = min(ap->exp_runfreq, runfreq);
 				else
@@ -442,7 +444,7 @@ static void do_readmap_mount(struct autofs_point *ap, struct mnt_list *mnts,
 			debug(ap->logopt,
 			      "%s is mounted", me->key);
 	} else
-		do_mount_autofs_direct(ap, mnts, me, map->exp_timeout);
+		do_mount_autofs_direct(ap, mnts, me, get_exp_timeout(ap, map));
 
 	return;
 }
@@ -491,7 +493,7 @@ static void *do_readmap(void *arg)
 
 	if (ap->type == LKP_INDIRECT) {
 		struct ioctl_ops *ops = get_ioctl_ops();
-		time_t timeout = ap->entry->maps->exp_timeout;
+		time_t timeout = get_exp_timeout(ap, ap->entry->maps);
 		ap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
 		ops->timeout(ap->logopt, ap->ioctlfd, timeout);
 		lookup_prune_cache(ap, now);
include/automount.h +1 -0
index eb4fcc4..39e685d 100644
@@ -551,6 +551,7 @@ struct autofs_point {
 	dev_t dev;			/* "Device" number assigned by kernel */
 	struct master_mapent *entry;	/* Master map entry for this mount */
 	unsigned int type;		/* Type of map direct or indirect */
+	time_t exp_timeout;		/* Indirect mount expire timeout */
 	time_t exp_runfreq;		/* Frequency for polling for timeouts */
 	time_t negative_timeout;	/* timeout in secs for failed mounts */
 	unsigned int flags;		/* autofs mount flags */
include/mounts.h +2 -0
index 8425818..031e2a3 100644
@@ -111,6 +111,8 @@ int tree_find_mnt_ents(struct mnt_list *mnts, struct list_head *list, const char
 int tree_is_mounted(struct mnt_list *mnts, const char *path, unsigned int type);
 void set_tsd_user_vars(unsigned int, uid_t, gid_t);
 const char *mount_type_str(unsigned int);
+void set_exp_timeout(struct autofs_point *ap, struct map_source *source, time_t timeout);
+time_t get_exp_timeout(struct autofs_point *ap, struct map_source *source);
 void notify_mount_result(struct autofs_point *, const char *, time_t, const char *);
 int try_remount(struct autofs_point *, struct mapent *, unsigned int);
 void set_indirect_mount_tree_catatonic(struct autofs_point *);
lib/master.c +4 -1
index 3f91808..142f97e 100644
@@ -99,6 +99,7 @@ int master_add_autofs_point(struct master_mapent *entry, unsigned logopt,
 		ap->negative_timeout = defaults_get_negative_timeout();
 	else
 		ap->negative_timeout = global_negative_timeout;
+	ap->exp_timeout = defaults_get_timeout();
 	ap->exp_runfreq = 0;
 	ap->flags = 0;
 	if (ghost)
@@ -981,6 +982,7 @@ static void master_add_amd_mount_section_mounts(struct master *master, time_t ag
 	while (paths[i]) {
 		const char *path = paths[i];
 		unsigned int ghost = 0;
+		time_t timeout;
 		char *type = NULL;
 		char *map = NULL;
 		char *opts;
@@ -1066,7 +1068,8 @@ static void master_add_amd_mount_section_mounts(struct master *master, time_t ag
 			goto next;
 		}
 
-		source->exp_timeout = conf_amd_get_dismount_interval(path);
+		timeout = conf_amd_get_dismount_interval(path);
+		set_exp_timeout(entry->ap, source, timeout);
 		source->master_line = 0;
 
 		entry->age = age;
lib/master_parse.y +13 -14
index 29bc3fc..42e03c2 100644
@@ -828,19 +828,6 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
 			ghost = 1;
 	}
 
-	if (timeout < 0) {
-		/*
-		 * If no timeout is given get the timout from the
-		 * first map (if it exists) or the config for amd
-		 * maps.
-		 */
-		if (format && !strcmp(format, "amd"))
-			timeout = conf_amd_get_dismount_interval(path);
-		else if (entry->maps)
-			timeout = entry->maps->exp_timeout;
-		else
-			timeout = default_timeout;
-	}
 
 	if (!entry->ap) {
 		ret = master_add_autofs_point(entry, logopt, nobind, ghost, 0);
@@ -863,6 +850,18 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
 	if (mode && mode < LONG_MAX)
 		entry->ap->mode = mode;
 
+	if (timeout < 0) {
+		/*
+		 * If no timeout is given get the timout from the
+		 * autofs point, or the first map, or the config
+		 * for amd maps.
+		 */
+		if (format && !strcmp(format, "amd"))
+			timeout = conf_amd_get_dismount_interval(path);
+		else
+			timeout = get_exp_timeout(entry->ap, entry->maps);
+	}
+
 	if (format && !strcmp(format, "amd")) {
 		char *opts = conf_amd_get_map_options(path);
 		if (opts) {
@@ -897,7 +896,7 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
 		local_free_vars();
 		return 0;
 	}
-	source->exp_timeout = timeout;
+	set_exp_timeout(entry->ap, source, timeout);
 	source->master_line = lineno;
 
 	entry->age = age;
lib/mounts.c +21 -6
index a9be906..22d653e 100644
@@ -1578,6 +1578,24 @@ const char *mount_type_str(const unsigned int type)
 	return (pos == type_count ? NULL : str_type[pos]);
 }
 
+void set_exp_timeout(struct autofs_point *ap,
+		     struct map_source *source, time_t timeout)
+{
+	ap->exp_timeout = timeout;
+	if (source)
+		source->exp_timeout = timeout;
+}
+
+time_t get_exp_timeout(struct autofs_point *ap, struct map_source *source)
+{
+	time_t timeout = ap->exp_timeout;
+
+	if (source && ap->type == LKP_DIRECT)
+		timeout = source->exp_timeout;
+
+	return timeout;
+}
+
 void notify_mount_result(struct autofs_point *ap,
 			 const char *path, time_t timeout, const char *type)
 {
@@ -1709,12 +1727,9 @@ static int remount_active_mount(struct autofs_point *ap,
 	ops->open(ap->logopt, &fd, devid, path);
 	if (fd == -1)
 		return REMOUNT_OPEN_FAIL;
-	else {
-		if (type == t_indirect || type == t_offset)
-			timeout = ap->entry->maps->exp_timeout;
-		else
-			timeout = me->source->exp_timeout;
-	}
+
+	error(ap->logopt, "ap->type %d type %u", ap->type, type);
+	timeout = get_exp_timeout(ap, me->source);
 
 	/* Re-reading the map, set timeout and return */
 	if (ap->state == ST_READMAP) {
modules/mount_autofs.c +4 -8
index 20bcd11..be9d51d 100644
@@ -57,7 +57,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 	int nobind = ap->flags & MOUNT_FLAG_NOBIND;
 	int ghost = ap->flags & MOUNT_FLAG_GHOST;
 	int symlnk = ap->flags & MOUNT_FLAG_SYMLINK;
-	time_t timeout = ap->entry->maps->exp_timeout;
+	time_t timeout = get_exp_timeout(ap, ap->entry->maps);
 	unsigned logopt = ap->logopt;
 	struct map_type_info *info;
 	struct master *master;
@@ -273,13 +273,9 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 		return 1;
 	}
 	free_map_type_info(info);
-	/* The exp_timeout can't be inherited if the map is shared, so
-	 * the autofs point exp_runfreq must be set here.
-	 */
-	if (source->ref <= 1)
-		source->exp_timeout = timeout;
-	else
-		nap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
+
+	set_exp_timeout(nap, NULL, timeout);
+	nap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
 
 	mounts_mutex_lock(ap);
 

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#29 lore raw

PATCH 29/34 autofs-5.1.2 - fix possible NULL derefernce

In reply to Ian Kent

In modules/mount_autofs.c:mount_mount() a NULL pointer dereference is (unlikley but) possible.

---
 CHANGELOG              |    1 +
 modules/mount_autofs.c |   15 +++++++++------
 2 files changed, 10 insertions(+), 6 deletions(-)
CHANGELOG +1 -0
index 1a4a8d9..2dceb69 100644
@@ -55,6 +55,7 @@ xx/xx/2016 autofs-5.1.3
 - factor out set_thread_mount_request_log_id().
 - add config option to use mount request log id.
 - use autofs_point to store expire timeout where possibe.
+- fix possible NULL derefernce.
 
 15/06/2016 autofs-5.1.2
 =======================
modules/mount_autofs.c +9 -6
index be9d51d..076ab85 100644
@@ -281,13 +281,16 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
 
 	if (source->flags & MAP_FLAG_FORMAT_AMD) {
 		struct amd_entry *am_entry = __master_find_amdmount(ap, entry->path);
-		if (am_entry && am_entry->pref) {
-			nap->pref = am_entry->pref;
-			am_entry->pref = NULL;
-		}
 
-		if (am_entry->cache_opts & AMD_CACHE_OPTION_ALL)
-			nap->flags |= MOUNT_FLAG_AMD_CACHE_ALL;
+		if (am_entry) {
+			if (am_entry->pref) {
+				nap->pref = am_entry->pref;
+				am_entry->pref = NULL;
+			}
+
+			if (am_entry->cache_opts & AMD_CACHE_OPTION_ALL)
+				nap->flags |= MOUNT_FLAG_AMD_CACHE_ALL;
+		}
 	}
 
 	if (handle_mounts_startup_cond_init(&suc)) {

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#30 lore raw

PATCH 30/34 autofs-5.1.2 - fix work around sss startup delay

In reply to Ian Kent

If a sss startup delay has been configured to non-zero autofs will wait up to the configured time and return NSS_STATUS_UNAVAIL or NSS_STATUS_NOTFOUND even if setautomntent_wait() returns success.

---
 CHANGELOG            |    1 +
 modules/lookup_sss.c |    8 +++++---
 2 files changed, 6 insertions(+), 3 deletions(-)
CHANGELOG +1 -0
index 2dceb69..7700a20 100644
@@ -56,6 +56,7 @@ xx/xx/2016 autofs-5.1.3
 - add config option to use mount request log id.
 - use autofs_point to store expire timeout where possibe.
 - fix possible NULL derefernce.
+- fix work around sss startup delay.
 
 15/06/2016 autofs-5.1.2
 =======================
modules/lookup_sss.c +5 -3
index 6d924cf..15a5ca4 100644
@@ -309,9 +309,11 @@ int lookup_read_master(struct master *master, time_t age, void *context)
 		ret = setautomntent_wait(logopt,
 					 ctxt, ctxt->mapname, &sss_ctxt,
 					 retries);
-		if (ret == ENOENT)
-			return NSS_STATUS_NOTFOUND;
-		return NSS_STATUS_UNAVAIL;
+		if (ret) {
+			if (ret == ENOENT)
+				return NSS_STATUS_NOTFOUND;
+			return NSS_STATUS_UNAVAIL;
+		}
 	}
 
 	count = 0;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#31 lore raw

PATCH 31/34 autofs-5.1.2 - fix invalid reference in remount_active_mount()

In reply to Ian Kent

remount_active_mount() can be called with the map entry pointer NULL so it must be checked before use when getting the automount timeout.

---
 CHANGELOG    |    1 +
 lib/mounts.c |    6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)
CHANGELOG +1 -0
index 7700a20..b7c5a62 100644
@@ -57,6 +57,7 @@ xx/xx/2016 autofs-5.1.3
 - use autofs_point to store expire timeout where possibe.
 - fix possible NULL derefernce.
 - fix work around sss startup delay.
+- fix invalid reference in remount_active_mount().
 
 15/06/2016 autofs-5.1.2
 =======================
lib/mounts.c +4 -2
index 22d653e..76ff006 100644
@@ -1728,8 +1728,10 @@ static int remount_active_mount(struct autofs_point *ap,
 	if (fd == -1)
 		return REMOUNT_OPEN_FAIL;
 
-	error(ap->logopt, "ap->type %d type %u", ap->type, type);
-	timeout = get_exp_timeout(ap, me->source);
+	if (!me)
+		timeout = get_exp_timeout(ap, NULL);
+	else
+		timeout = get_exp_timeout(ap, me->source);
 
 	/* Re-reading the map, set timeout and return */
 	if (ap->state == ST_READMAP) {

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#32 lore raw

PATCH 32/34 autofs-5.1.2 - use malloc for expanded map location

In reply to Ian Kent

Change the allocation of temporary mount location storage in the sun parser to use malloc(3) instead of alloca(3) and refactor a little.

---
 CHANGELOG           |    1 +
 modules/parse_sun.c |   65 ++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 50 insertions(+), 16 deletions(-)
CHANGELOG +1 -0
index b7c5a62..1ea69d5 100644
@@ -58,6 +58,7 @@ xx/xx/2016 autofs-5.1.3
 - fix possible NULL derefernce.
 - fix work around sss startup delay.
 - fix invalid reference in remount_active_mount().
+- use malloc for expanded map location.
 
 15/06/2016 autofs-5.1.2
 =======================
modules/parse_sun.c +49 -16

215 lines not on this page · raw message

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#33 lore raw

PATCH 33/34 autofs-5.1.2 - fix offset mount location multiple expansion

In reply to Ian Kent

When parsing an offset map entry mount location it shouldn't be expanded because it will have already been dequoted before being added to the map entry cache when it was first parsed.

Expanding it again can lead to inconsistent behaviour between the expansion of simple map entry locations and offset locations that have had quoting removed as part of the initial parse.

---
 CHANGELOG           |    1 +
 modules/parse_sun.c |   25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)
CHANGELOG +1 -0
index 1ea69d5..46487f1 100644
@@ -59,6 +59,7 @@ xx/xx/2016 autofs-5.1.3
 - fix work around sss startup delay.
 - fix invalid reference in remount_active_mount().
 - use malloc for expanded map location.
+- fix offset mount location multiple expansion.
 
 15/06/2016 autofs-5.1.2
 =======================
modules/parse_sun.c +25 -0
index 8955c84..536a9bc 100644
@@ -1297,6 +1297,30 @@ int parse_mount(struct autofs_point *ap, const char *name,
 
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
 
+	/* Offset map entries have been expanded already, avoid expanding
+	 * them again so that the quote handling is consistent between map
+	 * entry locations and (previously expanded) offset map entry
+	 * locations.
+	 */
+	if (*name == '/') {
+		cache_readlock(mc);
+		me = cache_lookup_distinct(mc, name);
+		if (me && me->multi && me->multi != me) {
+			cache_unlock(mc);
+			mapent_len = strlen(mapent) + 1;
+			pmapent = malloc(mapent_len + 1);
+			if (!pmapent) {
+				char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
+				logerr(MODPREFIX "malloc: %s", estr);
+				return 1;
+			}
+			memset(pmapent, 0, mapent_len + 1);
+			strcpy(pmapent, mapent);
+			goto dont_expand;
+		}
+		cache_unlock(mc);
+	}
+
 	macro_lock();
 	ctxt->subst = addstdenv(ctxt->subst, NULL);
 
@@ -1313,6 +1337,7 @@ int parse_mount(struct autofs_point *ap, const char *name,
 	ctxt->subst = removestdenv(ctxt->subst, NULL);
 	macro_unlock();
 
+dont_expand:
 	pthread_setcancelstate(cur_state, NULL);
 
 	debug(ap->logopt, MODPREFIX "expanded entry: %s", pmapent);

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

author maintainer
#34 lore raw

PATCH 34/34 autofs-5.1.2 - increase worker thread per-thread stack size

In reply to Ian Kent

automount(8) uses a worker thread per-thread stack size of 1M which is sufficient for its needs.

But some glibc functions (such as nscd_getgr_r()) use alloca() to allocate working storage that can have an arbitary size. Since alloca() never fails there is no way to check for stack overflow so I think this usage is wrong and needs to be fixed.

All that can be done by automount to avoid this is to increase the stack size.

---
 CHANGELOG          |    1 +
 daemon/automount.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
CHANGELOG +1 -0
index 46487f1..a2a22ce 100644
@@ -60,6 +60,7 @@ xx/xx/2016 autofs-5.1.3
 - fix invalid reference in remount_active_mount().
 - use malloc for expanded map location.
 - fix offset mount location multiple expansion.
+- increase worker thread per-thread stack size.
 
 15/06/2016 autofs-5.1.2
 =======================
daemon/automount.c +1 -1
index d27804d..109f8f9 100644
@@ -2476,7 +2476,7 @@ int main(int argc, char *argv[])
 
 #ifdef _POSIX_THREAD_ATTR_STACKSIZE
 	if (pthread_attr_setstacksize(
-			&th_attr_detached, PTHREAD_STACK_MIN*64)) {
+			&th_attr_detached, PTHREAD_STACK_MIN*128)) {
 		logerr("%s: failed to set stack size thread attribute!",
 		       program);
 		res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));

--
To unsubscribe from this list: send the line "unsubscribe autofs" in