]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
nfs-utils: don't use signals to shut down nfs server.
authorNeilBrown <neilb@suse.de>
Wed, 28 May 2025 02:08:52 +0000 (10:08 +0800)
committerSteve Sakoman <steve@sakoman.com>
Thu, 29 May 2025 15:22:59 +0000 (08:22 -0700)
Since Linux v2.4 it has been possible to stop all NFS server by running

   rpc.nfsd 0

i.e.  by requesting that zero threads be running.  This is preferred as
it doesn't risk killing some other process which happens to be called
"nfsd".

Since Linux v6.6 - and other stable kernels to which

  Commit: 390390240145 ("nfsd: don't allow nfsd threads to be
  signalled.")

has been backported - sending a signal no longer works to stop nfs server
threads.

This patch changes the nfsserver script to use "rpc.nfsd 0" to stop
server threads.

Signed-off-by: NeilBrown <neil@brown.name>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 7b09ad289a36)
Signed-off-by: Haixiao Yan <haixiao.yan.cn@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver

index 0f5747cc6db97d8c14100c170e2fa53f30b6e2b4..4d78312929e205b0b0bd8216a0d42867a7bed0b2 100644 (file)
@@ -66,34 +66,14 @@ start_nfsd(){
        start-stop-daemon --start --exec "$NFS_NFSD" -- "$@"
        echo done
 }
-delay_nfsd(){
-       for delay in 0 1 2 3 4 5 6 7 8 9 
-       do
-               if pidof nfsd >/dev/null
-               then
-                       echo -n .
-                       sleep 1
-               else
-                       return 0
-               fi
-       done
-       return 1
-}
 stop_nfsd(){
-       # WARNING: this kills any process with the executable
-       # name 'nfsd'.
        echo -n 'stopping nfsd: '
-       start-stop-daemon --stop --quiet --signal 1 --name nfsd
-       if delay_nfsd || {
-               echo failed
-               echo ' using signal 9: '
-               start-stop-daemon --stop --quiet --signal 9 --name nfsd
-               delay_nfsd
-       }
+       $NFS_NFSD 0
+       if pidof nfsd
        then
-               echo done
-       else
                echo failed
+       else
+               echo done
        fi
 }