autofs-5.0.3 - wait submount expire complete From: Ian Kent <raven@themaw.net> When expiring a submount expires away and proceeds to shutdown we can reach the end of the expire of the parent before the submount goes away. This can cause an incomplete expire during shutdown in some cases so, for the case the submount goes to state ST_SHUTDOWN, we need to wait until the submount either goes away or fails to shutdown before continuing. --- lib/master.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/lib/master.c b/lib/master.c index 13302f1..ce5b987 100644 --- a/lib/master.c +++ b/lib/master.c @@ -870,6 +870,29 @@ int master_notify_submount(struct autofs_point *ap, const char *path, enum state st_wait_task(this, state, 0); + /* + * If our submount gets to state ST_SHUTDOWN we need to + * wait until it goes away or changes to ST_READY. + */ + mounts_mutex_lock(ap); + st_mutex_lock(); + while ((this = __master_find_submount(ap, path))) { + struct timespec t = { 0, 300000000 }; + struct timespec r; + + if (this->state != ST_SHUTDOWN) + break; + + st_mutex_unlock(); + mounts_mutex_unlock(ap); + while (nanosleep(&t, &r) == -1 && errno == EINTR) + memcpy(&t, &r, sizeof(struct timespec)); + mounts_mutex_lock(ap); + st_mutex_lock(); + } + st_mutex_unlock(); + mounts_mutex_unlock(ap); + return ret; }