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

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