From patchwork Wed Feb 5 05:43:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 3584491 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4780F9F2E9 for ; Wed, 5 Feb 2014 05:44:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 437552018E for ; Wed, 5 Feb 2014 05:44:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 006F320181 for ; Wed, 5 Feb 2014 05:44:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751370AbaBEFoF (ORCPT ); Wed, 5 Feb 2014 00:44:05 -0500 Received: from cantor2.suse.de ([195.135.220.15]:42706 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750888AbaBEFoE (ORCPT ); Wed, 5 Feb 2014 00:44:04 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 236BBAAD1; Wed, 5 Feb 2014 05:44:02 +0000 (UTC) Date: Wed, 5 Feb 2014 16:43:51 +1100 From: NeilBrown To: Steve Dickson Cc: linux-nfs@vger.kernel.org Subject: Re: [PATCH/RFC: nfs-utils] Common systemd unit files for nfs-utils. Message-ID: <20140205164351.7a766eff@notabene.brown> In-Reply-To: <52F130E2.6090308@RedHat.com> References: <20140130172451.7a354ce4@notabene.brown> <52F003A1.3060908@RedHat.com> <20140204093452.7b6d7c7d@notabene.brown> <52F130E2.6090308@RedHat.com> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.22; x86_64-suse-linux-gnu) Mime-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 04 Feb 2014 13:26:42 -0500 Steve Dickson wrote: > > > >> > >> How would these daemons be restart and shutdown? Since this is a > >> target, systemctl restart and system stop don't do anything. > > > > This is something I haven't completely figured out yet. > > > > Part of the solution might be the "PartOf" directive. > > If each service claims to be "PartOf" the main one, then stopping or > > restarting the main service will propagate to stopping and restarting the > > individual services. > > Unfortunately in nfs we have some shared services. rpc.statd and rpc.gssd > > are needed by both server and client. That isn't a big problem for 'restart', > > but if you 'systemctl stop nfs-client' and find that the server isn't > > properly working any more, that would be awkward > > If could possibly work around that by setting "StopWhenUnneeded" for those > > shared services. Then e.g. rpc.statd would stop when both client and server > > are stopped, but not if either one of them is stopped. > > However I don't know how that interacts with restart. I suspect that the > > StopWhenUnneeded services are *not* stopped and restarted when the main > > service is stopped. So it would be hard to restart all nfs services on an > > upgrade. > > > > Further research seems needed here. > Fine... I'll try to digest what you are saying here, but > would it make it easier if everything was in a service file? So I did a bit more research and thinking, and I present the two patches below for consideration. If you agree and would prefer them in separate emails I can certainly do that. The first ensures that we can easily restart all daemons during software update. It creates a new 'nfs-utils.service' which exists only to allow that restart. The second ensures startup and shutdown work properly (though I haven't tested much). Do we need to shutdown nfs-server or nfs-client easily at any time other than system shutdown? Thanks, NeilBrown From 0d880d8faf4db7189c11fc13854da82074c260ac Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 5 Feb 2014 16:28:47 +1100 Subject: [PATCH] systemd: add nfs-utils.service which can be used to restart everything. With this patch, systemctl restart nfs-utils will restart any nfs-utils daemons that are currently running, whether there were started via nfs-server.service, nfs-client.target, or directly by systemctl. Signed-off-by: NeilBrown diff --git a/systemd/README b/systemd/README index d697cefbe229..8359530098f4 100644 --- a/systemd/README +++ b/systemd/README @@ -28,6 +28,17 @@ by a suitable 'preset' setting: If enabled, then blkmapd will be run when nfs-client.target is started. +Another special unit is "nfs-utils.service". This doesn't really do +anything, but exists so that other units may declare themselves as +"PartOf" nfs-utils.service. +The effect of this is that + systemctl restart nfs-utils +will restart all nfs-utils daemons as maybe be required during +software update. It isn't possible to make + systemctl try-restart nfs-server nfs-client.target +do this as some daemon are included in both, and rpc.statd would +not be restarted if nfs-server were not active (as nfs-client doesn't +Want it - it is started by mount.nfs running start-statd). It is possible that we should have an nfs-statd.target which can selectively enable statd being stared by -server and sm-notify diff --git a/systemd/nfs-blkmap.service b/systemd/nfs-blkmap.service index 7319a88661cc..80033f2fbcf4 100644 --- a/systemd/nfs-blkmap.service +++ b/systemd/nfs-blkmap.service @@ -6,6 +6,8 @@ Requires=var-lib-nfs-rpc_pipefs.mount Requisite=nfs-blkmap.target After=nfs-blkmap.target +PartOf=nfs-utils.service + [Service] Type=forking ExecStart=/usr/sbin/blkmapd diff --git a/systemd/nfs-idmapd.service b/systemd/nfs-idmapd.service index 6c2e1537f064..7d0dd84d8a44 100644 --- a/systemd/nfs-idmapd.service +++ b/systemd/nfs-idmapd.service @@ -1,6 +1,8 @@ [Unit] Description=NFSv4 ID-name mapping service +PartOf=nfs-utils.service + [Service] EnvironmentFile=-/run/sysconfig/nfs-utils ExecStartPre=-/usr/lib/systemd/scritps/nfs-utils_env.sh diff --git a/systemd/nfs-mountd.service b/systemd/nfs-mountd.service index 92e05ca309ee..90746a854b40 100644 --- a/systemd/nfs-mountd.service +++ b/systemd/nfs-mountd.service @@ -4,6 +4,7 @@ Requires=proc-fs-nfsd.mount After=proc-fs-nfsd.mount After=network.target PartOf=nfs-server.service +PartOf=nfs-utils.service [Service] EnvironmentFile=-/run/sysconfig/nfs-utils diff --git a/systemd/nfs-utils.service b/systemd/nfs-utils.service new file mode 100644 index 000000000000..54b6314d8d52 --- /dev/null +++ b/systemd/nfs-utils.service @@ -0,0 +1,17 @@ +[Unit] +Description=NFS server and client services +# This service should never be stopped, only restarted. +# When it is re-started, all other services which declare +# themselves to be "PartOf" this service will also be +# restarted. Thus +# systemctl restart nfs-utils +# will restart all daemons which are part of nfs-utils +# and which are running. This is useful after a software +# update. + +# This is a "service" rather than "target" so that we +# don't need to say "systemctl restart nfs-utils.target". +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/true diff --git a/systemd/rpc-gssd.service b/systemd/rpc-gssd.service index 8778c3ef651b..3982985762ea 100644 --- a/systemd/rpc-gssd.service +++ b/systemd/rpc-gssd.service @@ -5,6 +5,8 @@ After=var-lib-nfs-rpc_pipefs.mount ConditionPathExists=/etc/krb5.keytab +PartOf=nfs-utils.service + [Service] EnvironmentFile=-/run/sysconfig/nfs-utils ExecStartPre=-/usr/lib/systemd/scritps/nfs-utils_env.sh diff --git a/systemd/rpc-statd-notify.service b/systemd/rpc-statd-notify.service index 9d972fc7753a..532354d64fa0 100644 --- a/systemd/rpc-statd-notify.service +++ b/systemd/rpc-statd-notify.service @@ -8,6 +8,8 @@ After=network-online.target nss-lookup.target # tell clients that it has restarted. After=nfs-server.service +PartOf=nfs-utils.service + [Service] EnvironmentFile=-/run/sysconfig/nfs-utils ExecStartPre=/usr/lib/systemd/scritps/nfs-utils_env.sh diff --git a/systemd/rpc-statd.service b/systemd/rpc-statd.service index 04962e542fbc..88d2527cae9d 100644 --- a/systemd/rpc-statd.service +++ b/systemd/rpc-statd.service @@ -4,6 +4,8 @@ DefaultDependencies=no Requires=nss-lookup.target rpcbind.target After=network.target nss-lookup.target rpcbind.target +PartOf=nfs-utils.service + [Service] EnvironmentFile=-/run/sysconfig/nfs-utils ExecStartPre=-/usr/lib/systemd/scritps/nfs-utils_env.sh diff --git a/systemd/rpc-svcgssd.service b/systemd/rpc-svcgssd.service index 036ec579bfc1..6bd45884d991 100644 --- a/systemd/rpc-svcgssd.service +++ b/systemd/rpc-svcgssd.service @@ -3,6 +3,7 @@ Description=RPC security service for NFS server Requires=var-lib-nfs-rpc_pipefs.mount After=var-lib-nfs-rpc_pipefs.mount PartOf=nfs-server.service +PartOf=nfs-utils.service After=gssproxy.service ConditionPathExists=|!@localstatedir@/run/gssproxy.pid From 30b27a718632e9d24c479921b116d2c3958a3fc2 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 5 Feb 2014 16:36:21 +1100 Subject: [PATCH] systemd: tidy up DefaultDependencies DefaultDependencies should be "yes" (the default) for things needed only be the NFS server, as that is a service that doesn't need to start early. DefaultDependencies should be "no" for things needed to mount an NFS filesystem, and filesystems are mounted before basic.target. To ensure these services are shut down in a timely fashion, they must Conflict with systemd.umount so they are shutdown when everything is unmounted. Signed-off-by: NeilBrown diff --git a/systemd/nfs-blkmap.service b/systemd/nfs-blkmap.service index 80033f2fbcf4..4b74e9f61454 100644 --- a/systemd/nfs-blkmap.service +++ b/systemd/nfs-blkmap.service @@ -1,5 +1,7 @@ [Unit] Description=pNFS block layout mapping daemon +DefaultDependencies=no +Conflicts=umount.target After=var-lib-nfs-rpc_pipefs.mount Requires=var-lib-nfs-rpc_pipefs.mount diff --git a/systemd/nfs-server.service b/systemd/nfs-server.service index 6ba2fc0f346e..5779fd39ed34 100644 --- a/systemd/nfs-server.service +++ b/systemd/nfs-server.service @@ -1,6 +1,5 @@ [Unit] Description=NFS server and services -DefaultDependencies=no Requires= network.target proc-fs-nfsd.mount rpcbind.target Requires= nfs-mountd.service Wants=rpc-statd.service nfs-idmapd.service rpc-gssd.service rpc-svcgssd.service diff --git a/systemd/proc-fs-nfsd.mount b/systemd/proc-fs-nfsd.mount index f44d52f3d67b..931a5ceeb055 100644 --- a/systemd/proc-fs-nfsd.mount +++ b/systemd/proc-fs-nfsd.mount @@ -1,6 +1,5 @@ [Unit] Description=NFSD configuration filesystem -DefaultDependencies=no [Mount] What=nfsd diff --git a/systemd/rpc-gssd.service b/systemd/rpc-gssd.service index 3982985762ea..375792804247 100644 --- a/systemd/rpc-gssd.service +++ b/systemd/rpc-gssd.service @@ -1,5 +1,7 @@ [Unit] Description=RPC security service for NFS client and server +DefaultDependencies=no +Conflicts=umount.target Requires=var-lib-nfs-rpc_pipefs.mount After=var-lib-nfs-rpc_pipefs.mount diff --git a/systemd/rpc-statd-notify.service b/systemd/rpc-statd-notify.service index 532354d64fa0..7742ac8c5d9a 100644 --- a/systemd/rpc-statd-notify.service +++ b/systemd/rpc-statd-notify.service @@ -1,6 +1,5 @@ [Unit] Description=Notify NFS peers of a restart -DefaultDependencies=no Requires=network-online.target After=network-online.target nss-lookup.target diff --git a/systemd/rpc-statd.service b/systemd/rpc-statd.service index 88d2527cae9d..3f6cda16accd 100644 --- a/systemd/rpc-statd.service +++ b/systemd/rpc-statd.service @@ -1,6 +1,7 @@ [Unit] Description=NFS status monitor for NFSv2/3 locking. DefaultDependencies=no +Conflicts=umount.target Requires=nss-lookup.target rpcbind.target After=network.target nss-lookup.target rpcbind.target diff --git a/systemd/var-lib-nfs-rpc_pipefs.mount b/systemd/var-lib-nfs-rpc_pipefs.mount index cd614cf49f00..33c5db65aa38 100644 --- a/systemd/var-lib-nfs-rpc_pipefs.mount +++ b/systemd/var-lib-nfs-rpc_pipefs.mount @@ -1,6 +1,7 @@ [Unit] Description=RPC Pipe File System DefaultDependencies=no +Conflicts=umount.target [Mount] What=sunrpc