Skip to contentSkip to conversation

Patches to autofs 4.1.4 daemon to speed some things up and increase robustness

PATCH New Bill Ryder 1 participant 9 messages Dec 14, 2010 – Jan 13, 2011

Subsystems (3)
lore
Share & tools
lore

Bill Ryder

author
#0 lore raw

cover Patches to autofs 4.1.4 daemon to speed some things up and increase robustness

I'm releasing these patches for anyone still using the old autofs 4.1.4 daemon.

We still use autofs 4.1.4 where I work.

We have over 4,000 nfs clients using automounter (maps held in LDAP). We use simple indirect maps. In other words I've only tested LDAP with simple maps on nfs.

We have found many ways to make fileservers suffer from major performance problems.

Our preferred behaviour is for the automounter to keep trying to mount a location until the fileserver becomes less busy. Otherwise we have to deal with the fallout from EEXIST errors.

Along the way I've found other stuff which I've included (some of which only matters because the 4.1.4 daemon forks full processes rather than using threads).

I have included some other people's patches and have attributed them to the person I think did the patch in the first place. Apologies if I've got it wrong!

This published set is meant to clearly publish the work I've done - but include the bare minimum patches to autofs-4.1.4.tar.gz (from
http://www.kernel.org/pub/linux/daemons/autofs/v4/)
so that my stuff works and so it's clear what my patches do.

I've included CHANGELOG entries for each patch which hopefully explains what I've done for each patch.

However, I use a bunch more patches from the redhat rpms and some from kernel.org. A current picture of what I really use is available from
https://github.com/bryder/bryder_autofs414

So if you wanted to try this out - github is the place to get it from.

Bill Ryder (8):
Added the dumpmap option and updated manpage - I didn't write this Set LDAP_DEPRECATED to prevent coredumps with modern ldap libraries Added function names to some debug/crit messages, changed some crits
to debug
reinstated the jmoyer ldap-cleanup patch and included man etc updates Added option to ignore some highly unlikely paths before forking
daemon
Adds options to retry nfs mounts on certain nfs errors
Ian Kent's reentrant syslog patch
Fix race which would stop a daemon under high mount rates with
failures

author
#1 lore raw

PATCH 1/8 Added the dumpmap option and updated manpage

---
 CHANGELOG           |    8 ++++++++
 daemon/automount.c  |   21 +++++++++++++++++++--
 include/automount.h |    3 +++
 lib/cache.c         |   10 ++++++++++
 man/automount.8     |    3 +++
 5 files changed, 43 insertions(+), 2 deletions(-)
CHANGELOG +8 -0
index e9dbb63..467e90a 100644
@@ -1,3 +1,11 @@
+16/6/2010 autofs-4.1.4 - bryder p37
+-------------------------
+Moved the autofs-4.1.3 version of the dump map patch to 4.1.4 (without the lookup_files hack)
+It adds the --dumpmap or -D argument to dump maps read by the daemon - then the daemon exits. 
+Also help to the automount.c command for this option and updated the man page.
+Only tested with LDAP.
+
+
 11/4/2005 autofs-4.1.4
 ----------------------
 - add /proc/modules check to Debian init script.
daemon/automount.c +19 -2
index bbcab6a..93e3ff7 100644
@@ -55,6 +55,7 @@ static char *pid_file = NULL;	/* File in which to keep pid */
 
 int kproto_version;		/* Kernel protocol version used */
 int kproto_sub_version = 0;	/* Kernel protocol version used */
+int dumpmap = 0;		/* cmdline arg to dump map contents */
 
 static int submount = 0;
 
@@ -1380,6 +1381,8 @@ static unsigned long getnumopt(char *str, char option)
 static void usage(void)
 {
 	fprintf(stderr, "Usage: %s [options] path map_type [args...]\n", program);
+	fprintf(stderr, "   -D|--dumpmap dumps out the maps read and exits\n");
+
 }
 
 static void setup_signals(__sighandler_t event_handler, __sighandler_t cld_handler)
@@ -1671,6 +1674,7 @@ int main(int argc, char *argv[])
 		{"version", 0, 0, 'V'},
 		{"ghost", 0, 0, 'g'},
 		{"submount", 0, &submount, 1},
+		{"dumpmap", 0, 0, 'D'},
 		{0, 0, 0, 0}
 	};
 
@@ -1683,7 +1687,7 @@ int main(int argc, char *argv[])
 	ap.dir_created = 0; /* We haven't created the main directory yet */
 
 	opterr = 0;
-	while ((opt = getopt_long(argc, argv, "+hp:t:vdVg", long_options, NULL)) != EOF) {
+	while ((opt = getopt_long(argc, argv, "+hp:t:vdVgD", long_options, NULL)) != EOF) {
 		switch (opt) {
 		case 'h':
 			usage();
@@ -1713,6 +1717,9 @@ int main(int argc, char *argv[])
 			ap.ghost = LKP_GHOST;
 			break;
 
+		case 'D':
+			dumpmap = 1;
+			break;
 		case '?':
 		case ':':
 			printf("%s: Ambiguous or unknown options\n", program);
@@ -1734,7 +1741,8 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	become_daemon();
+	if (!dumpmap)
+		become_daemon();
 
 	path = argv[0];
 	map = argv[1];
@@ -1762,6 +1770,15 @@ int main(int argc, char *argv[])
 	if (!(ap.lookup = open_lookup(map, "", mapfmt, mapargc, mapargv)))
 		cleanup_exit(path, 1);
 
+	if (dumpmap) {
+		int ret;
+		ret = ap.lookup->lookup_ghost(ap.path, ap.ghost,
+					      0, ap.lookup->context);
+		if (ret & LKP_FAIL)
+			exit(ret);
+		exit(0);
+	}
+
 	if (!strncmp(path, "/-", 2)) {
 		supervisor(path);
 	} else {
include/automount.h +3 -0
index d2f5d70..64ff83d 100644
@@ -286,6 +286,9 @@ int allow_owner_mount(const char *);
 extern int do_verbose;
 extern int do_debug;
 
+/* command line option to print out included map contents */
+extern int dumpmap;
+
 #define info(msg, args...) 		\
 if (do_verbose || do_debug) 		\
 	syslog(LOG_INFO, msg, ##args);
lib/cache.c +10 -0
index 781c980..5a01079 100644
@@ -169,6 +169,11 @@ int cache_add(const char *root, const char *key, const char *mapent, time_t age)
 	char *pkey, *pent;
 	unsigned int hashval = hash(key);
 
+	if (dumpmap) {
+		fprintf(stdout, "%s %s\n", key, mapent);
+		return CHE_OK;
+	}
+
 	me = (struct mapent_cache *) malloc(sizeof(struct mapent_cache));
 	if (!me)
 		return CHE_FAIL;
@@ -221,6 +226,11 @@ int cache_update(const char *root, const char *key, const char *mapent, time_t a
 	char *pent;
 	int ret = CHE_OK;
 
+	if (dumpmap) {
+		fprintf(stdout, "%s %s\n", key, mapent);
+		return CHE_OK;
+	}
+
 	for (s = mapent_hash[hash(key)]; s != NULL; s = s->next)
 		if (strcmp(key, s->key) == 0)
 			me = s;
man/automount.8 +3 -0
index 2b63959..e640656 100644
@@ -43,6 +43,9 @@ until accesssed. The wildcard map is not ghosted.
 .TP
 .I "\-V, \-\-version"
 Display the version number, then exit.
+.TP
+.I "\-D, \-\-dumpmap"
+Dumps the maps read and exits.
 .SH ARGUMENTS
 \fBautomount\fP takes at least three arguments.  Mandatory arguments 
 include \fImount-point\fP, \fImap-type\fP, and \fImap\fP.  Both mandatory
Signature · 1 line
1.7.3.3
author
#2 lore raw

PATCH 2/8 Set LDAP_DEPRECATED to prevent coredumps with modern ldap libraries

In reply to Bill Ryder
---
 CHANGELOG        |    5 +++++
 configure.in     |    1 +
 samples/Makefile |    2 +-
 3 files changed, 7 insertions(+), 1 deletions(-)
CHANGELOG +5 -0
index 467e90a..9dd8185 100644
@@ -1,3 +1,8 @@
+17/6/2010 autofs-4.1.4 - bryder p38
+---------------------------
+Added LDAP patch to stop the autofs-ldap-auto-master and lookup_ldap.so from crashing on modern ldap libraries. 
+It sets the LDAP_DEPRECATED macro to 1. Obviously the ldap stuff needs some updating.
+
 16/6/2010 autofs-4.1.4 - bryder p37
 -------------------------
 Moved the autofs-4.1.3 version of the dump map patch to 4.1.4 (without the lookup_files hack)
configure.in +1 -0
index eb56ac7..623e92b 100644
@@ -118,6 +118,7 @@ AC_ARG_WITH(openldap,
 )
 if test -z "$HAVE_LDAP"; then
 	HAVE_LDAP=0
+	LDAP_FLAGS="$LDAP_FLAGS -DLDAP_DEPRECATED=1"
 	AC_CHECK_LIB(ldap, ldap_init, HAVE_LDAP=1 LIBLDAP="$LIBLDAP -lldap -llber -lresolv", ,
 		     -llber -lresolv $LIBS)
 fi
samples/Makefile +1 -1
index d69d6e7..f5aa2ba 100644
@@ -16,7 +16,7 @@ LIBS = -lldap -llber
 all: $(BINS) rc.autofs
 
 autofs-ldap-auto-master: $(OBJS)
-	$(CC) $(LDFLAGS) -o autofs-ldap-auto-master $(OBJS) $(LIBS)
+	$(CC) $(LDFLAGS) $(LDAP_FLAGS) -o autofs-ldap-auto-master $(OBJS) $(LIBS)
 	$(STRIP) autofs-ldap-auto-master
 
 rc.autofs: rc.autofs.in
Signature · 1 line
1.7.3.3
author
#3 lore raw

PATCH 3/8 Added function names to some debug/crit messages, changed some crits to debug

In reply to Bill Ryder
---
 CHANGELOG             |   10 +++++++-
 modules/lookup_ldap.c |   64 +++++++++++++++++++++++++-----------------------
 2 files changed, 42 insertions(+), 32 deletions(-)
CHANGELOG +9 -1
index 9dd8185..c40a670 100644
@@ -1,5 +1,13 @@
+
+18/6/2010 autofs-4.1.4 - bryder p39
+-----------------------------------
+Added the function name to the lookup_ldap debug and critical messages. 
+Also made a couple of the 'crit' messages 'debug' messages because they are not actually critical. 
+They just show a failed search.
+
+
 17/6/2010 autofs-4.1.4 - bryder p38
----------------------------
+--------------------------
 Added LDAP patch to stop the autofs-ldap-auto-master and lookup_ldap.so from crashing on modern ldap libraries. 
 It sets the LDAP_DEPRECATED macro to 1. Obviously the ldap stuff needs some updating.
 
modules/lookup_ldap.c +33 -31

222 lines not on this page · raw message

Signature · 1 line
1.7.3.3
author
#4 lore raw

PATCH 4/8 reinstated the jmoyer ldap-cleanup patch and included man etc updates

In reply to Bill Ryder
---
 CHANGELOG             |    9 ++
 daemon/automount.c    |    8 +-
 include/automount.h   |    1 +
 man/automount.8       |    8 ++
 modules/lookup_ldap.c |  275 ++++++++++++++++++++++++++++++++-----------------
 5 files changed, 206 insertions(+), 95 deletions(-)
CHANGELOG +9 -0
index c40a670..04043c5 100644
@@ -1,3 +1,10 @@
+29/06/2010 autofs-4.1.4-p40
+---------------------------
+  Reinstates the jmoyer ldap-cleanup.patch from 4.1.3 which does cleaner LDAP schema handling. 
+  It only looks up the schema once and then remembers it for every requested path under a mount point.
+  It  includes the --use_old_ldap_lookup or -u option to make the code search every schema every time the way it used to.
+  bryder changed the original patch is to invert the search order so the most modern schema (rfc2307bis) is checked first
+  bryder added the option to the man page and help output from automount.c
 
 18/6/2010 autofs-4.1.4 - bryder p39
 -----------------------------------
@@ -19,6 +26,8 @@ Also help to the automount.c command for this option and updated the man page.
 Only tested with LDAP.
 
 
+
+
 11/4/2005 autofs-4.1.4
 ----------------------
 - add /proc/modules check to Debian init script.
daemon/automount.c +6 -2
index 93e3ff7..0ef9cbb 100644
@@ -1382,7 +1382,7 @@ static void usage(void)
 {
 	fprintf(stderr, "Usage: %s [options] path map_type [args...]\n", program);
 	fprintf(stderr, "   -D|--dumpmap dumps out the maps read and exits\n");
-
+	fprintf(stderr, "   -u|--use-old-ldap-lookup instead of figuring out the schema once do it every single time a mount is requested. This is the old behaviour\n");
 }
 
 static void setup_signals(__sighandler_t event_handler, __sighandler_t cld_handler)
@@ -1675,6 +1675,7 @@ int main(int argc, char *argv[])
 		{"ghost", 0, 0, 'g'},
 		{"submount", 0, &submount, 1},
 		{"dumpmap", 0, 0, 'D'},
+		{"use-old-ldap-lookup", 0, 0, 'u'},
 		{0, 0, 0, 0}
 	};
 
@@ -1687,7 +1688,7 @@ int main(int argc, char *argv[])
 	ap.dir_created = 0; /* We haven't created the main directory yet */
 
 	opterr = 0;
-	while ((opt = getopt_long(argc, argv, "+hp:t:vdVgD", long_options, NULL)) != EOF) {
+	while ((opt = getopt_long(argc, argv, "+hp:t:vdVgDu", long_options, NULL)) != EOF) {
 		switch (opt) {
 		case 'h':
 			usage();
@@ -1720,6 +1721,9 @@ int main(int argc, char *argv[])
 		case 'D':
 			dumpmap = 1;
 			break;
+		case 'u':
+			ap.use_old_ldap_lookup = 1;
+			break;
 		case '?':
 		case ':':
 			printf("%s: Ambiguous or unknown options\n", program);
include/automount.h +1 -0
index 64ff83d..fa97764 100644
@@ -113,6 +113,7 @@ struct autofs_point {
 	int state_pipe[2];
 	unsigned dir_created;		/* Was a directory created for this
 					   mount? */
+	unsigned use_old_ldap_lookup;   /* query all schemas every time instead of sticking with the first one found */
 };
 
 extern struct autofs_point ap; 
man/automount.8 +8 -0
index e640656..5dc597b 100644
@@ -46,6 +46,14 @@ Display the version number, then exit.
 .TP
 .I "\-D, \-\-dumpmap"
 Dumps the maps read and exits.
+.TP
+.I "\-u, \-\-use\-old\-ldap\-lookup"
+By default automount will use new code for finding the correct ldap
+schema. It starts with rfc2307bis, then does the netscape one, then
+the original rfc2307 schema. It only checks once for each mount point
+and remembers the schema for the rest of the automount invocation.
+If you set this flag it will do it the old way which involves looking
+for the schema every time a mount is requested.
 .SH ARGUMENTS
 \fBautomount\fP takes at least three arguments.  Mandatory arguments 
 include \fImount-point\fP, \fImap-type\fP, and \fImap\fP.  Both mandatory
modules/lookup_ldap.c +182 -93

499 lines not on this page · raw message

Signature · 1 line
1.7.3.3
author
#5 lore raw

PATCH 5/8 Added option to ignore some highly unlikely paths before forking daemon

In reply to Bill Ryder
---
 CHANGELOG           |   35 +++++++++++++++++++++++++++++++++++
 daemon/automount.c  |   51 ++++++++++++++++++++++++++++++++++++++++++++++++---
 include/automount.h |    5 +++++
 man/automount.8     |   10 ++++++++++
 4 files changed, 98 insertions(+), 3 deletions(-)
CHANGELOG +35 -0
index 04043c5..9b0a418 100644
@@ -1,3 +1,38 @@
+01/07/2010 autofs-4.1.4 - bryder p41
+---------------------------
+ Adds the -I or --ignore-stupid-paths option.
+ 
+ The kernel nicely formats the path to mount up so that there are no extraneous dots or anything in it.
+ And it's just the part relative to the top level automount that gets passed to the daemon.
+ 
+ The -I option makes the automount daemon  return a fail to the kernel for any path with a '*' in it or 
+ if the path begins with a dot or if the path matches 'automount(pid'. 
+
+ It does this before it forks so it's very fast.
+
+ The odds are very good that no legimate path will be ignored. It's definitely true for my case but
+ YMMV.
+
+ The '*' paths are bad when you use ldap because it will match a lot of mount 
+ points and the first entry returned by the ldap search will be mounted  as /toplevelthing/*. 
+ 
+ The .blahblah paths are excluded because when serving NFS out to OSX and Windows via SAMBA 
+ we've found that OSX in particular will try to open a .directoryname for every directoryname 
+ in a mountpoint when browsing. This can be slow  when ghosting is on and you have a lot of 
+ mount points. Using this option it takes 0.001s more or less  to return a fail, without 
+ it it takes around 0.04s on the machine I tested. Mainly because the autmounter  forks before 
+ looking up the path. So 140 directories will delay you around 6s when a finder 
+ visits that top level automounter with that many entries. The 5.x automounter daemon doesn't fork so 
+ this is no such a big problem.
+
+ The 'automount(pid' path was added because samba will look for this path when it tries to get 
+ quotas on mount points.  I know I should fix samba but for now I'm adding it to the hacks 
+ I've already done for stupid paths. 
+
+ Ideally the automounter would have a list of regexes to ignore passed by command line option or config file 
+ but this patch hardcodes them.
+
+ 
 29/06/2010 autofs-4.1.4-p40
 ---------------------------
   Reinstates the jmoyer ldap-cleanup.patch from 4.1.3 which does cleaner LDAP schema handling. 
daemon/automount.c +48 -3

93 lines not on this page · raw message

include/automount.h +5 -0
index fa97764..46bc504 100644
@@ -114,6 +114,11 @@ struct autofs_point {
 	unsigned dir_created;		/* Was a directory created for this
 					   mount? */
 	unsigned use_old_ldap_lookup;   /* query all schemas every time instead of sticking with the first one found */
+	unsigned ignore_stupid_paths;   /* Ignores mount keys that will never occur at my site and which slow
+                                         * everything down or lead to 'interesting' results 
+					 * See automount.c:is_path_stupid for details
+					 */
+ 
 };
 
 extern struct autofs_point ap; 
man/automount.8 +10 -0
index 5dc597b..d242f58 100644
@@ -54,6 +54,16 @@ the original rfc2307 schema. It only checks once for each mount point
 and remembers the schema for the rest of the automount invocation.
 If you set this flag it will do it the old way which involves looking
 for the schema every time a mount is requested.
+.TP
+.I "\-I, \-\-ignore\-stupid\-paths"
+The automounter will return 'not found' for any key which contains '*' or
+starts with a dot. Ignoring '*' stops undefined results being returned when
+you use ldap. Ignoring the leading '.' is
+useful for macs and Windows when they look for metadata directories
+which typically do not exist in the root of an automount tree to help
+increase browse speed at the top of large trees of mount points.
+It will also ignore paths containing 'autmount(pid'. This is to stop
+lookups when samba asks for these paths which do not exist of course.
 .SH ARGUMENTS
 \fBautomount\fP takes at least three arguments.  Mandatory arguments 
 include \fImount-point\fP, \fImap-type\fP, and \fImap\fP.  Both mandatory
Signature · 1 line
1.7.3.3
author
#6 lore raw

PATCH 6/8 Adds options to retry nfs mounts on certain nfs errors

In reply to Bill Ryder
---
 CHANGELOG           |   32 ++++++++++++++++
 daemon/automount.c  |   21 +++++++++--
 daemon/spawn.c      |   64 +++++++++++++++++++++++++++++++-
 include/automount.h |    7 ++++
 man/automount.8     |   45 +++++++++++++++++++++++
 modules/mount_nfs.c |  100 ++++++++++++++++++++++++++++++++++++++-------------
 6 files changed, 239 insertions(+), 30 deletions(-)
CHANGELOG +32 -0
index 9b0a418..bbf4d3d 100644
@@ -1,3 +1,35 @@
+14/07/2010 autofs-4.1.4 - bryder p42
+------------------------------------
+ Adds retrying to nfs mounts. 
+
+ Originally written to handle overloaded fileservers which is common
+ for us.   It's better for us if the automounter takes a long time to
+ mount a mount point than to return a 'not found' error just because
+ the fileserver was too busy to respond in a small amount of time. 
+
+ As a convenience (so we don't have to use the 'insecure' option on
+ the NFS server) it  also retries if the number of local secure ports
+ is exhausted. Some  jobs we run will mount up 100 fileservers at once
+ which will usually  trigger this error. It is a transient error so
+ the retry succeeds.
+
+ It works by reading the error returned from mount. Some of
+ these errors may be actual permanent failures so it will take longer
+ before it fails. Use the options to control the retries.
+ 
+   "RPC: Remote system error - Connection refused", /* heavy fileserver load */
+   "RPC: Timed out", /* heavy fileserver load */
+   "RPC: Remote system error - Connection timed out", /* heavy fileserver load */
+   "Input/output error", /* too many mounts starting at once on a client  - centos 2.6.18 */
+   "can't read superblock", /* too many mounts starting at once on a client - 2.6.25.18 and others */ 
+   "nfs bindresvport: Address already in use", /* too many mounts starting at once  - see in ubuntu 7.04 2.6.25.18 */
+   "mount system call failed",  /* too many mounts starting at once on a client - seen in 2.6.31.12 */
+   "server down",  /* Seen on ubuntu 7 with massive overload on a test fileserver  */
+
+ The options are --max-nfs-mount-retries|-R  and --nfs-mount-retry-pause|-P options
+ 
+ The pause is chosen at random between 1 second and the retry-pause amount + 1
+
 01/07/2010 autofs-4.1.4 - bryder p41
 ---------------------------
  Adds the -I or --ignore-stupid-paths option.
daemon/automount.c +18 -3
index 2509431..3567abf 100644
@@ -1424,6 +1424,7 @@ static void usage(void)
 	fprintf(stderr, "   -D|--dumpmap dumps out the maps read and exits\n");
 	fprintf(stderr, "   -u|--use-old-ldap-lookup instead of figuring out the schema once do it every single time a mount is requested. This is the old behaviour\n");
  	fprintf(stderr, "   -I|--ignore-stupid-paths will never lookup a requested path which contains the * character or which starts with a dot (.) \n");
+ 	fprintf(stderr, "   -R|--max-nfs-mount-retries <n> and -P|--nfs-mount-retry-pause <max secs> retres nfs mounts when certain error messages are seen. Default is no retry. pause is max seconds to wait (the pause is random from 1 to (pause+1) seconds\n");
 }
 
 static void setup_signals(__sighandler_t event_handler, __sighandler_t cld_handler)
@@ -1718,6 +1719,8 @@ int main(int argc, char *argv[])
 		{"dumpmap", 0, 0, 'D'},
 		{"use-old-ldap-lookup", 0, 0, 'u'},
 		{"ignore-stupid-paths", 0, 0, 'I'},
+		{"max-nfs-mount-retries", 1, 0, 'R'},
+		{"nfs-mount-retry-pause", 1, 0, 'P'}, /* This is in fact the maximum pause - 1s (ie the code will randomly sleep between 1 and retry-pause +1 seconds) */
 		{0, 0, 0, 0}
 	};
 
@@ -1730,8 +1733,8 @@ int main(int argc, char *argv[])
 	ap.dir_created = 0; /* We haven't created the main directory yet */
 
 	opterr = 0;
-	while ((opt = getopt_long(argc, argv, "+hp:t:vdVgDuI", long_options, NULL)) != EOF) {
-		switch (opt) {
+	while ((opt = getopt_long(argc, argv, "+hp:t:vdVgDuIR:P:", long_options, NULL)) != EOF) {
+	  switch (opt) {
 		case 'h':
 			usage();
 			exit(0);
@@ -1769,13 +1772,25 @@ int main(int argc, char *argv[])
 		case 'I':
 			ap.ignore_stupid_paths = 1;
 			break;
+
+		case 'R':
+			ap.max_nfs_mount_retries =  getnumopt(optarg, opt);
+			break;
+
+		case 'P':
+			ap.nfs_mount_retry_pause =  getnumopt(optarg, opt);
+			break;
+
 		case '?':
 		case ':':
 			printf("%s: Ambiguous or unknown options\n", program);
 			exit(1);
 		}
 	}
-
+	/* Set this to a sane value even if it isn't used */
+	if (ap.nfs_mount_retry_pause <= 0){
+		ap.nfs_mount_retry_pause = 1;
+	}
 	if (geteuid() != 0) {
 		fprintf(stderr, "%s: This program must be run by root.\n", program);
 		exit(1);
daemon/spawn.c +62 -2

91 lines not on this page · raw message

include/automount.h +7 -0
index 46bc504..b09dd78 100644
@@ -119,6 +119,13 @@ struct autofs_point {
 					 * See automount.c:is_path_stupid for details
 					 */
  
+
+	unsigned max_nfs_mount_retries; /* number of times to retry a failed nfs mount if it 
+					 * returns specified error messages (see mount_nfs.c for the errors 
+					 */
+	unsigned nfs_mount_retry_pause; /* Time in seconds to pause between retrying nfs mounts */
+        
+
 };
 
 extern struct autofs_point ap; 
man/automount.8 +45 -0

51 lines not on this page · raw message

modules/mount_nfs.c +75 -25

120 lines not on this page · raw message

Signature · 1 line
1.7.3.3
author
#7 lore raw

PATCH 7/8 Ian Kent's reentrant syslog patch

In reply to Bill Ryder
---
 CHANGELOG           |    8 +
 COPYRIGHT           |   36 +++-
 daemon/automount.c  |   72 +++++--
 include/automount.h |   27 +++
 include/syslog.h    |  201 +++++++++++++++++
 lib/Makefile        |    5 +-
 lib/syslog.c        |  383 +++++++++++++++++++++++++++++++
 lib/vsprintf.c      |  619 +++++++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 1332 insertions(+), 19 deletions(-)
 create mode 100644 include/syslog.h
 create mode 100644 lib/syslog.c
 create mode 100644 lib/vsprintf.c
CHANGELOG +8 -0
index bbf4d3d..b4959ec 100644
@@ -1,3 +1,11 @@
+15/07/2010 autofs-4.1.4 - syslog patch
+--------------------------------------
+
+This patch is necessary - especially when using debug syslog messages
+and testing high mount rates. Without it I've see the daemon wedge in
+syslog. I'm pretty sure Ian Kent did the patch.
+
+
 14/07/2010 autofs-4.1.4 - bryder p42
 ------------------------------------
  Adds retrying to nfs mounts. 
COPYRIGHT +35 -1
index cf647f8..ee56c0c 100644
@@ -14,4 +14,38 @@ For all software in this distribution unless otherwise indicated:
    GNU General Public License for more details.
 
 Portions Copyright (C) 1999-2000 Jeremy Fitzhardinge
-Portions Copyright (C) 2001-2003 Ian Kent
+Portions Copyright (C) 2001-2005 Ian Kent
+
+The files lib/syslog.c and include/syslog.h are licenced under the
+BSD License and require that a copy of the notice ibelow be included in
+accompanying documentation and be distributed with binary distributions
+of the code, so be sure to include this file along with any binary
+distributions derived from this source package.
+
+Copyright (c) 1983, 1988, 1993
+     The Regents of the University of California.  All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name of the University nor the names of its contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
daemon/automount.c +56 -16

172 lines not on this page · raw message

include/automount.h +27 -0
index b09dd78..72f6c91 100644
@@ -15,6 +15,9 @@
 #include <time.h>
 #include "config.h"
 
+/* OpenBSD re-entrant syslog */
+#include "syslog.h"
+
 /* We MUST have the paths to mount(8) and umount(8) */
 #ifndef HAVE_MOUNT
 #error Failed to locate mount(8)!
@@ -318,5 +321,29 @@ if (do_verbose || do_debug) 		\
 if (do_debug) 				\
 	syslog(LOG_DEBUG, msg, ##args);
 
+/* Define reentrant logging macros for signal handlers */
+
+#define debug_r(context, msg, args...)				\
+do {								\
+	if (do_debug)						\
+		syslog_r(LOG_DEBUG, context, msg, ##args);	\
+} while (0)
+
+#define warn_r(context, msg, args...)				\
+do {								\
+	if (do_verbose || do_debug)				\
+		syslog_r(LOG_WARNING, context, msg, ##args);	\
+} while (0)
+
+#define error_r(context, msg, args...)			\
+do {							\
+	syslog_r(LOG_ERR, context, msg, ##args);	\
+} while (0)
+
+#define crit_r(context, msg, args...)			\
+do {							\
+	syslog_r(LOG_CRIT, context, msg, ##args);	\
+} while (0)
+
 #endif
 
include/syslog.h new file +201 -0

201 lines not on this page · raw message

lib/Makefile +3 -2
index 5cc809c..1771b1f 100644
@@ -9,10 +9,11 @@ include ../Makefile.rules
 RPCGEN = /usr/bin/rpcgen
 RANLIB = /usr/bin/ranlib
 
-SRCS = cache.c listmount.c cat_path.c rpc_subs.c mounts.c lock.c
+SRCS = cache.c listmount.c cat_path.c rpc_subs.c mounts.c lock.c syslog.c \
+	vsprintf.c
 RPCS = mount.h mount_clnt.c mount_xdr.c
 OBJS = cache.o mount_clnt.o mount_xdr.o listmount.o \
-	cat_path.o rpc_subs.o mounts.o lock.o
+	cat_path.o rpc_subs.o mounts.o lock.o syslog.o vsprintf.o
 
 LIB = autofs.a
 
lib/syslog.c new file +383 -0

383 lines not on this page · raw message

lib/vsprintf.c new file +619 -0

619 lines not on this page · raw message

Signature · 1 line
1.7.3.3
author
#8 lore raw

PATCH 8/8 Fix race which would stop a daemon under high mount rates with failures

In reply to Bill Ryder
---
 CHANGELOG          |   13 +++++++++++++
 daemon/automount.c |    4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)
CHANGELOG +13 -0
index b4959ec..e13e0ac 100644
@@ -1,3 +1,16 @@
+19/07/2010 autofs-4.1.4 - bryder p44
+---------------------------
+  Fix a problem where automount can shut itself down for no good reason.
+  The case I had was  very high rate of failed mounts triggering the
+      if (handle_packet() && errno != EINTR) ; break  
+  piece of code in automount.c:handle_mounts which ended up just shutting down the automounter.
+  The debug statement confirmed it (ap.state was 1 (READY) instead of 6 (SHUTDOWN))
+  The bug is triggered if a child signal is caught when the daemon was not in the middle of a system call - hence errno 
+  was not set to EINTR and handle_packet returned non zero - as in when a mount point didn't exist. 
+  This was  reproducible when using the ignore-stupid-paths option which meant the daemon spent
+  more time in user space handling autofs kernel packets than before.
+
+  
 15/07/2010 autofs-4.1.4 - syslog patch
 --------------------------------------
 
daemon/automount.c +2 -2
index 92476b4..0142884 100644
@@ -1729,9 +1729,9 @@ int handle_mounts(char *path)
 		kill(my_pid, SIGSTOP);
 
 	while (ap.state != ST_SHUTDOWN) {
-		if (handle_packet() && errno != EINTR)
-			break;
+		handle_packet();
 	}
+	debug("Shutting down - ap.state is %d if it's not %d (ST_SHUTDOWN) something bad happened ",ap.state,ST_SHUTDOWN);
 
 	/* Mop up remaining kids */
 	handle_child(1);
Signature · 1 line
1.7.3.3