Bug 784022

Summary: /etc/init.d/nfs mishandles /var/lock/subsys/nfs
Product: Red Hat Enterprise Linux 6 Reporter: Peter Staubach <plstaubach>
Component: nfs-utilsAssignee: Steve Dickson <steved>
Status: CLOSED ERRATA QA Contact: yanfu,wang <yanwang>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0CC: kzhang, pbenas
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: nfs-utils-1.2.3-18.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 851946 (view as bug list) Environment:
Last Closed: 2012-06-20 15:08:29 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 851946    

Description Peter Staubach 2012-01-23 15:39:04 UTC
Description of problem:

The NFS server startup script, /etc/init.d/nfs, touches the file, /var/lock/subsys/nfs, when it is called with the "reload" argument.  This argument tells it to rerun the exportfs command to export all file systems contained in the file, /etc/exports.  The problem is that if "/etc/init.d/nfs reload" is run while the NFS server is not running, it creates the file anyway.

This is not so much of a problem anymore since the script does not use the existence of this file to determine whether the NFS server is already running or not when it is called with the "start" argument.  However, the "probe", "condrestart", and "condstop" functions will not work correctly because they continue to use the existence of this file to determine whether the NFS server is already running or not.


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Run /etc/init.d/nfs stop
2. Run /etc/init.d/nfs reload
3. Run /etc/init.d/nfs probe
  
Actual results:

The last command echos "restart".


Expected results:

It should echo "start".


Additional info:

The solution might be as simple as only touching /var/lock/subsys/nfs if it exists already in the "reload" function.

Better would be to have the script use a consistent algorithm when determining whether the server is aleady running or not.

I might also suggest that checking for the existence of the rpc.mountd process will eventually not be a good algorithm because NFSv4 won't require mountd to be running.

Comment 2 Steve Dickson 2012-03-05 20:47:36 UTC
Here is the needed patch.

diff --git a/nfs.init b/nfs.init
index 2b84f7e..140df07 100755
--- a/nfs.init
+++ b/nfs.init
@@ -197,7 +197,7 @@ case "$1" in
        ;;
   reload | force-reload)
        /usr/sbin/exportfs -r
-       touch /var/lock/subsys/nfsd
+       [ -f /var/lock/subsys/nfsd ] && touch /var/lock/subsys/nfsd
        ;;
   probe)
        if [ ! -f /var/lock/subsys/nfsd ] ; then

Comment 4 yanfu,wang 2012-04-24 06:52:47 UTC
Reproduced on rhel6.1 package with the same result of comment #0:
# rpm -qa|grep nfs-utils
nfs-utils-lib-devel-1.1.5-3.el6.x86_64
nfs-utils-1.2.3-7.el6_1.1.x86_64
nfs-utils-lib-1.1.5-3.el6.x86_64
nfs-utils-debuginfo-1.2.3-7.el6_1.1.x86_64

# /etc/init.d/nfs status
rpc.svcgssd is stopped
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped
# /etc/init.d/nfs reload
It creates the lock file anyway even though the NFS server is not running:
# ls -l /var/lock/subsys/nfs 
-rw-r--r--. 1 root root 0 Apr 23 04:36 /var/lock/subsys/nfs
# /etc/init.d/nfs probe 
restart

# /etc/init.d/nfs condrestart
Shutting down NFS mountd:                                  [FAILED]
Shutting down NFS daemon:                                  [FAILED]
Shutting down NFS quotas:                                  [FAILED]
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
# /etc/init.d/nfs condstop   
Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS daemon:                                  [  OK  ]
Shutting down NFS quotas:                                  [  OK  ]


Verified on nfs-utils-1.2.3-21.el6:
# rpm -qa|grep nfs-utils
nfs-utils-lib-1.1.5-4.el6.i686
nfs-utils-1.2.3-21.el6.i686

# /etc/init.d/nfs stop
Shutting down NFS daemon: [  OK  ]
Shutting down NFS mountd: [  OK  ]
Shutting down NFS quotas: [  OK  ]
[root@hp-bl260cg5-01 autofs-5.0.5]# ls -l /var/lock/subsys/nfsd
ls: cannot access /var/lock/subsys/nfsd: No such file or directory
# /etc/init.d/nfs reload
Now it doesn't create the lock file when the NFS server is not running:
# ls -l /var/lock/subsys/nfsd
ls: cannot access /var/lock/subsys/nfsd: No such file or directory

Now "probe", "condrestart" and "condstop" functions work correctly:
# /etc/init.d/nfs condrestart
# /etc/init.d/nfs condstop
# /etc/init.d/nfs probe      
start

# /etc/init.d/nfs start
Starting NFS services:  [  OK  ]
Starting NFS quotas: [  OK  ]
Starting NFS mountd: [  OK  ]
Starting NFS daemon: [  OK  ]
# ls -l /var/lock/subsys/nfsd 
-rw-r--r--. 1 root root 0 Apr 23 04:44 /var/lock/subsys/nfsd
# /etc/init.d/nfs probe  
# echo $?
0
# /etc/init.d/nfs condrestart
Shutting down NFS daemon: [  OK  ]
Shutting down NFS mountd: [  OK  ]
Shutting down NFS quotas: [  OK  ]
Starting NFS services:  [  OK  ]
Starting NFS quotas: [  OK  ]
Starting NFS mountd: [  OK  ]
Starting NFS daemon: [  OK  ]
# /etc/init.d/nfs condstop   
Shutting down NFS daemon: [  OK  ]
Shutting down NFS mountd: [  OK  ]
Shutting down NFS quotas: [  OK  ]
# /etc/init.d/nfs status
rpc.svcgssd is stopped
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped

Comment 5 errata-xmlrpc 2012-06-20 15:08:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0964.html