autofs-5.0.3 - wait submount expire complete From: Ian Kent 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 file changed, 23 insertions(+) --- autofs-5.0.3.orig/lib/master.c +++ autofs-5.0.3/lib/master.c @@ -870,6 +870,29 @@ int master_notify_submount(struct autofs 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; }