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

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