Blame SOURCES/autofs-5.1.2-handle-map_option-cache-for-top-level-mounts.patch

304803
autofs-5.1.2 - handle map_option cache for top level mounts
304803
304803
From: Ian Kent <raven@themaw.net>
304803
304803
In order to read in the map at mount time autofs top level mounts
304803
must be set as browsasble but amd top level mounts that have the
304803
map_option cache:=all set need to read in the map without the browse
304803
option being set.
304803
304803
Signed-off-by: Ian Kent <raven@themaw.net>
304803
---
304803
 CHANGELOG            |    1 +
304803
 include/automount.h  |    3 +++
304803
 lib/master.c         |   15 +++++++++++++++
304803
 lib/master_parse.y   |   16 ++++++++++++++++
304803
 man/autofs.conf.5.in |    8 ++++++--
304803
 5 files changed, 41 insertions(+), 2 deletions(-)
304803
304803
--- autofs-5.0.7.orig/CHANGELOG
304803
+++ autofs-5.0.7/CHANGELOG
304803
@@ -231,6 +231,7 @@
304803
 - check for conflicting amd section mounts.
304803
 - add function conf_get_map_options().
304803
 - capture cache option and its settings during parsing.
304803
+- handle map_option cache for top level mounts.
304803
 
304803
 25/07/2012 autofs-5.0.7
304803
 =======================
304803
--- autofs-5.0.7.orig/include/automount.h
304803
+++ autofs-5.0.7/include/automount.h
304803
@@ -505,6 +505,9 @@ struct kernel_mod_version {
304803
 /* Use symlinks instead of bind mounting local mounts */
304803
 #define MOUNT_FLAG_SYMLINK		0x0040
304803
 
304803
+/* Read amd map even if it's not to be ghosted (browsable) */
304803
+#define MOUNT_FLAG_AMD_CACHE_ALL	0x0080
304803
+
304803
 struct autofs_point {
304803
 	pthread_t thid;
304803
 	char *path;			/* Mount point name */
304803
--- autofs-5.0.7.orig/lib/master.c
304803
+++ autofs-5.0.7/lib/master.c
304803
@@ -982,6 +982,7 @@ static void master_add_amd_mount_section
304803
 		unsigned int ghost = 0;
304803
 		char *type = NULL;
304803
 		char *map = NULL;
304803
+		char *opts;
304803
 
304803
 		ret = master_partial_match_mapent(master, path);
304803
 		if (ret) {
304803
@@ -1036,6 +1037,20 @@ static void master_add_amd_mount_section
304803
 			goto next;
304803
 		}
304803
 
304803
+		opts = conf_amd_get_map_options(path);
304803
+		if (opts) {
304803
+			/* autofs uses the equivalent of cache:=inc,sync
304803
+			 * (except for file maps which use cache:=all,sync)
304803
+			 * but if the map is large then it may be necessary
304803
+			 * to read the whole map at startup even if browsing
304803
+			 * is is not enabled, so look for cache:=all in the
304803
+			 * map_options configuration entry.
304803
+			 */
304803
+			if (strstr(opts, "cache:=all"))
304803
+				entry->ap->flags |= MOUNT_FLAG_AMD_CACHE_ALL;
304803
+			free(opts);
304803
+		}
304803
+
304803
 		type = conf_amd_get_map_type(path);
304803
 		argv[0] = map;
304803
 		argv[1] = NULL;
304803
--- autofs-5.0.7.orig/lib/master_parse.y
304803
+++ autofs-5.0.7/lib/master_parse.y
304803
@@ -856,6 +856,22 @@ int master_parse_entry(const char *buffe
304803
 	if (negative_timeout)
304803
 		entry->ap->negative_timeout = negative_timeout;
304803
 
304803
+	if (format && !strcmp(format, "amd")) {
304803
+		char *opts = conf_amd_get_map_options(path);
304803
+		if (opts) {
304803
+			/* autofs uses the equivalent of cache:=inc,sync
304803
+			 * (except for file maps which use cache:=all,sync)
304803
+			 * but if the map is large then it may be necessary
304803
+			 * to read the whole map at startup even if browsing
304803
+			 * is is not enabled, so look for cache:=all in the
304803
+			 * map_options configuration entry.
304803
+			 */
304803
+			if (strstr(opts, "cache:=all"))
304803
+				entry->ap->flags |= MOUNT_FLAG_AMD_CACHE_ALL;
304803
+			free(opts);
304803
+		}
304803
+	}
304803
+
304803
 /*
304803
 	source = master_find_map_source(entry, type, format,
304803
 					local_argc, (const char **) local_argv); 
304803
--- autofs-5.0.7.orig/man/autofs.conf.5.in
304803
+++ autofs-5.0.7/man/autofs.conf.5.in
304803
@@ -284,8 +284,12 @@ protocol version.
304803
 .BR cache_duration ", " map_reload_interval ", " map_options
304803
 .br
304803
 The map	entry cache is continually updated and stale entries
304803
-cleaned on re-load, which is done when map changes aredetected
304803
-so these configuration entries are not used by autofs.
304803
+cleaned on re-load, which is done when map changes are detected
304803
+so these configuration entries are not used by autofs. An
304803
+exception to this is the case where the map is large. In this
304803
+case it may be necessary to read the whole map at startup even if
304803
+browsing is is not enabled. Adding the cache:=all option to
304803
+map_options can be used to for this.
304803
 .TP
304803
 .B localhost_address
304803
 This is not used within autofs. This configuration option was