Blame SOURCES/autofs-5.1.8-fix-root-offset-error-handling.patch

91594d
autofs-5.1.8 - fix root offset error handling
91594d
91594d
From: Ian Kent <raven@themaw.net>
91594d
91594d
If mounting the root or offsets of a multi-mount root fails any mounts
91594d
done so far need to be umounted and the multi-mount offset tree deleted
91594d
so it can be created cleanly and possibly mounted the next time it's
91594d
triggered.
91594d
91594d
Also, if a subtree that is not the multi-mount root fails the expire
91594d
alarm needs to be re-instated so other subtrees (at least the root)
91594d
will continue to expire.
91594d
91594d
Signed-off-by: Ian Kent <raven@themaw.net>
91594d
---
91594d
 CHANGELOG           |    1 +
91594d
 daemon/direct.c     |   10 +++++++++-
91594d
 modules/parse_sun.c |    6 ++++++
91594d
 3 files changed, 16 insertions(+), 1 deletion(-)
91594d
91594d
--- autofs-5.1.7.orig/CHANGELOG
91594d
+++ autofs-5.1.7/CHANGELOG
91594d
@@ -84,6 +84,7 @@
91594d
 - fix fedfs build flags.
91594d
 - fix set open file limit.
91594d
 - improve descriptor open error reporting.
91594d
+- fix root offset error handling.
91594d
 
91594d
 25/01/2021 autofs-5.1.7
91594d
 - make bind mounts propagation slave by default.
91594d
--- autofs-5.1.7.orig/daemon/direct.c
91594d
+++ autofs-5.1.7/daemon/direct.c
91594d
@@ -1163,6 +1163,7 @@ static void *do_mount_direct(void *arg)
91594d
 	struct ioctl_ops *ops = get_ioctl_ops();
91594d
 	struct pending_args *args, mt;
91594d
 	struct autofs_point *ap;
91594d
+	struct mapent *me;
91594d
 	struct stat st;
91594d
 	int status, state;
91594d
 
91594d
@@ -1226,7 +1227,6 @@ static void *do_mount_direct(void *arg)
91594d
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
91594d
 	if (status) {
91594d
 		struct mnt_list *sbmnt;
91594d
-		struct mapent *me;
91594d
 		struct statfs fs;
91594d
 		unsigned int close_fd = 0;
91594d
 		unsigned int flags = MNTS_DIRECT|MNTS_MOUNTED;
91594d
@@ -1267,6 +1267,14 @@ static void *do_mount_direct(void *arg)
91594d
 			       mt.ioctlfd, mt.wait_queue_token, -ENOENT);
91594d
 		ops->close(ap->logopt, mt.ioctlfd);
91594d
 		info(ap->logopt, "failed to mount %s", mt.name);
91594d
+
91594d
+		/* If this is a multi-mount subtree mount failure
91594d
+		 * ensure the tree continues to expire.
91594d
+		 */
91594d
+		me = cache_lookup_distinct(mt.mc, mt.name);
91594d
+		if (me && IS_MM(me) && !IS_MM_ROOT(me))
91594d
+			conditional_alarm_add(ap, ap->exp_runfreq);
91594d
+		cache_unlock(mt.mc);
91594d
 	}
91594d
 	pthread_setcancelstate(state, NULL);
91594d
 
91594d
--- autofs-5.1.7.orig/modules/parse_sun.c
91594d
+++ autofs-5.1.7/modules/parse_sun.c
91594d
@@ -1142,6 +1142,9 @@ static int mount_subtree(struct autofs_p
91594d
 		if (!len) {
91594d
 			warn(ap->logopt, "path loo long");
91594d
 			cache_unlock(mc);
91594d
+			cache_writelock(mc);
91594d
+			tree_mapent_delete_offsets(mc, name);
91594d
+			cache_unlock(mc);
91594d
 			return 1;
91594d
 		}
91594d
 		key[len] = '/';
91594d
@@ -1186,6 +1189,9 @@ static int mount_subtree(struct autofs_p
91594d
 				cache_unlock(mc);
91594d
 				error(ap->logopt, MODPREFIX
91594d
 					 "failed to mount offset triggers");
91594d
+				cache_writelock(mc);
91594d
+				tree_mapent_delete_offsets(mc, name);
91594d
+				cache_unlock(mc);
91594d
 				return 1;
91594d
 			}
91594d
 		}