Patchwork nfs-utils: Stop rpc.statd correctly

login
register
mail settings
Submitter Qiang Chen
Date Oct. 22, 2013, 3:03 a.m.
Message ID <1382411039-1161-1-git-send-email-qiang.chen@windriver.com>
Download mbox | patch
Permalink /patch/60331/
State Accepted
Commit b82603b06276050b80c9ae643075dcb7efda352b
Headers show

Comments

Qiang Chen - Oct. 22, 2013, 3:03 a.m.
From: Qiang Chen <qiang.chen@windriver.com>

An incorrect process name in the nfsserver initscript prevented
rpc.statd from being shut down.

root@qemux86-64:~# /etc/init.d/nfsserver start
creating NFS state directory: done
starting 8 nfsd kernel threads: done
starting mountd: done
starting statd: done

root@qemux86-64:~# ps | grep rpc.statd
  650 root     10532 S    /usr/sbin/rpc.statd
  654 root      4720 S    grep rpc.statd

root@qemux86-64:~# /etc/init.d/nfsserver stop
stopping statd: done
stopping mountd: done
stopping nfsd: done

root@qemux86-64:~# ps | grep rpc.statd
  650 root     10532 S    /usr/sbin/rpc.statd
  662 root      4720 S    grep rpc.statd

As this daemon drops a pid file,simply use that instead.
Also add some initialization checks so the daemons are not
left partially started in the absence of kernel nfsd support.

Signed-off-by: Andy Ross <andy.ross@windriver.com>
Signed-off-by: Qiang Chen <qiang.chen@windriver.com>
---
 .../nfs-utils/nfs-utils/nfsserver                  |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
Khem Raj - Oct. 25, 2013, 12:31 p.m.
On Mon, Oct 21, 2013 at 8:03 PM,  <qiang.chen@windriver.com> wrote:
> From: Qiang Chen <qiang.chen@windriver.com>
>
> An incorrect process name in the nfsserver initscript prevented
> rpc.statd from being shut down.
>
> root@qemux86-64:~# /etc/init.d/nfsserver start
> creating NFS state directory: done
> starting 8 nfsd kernel threads: done
> starting mountd: done
> starting statd: done
>
> root@qemux86-64:~# ps | grep rpc.statd
>   650 root     10532 S    /usr/sbin/rpc.statd
>   654 root      4720 S    grep rpc.statd
>
> root@qemux86-64:~# /etc/init.d/nfsserver stop
> stopping statd: done
> stopping mountd: done
> stopping nfsd: done
>
> root@qemux86-64:~# ps | grep rpc.statd
>   650 root     10532 S    /usr/sbin/rpc.statd
>   662 root      4720 S    grep rpc.statd
>
> As this daemon drops a pid file,simply use that instead.
> Also add some initialization checks so the daemons are not
> left partially started in the absence of kernel nfsd support.
>
> Signed-off-by: Andy Ross <andy.ross@windriver.com>
> Signed-off-by: Qiang Chen <qiang.chen@windriver.com>
> ---

I think this patch is needed for dora branch too.

>  .../nfs-utils/nfs-utils/nfsserver                  |   18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver b/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver
> index 1ac6fec..8ee8d0b 100644
> --- a/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver
> +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver
> @@ -25,6 +25,7 @@ test -r /etc/default/nfsd && . /etc/default/nfsd
>  test -x "$NFS_MOUNTD" || NFS_MOUNTD=/usr/sbin/rpc.mountd
>  test -x "$NFS_NFSD" || NFS_NFSD=/usr/sbin/rpc.nfsd
>  test -x "$NFS_STATD" || NFS_STATD=/usr/sbin/rpc.statd
> +test -z "$STATD_PID" && STATD_PID=/var/run/rpc.statd.pid
>  #
>  # The user mode program must also exist (it just starts the kernel
>  # threads using the kernel module code).
> @@ -77,6 +78,17 @@ stop_mountd(){
>  #
>  #nfsd
>  start_nfsd(){
> +        modprobe -q nfsd
> +       grep -q nfsd /proc/filesystems || {
> +               echo NFS daemon support not enabled in kernel
> +               exit 1
> +        }
> +       grep -q nfsd /proc/mounts || mount -t nfsd nfsd /proc/fs/nfsd
> +       grep -q nfsd /proc/mounts || {
> +               echo nfsd filesystem could not be mounted at /proc/fs/nfsd
> +               exit 1
> +        }
> +
>         echo -n "starting $1 nfsd kernel threads: "
>         start-stop-daemon --start --exec "$NFS_NFSD" -- "$@"
>         echo done
> @@ -115,14 +127,12 @@ stop_nfsd(){
>  #statd
>  start_statd(){
>         echo -n "starting statd: "
> -       start-stop-daemon --start --exec "$NFS_STATD"
> +       start-stop-daemon --start --exec "$NFS_STATD" --pidfile "$STATD_PID"
>         echo done
>  }
>  stop_statd(){
> -       # WARNING: this kills any process with the executable
> -       # name 'statd'.
>         echo -n 'stopping statd: '
> -       start-stop-daemon --stop --quiet --signal 1 --name statd
> +       start-stop-daemon --stop --quiet --signal 1 --pidfile "$STATD_PID"
>         echo done
>  }
>  #----------------------------------------------------------------------
> --
> 1.7.9.5
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core

Patch

diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver b/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver
index 1ac6fec..8ee8d0b 100644
--- a/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver
@@ -25,6 +25,7 @@  test -r /etc/default/nfsd && . /etc/default/nfsd
 test -x "$NFS_MOUNTD" || NFS_MOUNTD=/usr/sbin/rpc.mountd
 test -x "$NFS_NFSD" || NFS_NFSD=/usr/sbin/rpc.nfsd
 test -x "$NFS_STATD" || NFS_STATD=/usr/sbin/rpc.statd
+test -z "$STATD_PID" && STATD_PID=/var/run/rpc.statd.pid
 #
 # The user mode program must also exist (it just starts the kernel
 # threads using the kernel module code).
@@ -77,6 +78,17 @@  stop_mountd(){
 #
 #nfsd
 start_nfsd(){
+        modprobe -q nfsd
+	grep -q nfsd /proc/filesystems || {
+		echo NFS daemon support not enabled in kernel
+		exit 1
+        }
+	grep -q nfsd /proc/mounts || mount -t nfsd nfsd /proc/fs/nfsd
+	grep -q nfsd /proc/mounts || {
+		echo nfsd filesystem could not be mounted at /proc/fs/nfsd
+		exit 1
+        }
+
 	echo -n "starting $1 nfsd kernel threads: "
 	start-stop-daemon --start --exec "$NFS_NFSD" -- "$@"
 	echo done
@@ -115,14 +127,12 @@  stop_nfsd(){
 #statd
 start_statd(){
 	echo -n "starting statd: "
-	start-stop-daemon --start --exec "$NFS_STATD"
+	start-stop-daemon --start --exec "$NFS_STATD" --pidfile "$STATD_PID"
 	echo done
 }
 stop_statd(){
-	# WARNING: this kills any process with the executable
-	# name 'statd'.
 	echo -n 'stopping statd: '
-	start-stop-daemon --stop --quiet --signal 1 --name statd
+	start-stop-daemon --stop --quiet --signal 1 --pidfile "$STATD_PID"
 	echo done
 }
 #----------------------------------------------------------------------