Score:1

How does a lazy unmount actually work?

ug flag

During recent testing, I couldn't unmount an NFS mount after removing the NFS server or blocking the IP address of the server on PREROUTING raw, with iptables.

--force didn't work. Running mount to print all mounts showed it was still there.

But --lazy did.

Plenty of results to be found telling a person to do this. And that the manpage describes --force in particular for NFS servers that won't hang up.

But what exactly is the algorithm behind --lazy? How does the system know if the device is no longer busy?

It says it's unmounted, but how can I tell if operations are still happening in the background or not?

Last thing I want is a system that claims to be unmounted but is still opening connections that I can't see.

How can I go about verifying the mount is actually gone? Or read up about ways to verify this?

Score:1
jo flag

Laziness is managed by a counter referencing the specific mount_id.

All open file handles that reference the paths being used have to be closed or finished.

When the file tree is detached from the filesystem hierarchy, the counter can only go down. When it reaches 0, the filesystem is properly closed and cleaned up.

It should be noted however, if you mount with the hard mount option and you a performing a read, its possible for an NFS read task to never finish and delay indefinitely, as such some lazy unmounts may never complete.

ug flag
Assuming a soft mount with a custom low amount of retransmits... all connections should receive an I/O error after a few seconds, and then after a few tries, stop retrying and then it's all good, I think?
Matthew Ife avatar
jo flag
@KdgDev thats not so clear. If you have a process with its current working directory inside a NFS mount you're trying to close, unless the process moves out of that directory I dont see how the reference count will get eventually closed.
ug flag
Indeed, that is be the only case I couldn't verify theoretically. However in practice, I know only 1 process uses the mount I'm investigating, and its working directory is elsewhere.
Matthew Ife avatar
jo flag
@KdgDEv you could also have the mount path bind mounted, or have the mount propagated to a private mount namespace. Both of which would lead technically to a partially detached mount point. These are more exceptional circumstances however you'll less likely to encounter in the real world.
Score:0
de flag

Lazy umount is a regular umount, which happens in background. In addition is hides the mount entry, which makes it looks like umount have worked (or Detach the filesystem from the file hierarchy, how man page says). In really the unmount will happen when filesystem is not in use anymore.

Thus, for a real umount one should use --force and wait ...

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.