LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-30-2017, 06:49 PM   #1
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Rep: Reputation: 177Reputation: 177
nfs hangs client when connection lost


I am doing an nfs mount of a remotely exported filesystem. My problem is that when connection to the remote host is lost, any application on the client machine that attempts to reference the nfs filesystem (e.g `ls`) hangs for a very long time, at least several minutes. It stays hung until the nfs server comes back online. (I've never had the patience to see if it ever terminates the request with the server offline).

I need for this to NOT behave this way. I would like to get some kind of system error after e.g. 60 seconds or less.

I've tried setting mount options hard,intr, but intr is apparently deprecated.

I can find nothing on this. It is possible?
 
Old 10-31-2017, 07:00 AM   #2
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 382Reputation: 382Reputation: 382Reputation: 382
Use 'soft' not 'hard' (hard might ignore intr)

Quote:
hard or soft — Specifies whether the program using a file via an NFS connection should stop and wait (hard) for the server to come back online, if the host serving the exported file system is unavailable, or if it should report an error (soft).

If hard is specified, the user cannot terminate the process waiting for the NFS communication to resume unless the intr option is also specified.

If soft is specified, the user can set an additional timeo=<value> option, where <value> specifies the number of seconds to pass before the error is reported.

Last edited by !!!; 10-31-2017 at 07:01 AM.
 
Old 10-31-2017, 07:10 AM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
I think this is the reason that in Linux it is accepted to consider a mounted NFS drive as part of the local filesystem. There is no difference whether a mounted directory resides on the local hard disk or a connected network drive. It simply is guaranteed to be there.

This is opposed to --say-- Windows where "mapped network drives" are considered unreliable. Some applications (and Windows itself of course) simply refuse to perform some actions on a network drive. Even if you have a roaming profile, the profile folder is copied back and forth to the network at every start-up and shutdown. (Real nice if you have over 2GB of IE and Google cache)

But the guaranteed presence of the NFS drive comes with a price: your system hangs when it is not there. And I also think a "soft" mount allows the process to fail when the drive disappeared.

jlinkels
 
Old 11-03-2017, 12:20 AM   #4
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
Quote:
Originally Posted by !!! View Post
Use 'soft' not 'hard' (hard might ignore intr)
Well, I've been scared to do that because of multiple warnings all over the place including the nfs man page:
Quote:
NB: A so-called "soft" timeout can cause silent data corruption in certain cases. As such, use the soft
option only when client responsiveness is more important than data integrity. Using NFS over TCP or
increasing the value of the retrans option may mitigate some of the risks of using the soft option.
However the author at this site: https://www.centos.org/forums/viewtopic.php?t=8787, doubts soft mounts are as scarey as advertised.
 
Old 11-03-2017, 07:08 AM   #5
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by mfoley View Post
However the author at this site: https://www.centos.org/forums/viewtopic.php?t=8787, doubts soft mounts are as scarey as advertised.
As I read it, the author states that it is not scary in all situations. So, yeah, that is less scary than scary in all situations.
An example where it is extremely scary is a MySQL server which uses an NFS mounted file system. You definitely don't want a table half updated. Note that MySQL transactions are atomic as seen by the client. But a transaction interrupted halfway during a write due to a file system error is different.
OTOH I have a NFS mounted drive where I store lots of data, but never process that data. Like disk images, backups, music and movies. No write action ever except for file copy. It is conceivable I could not care less if this file system is unreachable now and then. And much more irritating if my computer hangs due to such an event.
So you might want to consider for yourself if there is a risk for data corruption when you NFS is soft mounted and you get an I/O error instead of a frozen system.

jlinkels
 
  


Reply

Tags
nfs, timeout



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] mount nfs hangs -centos client ilanadm Linux - Server 2 04-03-2018 09:45 AM
System hangs when nfs connection is lost Hmail Linux - Networking 5 10-06-2015 05:02 AM
NFS client hangs when write ziobudda Linux - Networking 5 04-14-2006 10:40 PM
Iptables denies NFS to client and hangs ethics Linux - Networking 7 11-21-2005 06:59 PM
NFS hangs (server: 2.4.21, client: 2.6.6) grabner Linux - Networking 0 05-31-2004 12:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration