Bug 251395

Summary: usr.sbin/autofs: autounmountd does not clear entries in /var/db/mounttab (was: rc.d/nfsclient: hangs at shutdown because of non-empty /var/db/mounttab)
Product: Base System Reporter: Martin Birgmeier <d8zNeCFG>
Component: binAssignee: freebsd-rc (Nobody) <rc>
Status: New ---    
Severity: Affects Only Me CC: rew
Priority: ---    
Version: 12.2-RELEASE   
Hardware: Any   
OS: Any   
URL: https://reviews.freebsd.org/D27801

Description Martin Birgmeier 2020-11-26 07:10:22 UTC
- multiple machines using NFS and autofs (automount)
- some of them running FreeBSD 12.2, the others 12.1
- at the end of the day they are shut down simultaneously; before that, it is ensured that all NFS mounts are unmounted (using automount -u and checking via "df -t nfs")

- The 12.2 machine hangs in the rc.d/nfsclient script with repeated error messages indicating it cannot contact the remote portmapper: the remote portmapper does not reply anymore because that machine is also going down.
- This happens because the file /var/db/mounttab is non-empty and still indicates the remote NFS servers despite the fact that all NFS mounts have already been unmounted.

Expected result:
- After the last NFS mount from a server has been unmounted, the corresponding entry in /var/db/mounttab, and the complete file if empty, should be removed.
- This should enable rc.d/nfsclient to skip any further NFS server notification during shutdown.

-- Martin
Comment 1 Martin Birgmeier 2020-12-07 10:54:39 UTC
It seems that the problem with rc.d/nfsclient hanging is that the autounmountd (part of autofs) does not remove entries from /var/db/mounttab, where the regular umount command does.

In this way, even if there are no NFS mounts anymore, entries accumulate in /var/db/mounttab.

It is possible to manually mount a remote dir (e.g., on /mnt) and then unmount it again, and this will remove all the corresponding entries from /var/db/mounttab.

Therefore, it seems that autounmountd needs to be fixed to remove entries from /var/db/mounttab.

-- Martin