Blame SOURCES/autofs-5.1.6-move-submount-check-into-conditional_alarm_add.patch

beb904
autofs-5.1.6 - move submount check into conditional_alarm_add()
beb904
beb904
From: Ian Kent <raven@themaw.net>
beb904
beb904
The expire of submounts is driven by the top level autofs mount in the
beb904
mount tree so an expire alarm doesn't need to set if the autofs point
beb904
is a submount.
beb904
beb904
Take that check into conditional_alarm_add().
beb904
beb904
Signed-off-by: Ian Kent <raven@themaw.net>
beb904
---
beb904
 CHANGELOG          |    1 +
beb904
 daemon/automount.c |    6 ++----
beb904
 daemon/direct.c    |    3 +--
beb904
 daemon/indirect.c  |    3 +--
beb904
 daemon/state.c     |   26 +++++++++-----------------
beb904
 lib/alarm.c        |    2 ++
beb904
 lib/mounts.c       |    6 ++----
beb904
 7 files changed, 18 insertions(+), 29 deletions(-)
beb904
beb904
--- autofs-5.1.4.orig/CHANGELOG
beb904
+++ autofs-5.1.4/CHANGELOG
beb904
@@ -132,6 +132,7 @@ xx/xx/2018 autofs-5.1.5
beb904
 - use struct mnt_list mounted list for expire.
beb904
 - remove unused function tree_get_mnt_list().
beb904
 - only add expre alarm for active mounts.
beb904
+- move submount check into conditional_alarm_add().
beb904
 
beb904
 19/12/2017 autofs-5.1.4
beb904
 - fix spec file url.
beb904
--- autofs-5.1.4.orig/daemon/automount.c
beb904
+++ autofs-5.1.4/daemon/automount.c
beb904
@@ -1843,8 +1843,7 @@ int handle_mounts_exit(struct autofs_poi
beb904
 	}
beb904
 
beb904
 	if (ap->state != ST_SHUTDOWN) {
beb904
-		if (!ap->submount)
beb904
-			conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+		conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 		/* Return to ST_READY is done immediately */
beb904
 		st_add_task(ap, ST_READY);
beb904
 		if (ap->submount)
beb904
@@ -1888,8 +1887,7 @@ int handle_mounts_exit(struct autofs_poi
beb904
 
beb904
 	/* Failed shutdown returns to ready */
beb904
 	warn(ap->logopt, "can't shutdown: filesystem %s still busy", ap->path);
beb904
-	if (!ap->submount)
beb904
-		conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+	conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 	/* Return to ST_READY is done immediately */
beb904
 	st_add_task(ap, ST_READY);
beb904
 	if (ap->submount)
beb904
--- autofs-5.1.4.orig/daemon/direct.c
beb904
+++ autofs-5.1.4/daemon/direct.c
beb904
@@ -1246,8 +1246,7 @@ static void *do_mount_direct(void *arg)
beb904
 
beb904
 		mnts_set_mounted_mount(ap, mt.name);
beb904
 
beb904
-		if (!ap->submount)
beb904
-			conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+		conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 	} else {
beb904
 		/* TODO: get mount return status from lookup_nss_mount */
beb904
 		ops->send_fail(ap->logopt,
beb904
--- autofs-5.1.4.orig/daemon/indirect.c
beb904
+++ autofs-5.1.4/daemon/indirect.c
beb904
@@ -754,8 +754,7 @@ static void *do_mount_indirect(void *arg
beb904
 
beb904
 		mnts_set_mounted_mount(ap, mt.name);
beb904
 
beb904
-		if (!ap->submount)
beb904
-			conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+		conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 	} else {
beb904
 		/* TODO: get mount return status from lookup_nss_mount */
beb904
 		ops->send_fail(ap->logopt,
beb904
--- autofs-5.1.4.orig/daemon/state.c
beb904
+++ autofs-5.1.4/daemon/state.c
beb904
@@ -154,7 +154,7 @@ void expire_cleanup(void *arg)
beb904
 			} else if (ap->submount > 1)
beb904
 				ap->submount = 1;
beb904
 
beb904
-			if (ap->state == ST_EXPIRE && !ap->submount)
beb904
+			if (ap->state == ST_EXPIRE)
beb904
 				conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 
beb904
 			/* FALLTHROUGH */
beb904
@@ -172,8 +172,7 @@ void expire_cleanup(void *arg)
beb904
 			rv = ops->askumount(ap->logopt, ap->ioctlfd, &idle);
beb904
 			if (!rv && !idle && !ap->shutdown) {
beb904
 				next = ST_READY;
beb904
-				if (!ap->submount)
beb904
-					conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+				conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 				break;
beb904
 			}
beb904
 
beb904
@@ -186,8 +185,7 @@ void expire_cleanup(void *arg)
beb904
 
beb904
 			/* Failed shutdown returns to ready */
beb904
 			warn(ap->logopt, "filesystem %s still busy", ap->path);
beb904
-			if (!ap->submount)
beb904
-				conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+			conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 			next = ST_READY;
beb904
 			break;
beb904
 #endif
beb904
@@ -577,8 +575,7 @@ static unsigned int st_readmap(struct au
beb904
 		error(ap->logopt, "failed to malloc readmap cond struct");
beb904
 		/* It didn't work: return to ready */
beb904
 		st_ready(ap);
beb904
-		if (!ap->submount)
beb904
-			conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+		conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 		return 0;
beb904
 	}
beb904
 
beb904
@@ -604,8 +601,7 @@ static unsigned int st_readmap(struct au
beb904
 		free(ra);
beb904
 		/* It didn't work: return to ready */
beb904
 		st_ready(ap);
beb904
-		if (!ap->submount)
beb904
-			conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+		conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 		return 0;
beb904
 	}
beb904
 	ap->readmap_thread = thid;
beb904
@@ -640,8 +636,7 @@ static unsigned int st_prepare_shutdown(
beb904
 	case EXP_ERROR:
beb904
 	case EXP_PARTIAL:
beb904
 		/* It didn't work: return to ready */
beb904
-		if (!ap->submount)
beb904
-			conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+		conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 		st_ready(ap);
beb904
 		return 0;
beb904
 
beb904
@@ -666,8 +661,7 @@ static unsigned int st_force_shutdown(st
beb904
 	case EXP_ERROR:
beb904
 	case EXP_PARTIAL:
beb904
 		/* It didn't work: return to ready */
beb904
-		if (!ap->submount)
beb904
-			conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+		conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 		st_ready(ap);
beb904
 		return 0;
beb904
 
beb904
@@ -699,8 +693,7 @@ static unsigned int st_prune(struct auto
beb904
 	switch (expire_proc(ap, AUTOFS_EXP_IMMEDIATE)) {
beb904
 	case EXP_ERROR:
beb904
 	case EXP_PARTIAL:
beb904
-		if (!ap->submount)
beb904
-			conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+		conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 		st_ready(ap);
beb904
 		return 0;
beb904
 
beb904
@@ -720,8 +713,7 @@ static unsigned int st_expire(struct aut
beb904
 	switch (expire_proc(ap, AUTOFS_EXP_NORMAL)) {
beb904
 	case EXP_ERROR:
beb904
 	case EXP_PARTIAL:
beb904
-		if (!ap->submount)
beb904
-			conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+		conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 		st_ready(ap);
beb904
 		return 0;
beb904
 
beb904
--- autofs-5.1.4.orig/lib/alarm.c
beb904
+++ autofs-5.1.4/lib/alarm.c
beb904
@@ -187,6 +187,8 @@ int conditional_alarm_add(struct autofs_
beb904
 {
beb904
 	int status;
beb904
 
beb904
+	if (ap->submount)
beb904
+		return 1;
beb904
 	if (!mnts_has_mounted_mounts(ap))
beb904
 		return 1;
beb904
 
beb904
--- autofs-5.1.4.orig/lib/mounts.c
beb904
+++ autofs-5.1.4/lib/mounts.c
beb904
@@ -1921,8 +1921,7 @@ static int do_remount_direct(struct auto
beb904
 
beb904
 		info(ap->logopt, "re-connected to %s", path);
beb904
 
beb904
-		if (!ap->submount)
beb904
-			conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+		conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 	} else {
beb904
 		status = REMOUNT_FAIL;
beb904
 		info(ap->logopt, "failed to re-connect %s", path);
beb904
@@ -1997,8 +1996,7 @@ static int do_remount_indirect(struct au
beb904
 
beb904
 			info(ap->logopt, "re-connected to %s", buf);
beb904
 
beb904
-			if (!ap->submount)
beb904
-				conditional_alarm_add(ap, ap->exp_runfreq);
beb904
+			conditional_alarm_add(ap, ap->exp_runfreq);
beb904
 		} else {
beb904
 			status = REMOUNT_FAIL;
beb904
 			info(ap->logopt, "failed to re-connect %s", buf);