File 0004-systemd-unit-files-fix-up-dependencies-on-rpcbind.patch of Package nfs-utils.3350

From 91da135f243d6f87fcea8b8a3ce28a589917b0e4 Mon Sep 17 00:00:00 2001
From: NeilBrown <>
Date: Mon, 2 May 2016 08:54:13 -0400
Subject: [PATCH] systemd unit files: fix up dependencies on rpcbind.

The dependencies on rpcbind have been changed a few times and I think
they are still wrong.  So I'll go into some detail to justify this

Firstly: rpcbind.socket or rpcbind.service?

The systemd documentation talks about targets as "synchronization
points" and likens them to SysV init run levels.  Run levels are about
ordering but not dependencies.

The systemd.special man page describes as intended
explicitly for ordering sysvinit scripts, with "After=" dependencies.

So while I think it is valid to use for ordering
(before/after) it shouldn't be used for dependencies (Wants/Requires).
The file included in systemd does not "Require" the
actual service, so requiring itself is pointless.

I think we shouldn't use at all.  Leave it for sysvinit

So: .socket or .service?

I think nfs only needs the socket to be active.  On first connection
the service will be started.  But nfs does not need to wait for the
service to start, only the socket.  So I think we should exclusively
use rpcbind.socket.

Next: Wants or Requires.

rpc.statd definitely Requires rpcbind.  It needs to register to be
useful, and without rpcbind it cannot register.

nfs-server does not necesarily require rpcbind.  Specifically if
configured for NFSv4 only, nfs-server will work quite happily without

Someone with an NFSv4 only setup who wants rpcbind to not run can use
  systemctl mask rpcbind.socket
to ensure it never runs.
So nfs-server should only "Wants: rpcbind.socket".
I think
 Commit: 4fabfcd08206 ("systemd: Decouple the starting and stopping of
should have changed "Requires" to "Wants" rather than "server" to
to fix the dependency problem.

Finally: After?

It only makes sense to declare an ordering relation as "After:"
something that will actually be started.  If "foo.service" is not part
of the systemd transaction, then "After: foo.service" has no effect.
So having:
  After: rpcbind.socket

doesn't make much sense unless there is some relationship between and rpcbind.socket, and there is no general guarantee
of that (though what individual distros do, I don't know).
So the "After" should match the "Wants" or "Requires".

It might make sense to
  Requires: rpcbind.socket

as it is reasonable to assume that will be ordered with
rpcbind.socket, but as we can use rpcbind.socket explictly, that is

So my conclusion is that nfs-server should:
  Wants: rpcbind.socket
  After: rpcbind.socket

and rpc-statd should
  Requires: rpcbind.socket
  After: rpcbind.socket

which is what this patch puts into effect.

Signed-off-by: NeilBrown <>
Signed-off-by: Steve Dickson <>
 systemd/nfs-server.service | 5 +++--
 systemd/rpc-statd.service  | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/systemd/nfs-server.service b/systemd/nfs-server.service
index 317e5d689767..2ccdc6344cd5 100644
--- a/systemd/nfs-server.service
+++ b/systemd/nfs-server.service
@@ -1,13 +1,14 @@
 Description=NFS server and services
-Requires= proc-fs-nfsd.mount
+Requires= proc-fs-nfsd.mount
 Requires= nfs-mountd.service
 Wants=rpc-statd.service nfs-idmapd.service
-After= proc-fs-nfsd.mount rpcbind.service nfs-mountd.service
+After= proc-fs-nfsd.mount rpcbind.socket nfs-mountd.service
 After= nfs-idmapd.service rpc-statd.service
 Before= rpc-statd-notify.service
diff --git a/systemd/rpc-statd.service b/systemd/rpc-statd.service
index f16ea425dc77..a02f5c41a424 100644
--- a/systemd/rpc-statd.service
+++ b/systemd/rpc-statd.service
@@ -2,8 +2,8 @@
 Description=NFS status monitor for NFSv2/3 locking.
 DefaultDependencies=no rpcbind.service rpcbind.socket rpcbind.socket