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

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