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