- Integrated Systems
- About Us
- Integrated Systems
- About Us
03-07-2012 08:33 AM
what is the difference betweeen NFS hard mount and softmount
I know that hard mount is default, But the disadvantage of this option is NFS client will keep trying to mount the NFS share if it is not available...So that, the application using that mount point will hung...But the advantage is it will mount NFS share automatically once it is available again...
But if we are mounting as soft mount, then NFS client will try to mount NFS share for particular period of time and then it wont try....So hung of application will not happen...
1)If we are using soft mount option, Will it mount the NFS share automatically once NFS share restored or do we need to mount manually?
2)When and where we have to use hard mount and soft mount, Please explain me in detail?
03-07-2012 03:21 PM
Re: what is the difference betweeen NFS hard mount and softmount
You're assuming that a NFS filesystem will be unmounted if the NFS server is not reachable. This is not true.
What actually happens is a bit more complicated.
To avoid wasting network bandwidth, the NFS client will not continuously poll the NFS server to make sure it is still reachable. So the NFS client won't always know that the server has become unreachable until it tries to access a file on the NFS server.
Most of the filesystem I/O goes through the buffer cache (memory-mapped files are always cached, other methods may have an option to avoid caching). Normally, when a program writes something to a file, the OS will make some checks, and if there is nothing to stop the operation from succeeding, the data to be written is accepted into the cache and the program is told that the write is successful. The OS will do the actual write a bit later, in the hope that it can gather multiple small write operations and write them all in one big operation, because it will be more efficient. Normally this works well.
But if the NFS server becomes inaccessible between the data hitting the cache and the actual write operation, the OS has a big problem. As far as the program is concerned, the write operation was successfully done and firmly in the past; the OS already told it so. There is no way for the OS to go back on its word and tell the program that the write operation failed after all.
At this point, the OS has two choices:
- It can hold the program in a frozen state while it tries again and again to reach the NFS server and complete the write operation. This is exactly what the hard mount does. At this point, the kernel usually outputs a message for all logged-in users: "NFS server <name> not responding, still trying" in order to alert the users that there is a problem,
- Or the OS can keep trying for a while, then give up and throw away the data, and tell the program that accessing the NFS filesystem is no longer possible when it makes the next NFS write operation. This is what the soft mount does. (The program will know that operation #2 failed, but it will have no clue that operation #1 failed too.)
Whether the mount was soft or hard, it should automatically recover as soon as the NFS server is reachable again. (However, if the NFS server has rebooted while it was unreachable, any file locks that may have been established on the NFS filesystem before must be recovered with a special procedure or they will be lost, and that can be yet another can of worms...)
After this bit of background, the answers to your actual questions:
1.) No, you don't need to re-mount soft NFS mounts after a NFS server becomes unreachable and then returns.
2.) As far as I've undrstood, you can use soft mounts safely only if:
- you don't care that you might lose some data if the NFS server becomes unreachable, or
- your programs "know" that they are working with a soft-mounted NFS filesystem and are designed to take special steps to guard against data loss.
So, in some very limited circumstances, a soft NFS mount might be useful, but in general, soft NFS mounts are a bad idea. Don't use them unless you really know what you're doing.