add systemd generator for the rpc_pipefs mountpoint
Subsystems (2)
cover add systemd generator for the rpc_pipefs mountpoint
These patches aim to make it a little easier to change the mountpoint. Right now if you change the pipefs-directory in /etc/nfs.conf, you still need to manually override the dependencies in the systemd unit files in order for the change to actually work.
The first patch moves rpc.idmapd's (mostly) undocumented pipefs-directory from /etc/idmapd.conf to /etc/nfs.conf, which rpc.gssd already can use for it's pipefs-directory configuration.
The second patch adds a systemd generator that reads the pipefs-directory configurations from /etc/nfs.conf, and if they differ from the default it will automatically 1) create a systemd mount unit file for the pipefs mountpoint and 2) it will create a drop-in configuration file to override the Requires= and After= directives for that service.
I did run into a bit of a snag though. Depsite overriding the dependencies for both idmapd and gssd, I wind up with two pipefs filesystems mounted:
[root@coeurl ~]# grep pipefs /proc/mounts
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0 sunrpc /run/rpc_pipefs rpc_pipefs rw,relatime 0 0
systemd still shows the dependency on the default pipefs mountpoint:
[root@coeurl ~]# systemctl list-dependencies --before var-lib-nfs-rpc_pipefs.mount var-lib-nfs-rpc_pipefs.mount
● ├─nfs-idmapd.service ● └─rpc-gssd.service
as well as the new one:
[root@coeurl ~]# systemctl list-dependencies --before run-rpc_pipefs.mount run-rpc_pipefs.mount
● ├─nfs-idmapd.service ● └─rpc-gssd.service
The drop-in configs to override the pipefs mountpoint look correct. I'm clearing both Requires= and After= before setting them:
[root@coeurl ~]# cat /run/systemd/generator/nfs-idmapd.service.d/10-pipefs.conf # Automatically generated by rpc-pipefs-generator
[Unit]
Requires=
Requires=run-rpc_pipefs.mount
After=
After=run-rpc_pipefs.mount local-fs.target
[root@coeurl ~]# cat /run/systemd/generator/rpc-gssd.service.d/10-pipefs.conf # Automatically generated by rpc-pipefs-generator
[Unit]
Requires=
Requires=run-rpc_pipefs.mount
After=
After=run-rpc_pipefs.mount
The generated mount unit file also looks correct:
[root@coeurl ~]# cat /run/systemd/generator/run-rpc_pipefs.mount # Automatically generated by rpc-pipefs-generator
[Unit]
Description=RPC Pipe File System
DefaultDependencies=no
After=systemd-tmpfiles-setup.service
Conflicts=umount.target
[Mount]
What=sunrpc
Where=/run/rpc_pipefs
Type=rpc_pipefs
systemd shows that the drop-in config was picked up:
[root@coeurl ~]# systemctl status nfs-idmapd
● nfs-idmapd.service - NFSv4 ID-name mapping service
Loaded: loaded (/usr/lib/systemd/system/nfs-idmapd.service; static; vendor preset: disabled)
Drop-In: /run/systemd/generator/nfs-idmapd.service.d
└─10-pipefs.conf
Active: active (running) since Fri 2017-03-31 16:54:24 EDT; 5min ago
Process: 27831 ExecStart=/usr/sbin/rpc.idmapd $RPCIDMAPDARGS (code=exited, status=0/SUCCESS)
Main PID: 27832 (rpc.idmapd)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/nfs-idmapd.service
└─27832 /usr/sbin/rpc.idmapdand lsof shows that the correct mountpoint is being used:
[root@coeurl ~]# lsof -p 27832 2>/dev/null | grep pipefs
rpc.idmap 27832 root 10r DIR 0,42 0 103 /run/rpc_pipefs/nfs
The same for gssd:
[root@coeurl ~]# systemctl status rpc-gssd
● rpc-gssd.service - RPC security service for NFS client and server
Loaded: loaded (/usr/lib/systemd/system/rpc-gssd.service; static; vendor preset: disabled)
Drop-In: /run/systemd/generator/rpc-gssd.service.d
└─10-pipefs.conf
Active: active (running) since Fri 2017-03-31 16:54:29 EDT; 6min ago
Process: 27839 ExecStart=/usr/sbin/rpc.gssd $RPCGSSDARGS (code=exited, status=0/SUCCESS)
Main PID: 27840 (rpc.gssd)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/rpc-gssd.service
└─27840 /usr/sbin/rpc.gssd[root@coeurl ~]# lsof -p 27840 2>/dev/null | grep pipefs
rpc.gssd 27840 root cwd DIR 0,42 0 24637 /run/rpc_pipefs rpc.gssd 27840 root 7r DIR 0,42 0 24637 /run/rpc_pipefs rpc.gssd 27840 root 11u FIFO 0,42 0t0 112 /run/rpc_pipefs/gssd/clntXX/gssd
So it looks like systemd is using both sets of dependencies, even though the programs themselves are only looking for what's specified in /etc/nfs.conf. I'm not sure what to do about that. Maybe remove the var-lib-nfs-rpc_pipefs.mount unit as well as the dependencies in the nfs-idmapd.service and rpc-gssd.service files, and have the generator create those automatically as well?
-Scott
Scott Mayhew (2):
idmapd: move the pipefs-directory config option to nfs.conf
systemd: add a generator for the rpc_pipefs mountpoint
.gitignore | 1 + nfs.conf | 3 + systemd/Makefile.am | 4 +- systemd/nfs.conf.man | 9 ++ systemd/rpc-pipefs-generator.c | 256 +++++++++++++++++++++++++++++++++++++++++ systemd/rpc-svcgssd.service | 3 +- utils/idmapd/idmapd.c | 35 +++--- utils/idmapd/idmapd.man | 19 ++- 8 files changed, 305 insertions(+), 25 deletions(-) create mode 100644 systemd/rpc-pipefs-generator.c
Signature · 1 line
2.9.3
RFC PATCH 1/2 idmapd: move the pipefs-directory config option to nfs.conf
Changed idmapd to read its value for the pipefs-directory from /etc/nfs.conf rather than /etc/idmapd.conf. All other configurations related to id mapping still reside in /etc/idmapd.conf for now.
Removed the -c option, since it would be confusing as whether it should override nfs.conf, idmapd.conf, or both.
--- nfs.conf | 3 +++ systemd/nfs.conf.man | 9 +++++++++ utils/idmapd/idmapd.c | 35 ++++++++++++++--------------------- utils/idmapd/idmapd.man | 19 ++++++++++++++++++- 4 files changed, 44 insertions(+), 22 deletions(-)
nfs.conf +3 -0
@@ -17,6 +17,9 @@ # cred-cache-directory= # preferred-realm= # +#[idmapd] +# pipefs-directory=/var/lib/nfs/rpc_pipefs +# #[lockd] # port=0 # udp-port=0
systemd/nfs.conf.man +9 -0
@@ -215,6 +215,15 @@ See for details. .TP +.B idmapd +Recognized values: +.BR pipefs-directory . + +See +.BR rpc.idmapd (8) +for details. + +.TP .B svcgssd Recognized values: .BR principal .
utils/idmapd/idmapd.c +14 -21
@@ -214,13 +214,11 @@ main(int argc, char **argv)struct event initialize;struct passwd *pw;struct group *gr; -struct stat sb;char *xpipefsdir =NULL ;int serverstart =1 , clientstart =1 ;int ret;char *progname; - conf_path = _PATH_IDMAPDCONF; nobodyuser =NFS4NOBODY_USER ; nobodygroup =NFS4NOBODY_GROUP ;strlcpy (pipefsdir,PIPEFS_DIR ,sizeof (pipefsdir));
@@ -231,11 +229,9 @@ main(int argc, char **argv) progname = argv[0 ];xlog_open (progname); -#define GETOPTSTR "hvfd:p:U:G:c:CS" +#define GETOPTSTR "hvfd:p:U:G:CS" opterr=0 ;/* Turn off error messages */ while ((opt =getopt (argc, argv,GETOPTSTR )) !=-1 ) { -if (opt =='c' ) - conf_path = optarg;if (opt =='?' ) {if (strchr (GETOPTSTR , optopt))warnx ("'-%c' option requires an argument." , optopt);
@@ -247,20 +243,19 @@ main(int argc, char **argv) } optind =1 ; -if (stat (conf_path, &sb) ==-1 && (errno ==ENOENT || errno ==EACCES )) { -warn ("Skipping configuration file \"%s\"" , conf_path); - conf_path =NULL ; - }else { -conf_init (); - verbose =conf_get_num ("General" ,"Verbosity" ,0 ); - cache_entry_expiration =conf_get_num ("General" , -"Cache-Expiration" ,DEFAULT_IDMAP_CACHE_EXPIRY ); -CONF_SAVE (xpipefsdir,conf_get_str ("General" ,"Pipefs-Directory" )); -if (xpipefsdir !=NULL ) -strlcpy (pipefsdir, xpipefsdir,sizeof (pipefsdir)); -CONF_SAVE (nobodyuser,conf_get_str ("Mapping" ,"Nobody-User" )); -CONF_SAVE (nobodygroup,conf_get_str ("Mapping" ,"Nobody-Group" )); - } + conf_path =NFS_CONFFILE ; +conf_init (); +CONF_SAVE (xpipefsdir,conf_get_str ("idmapd" ,"pipefs-directory" )); +if (xpipefsdir !=NULL ) +strlcpy (pipefsdir, xpipefsdir,sizeof (pipefsdir)); + + conf_path = _PATH_IDMAPDCONF; +conf_init (); + verbose =conf_get_num ("General" ,"Verbosity" ,0 ); + cache_entry_expiration =conf_get_num ("General" , +"cache-expiration" ,DEFAULT_IDMAP_CACHE_EXPIRY ); +CONF_SAVE (nobodyuser,conf_get_str ("Mapping" ,"Nobody-User" )); +CONF_SAVE (nobodygroup,conf_get_str ("Mapping" ,"Nobody-Group" ));while ((opt =getopt (argc, argv,GETOPTSTR )) !=-1 )switch (opt) {
@@ -307,8 +302,6 @@ main(int argc, char **argv)#ifdef HAVE_NFS4_SET_DEBUG nfs4_set_debug (verbose, xlog_warn);#endif -if (conf_path ==NULL ) - conf_path = _PATH_IDMAPDCONF;if (nfs4_init_name_mapping (conf_path))errx (1 ,"Unable to create name to user id mappings." );
utils/idmapd/idmapd.man +18 -1
@@ -78,6 +78,21 @@ Client-only: perform no idmapping for any NFS server, even if one is detected. .It Fl S Server-only: perform no idmapping for any NFS client, even if one is detected. .El +.Sh CONFIGURATION FILES +The +.Sy [idmapd] +section of the +.Pa /etc/nfs.conf +configuration file recognizes the following value: +.Bl -tag -width Ds_imagedir +.It Sy pipefs-directory +Equivalent to +.Sy -p . +.El +.Pp +All other settings related to id mapping are found in the +.Pa /etc/idmapd.conf +configuration file. .Sh EXAMPLES .Cm rpc.idmapd -f -vvv .Pp
@@ -94,9 +109,11 @@ messages to console, and with a verbosity level of 3. .\" This next request is for sections 1, 6, 7 & 8 only. .\" .Sh ENVIRONMENT .Sh FILES -.Pa /etc/idmapd.conf +.Pa /etc/idmapd.conf , +.Pa /etc/nfs.conf .Sh SEE ALSO .Xr idmapd.conf 5 , +.Xr nfs.conf 5 , .Xr nfsidmap 8 .\".Sh SEE ALSO .\".Xr nylon.conf 4
Signature · 1 line
2.9.3
RFC PATCH 2/2 systemd: add a generator for the rpc_pipefs mountpoint
In reply to Scott MayhewThe nfs.conf has config options for the pipefs mountpoint. Currently, changing these from the default also requires manually overriding the systemd unit files that are hard-coded to mount the filesystem on /var/lib/nfs/rpc_pipefs.
This patch adds a generator that creates a mount unit file for the pipefs when a non-default value is specified in /etc/nfs.conf, as well as drop-in config files to override the dependencies for the systemd units using the pipefs.
This patch also removes the dependency on the pipefs from the rpc-svcgssd.service unit file. rpc.svcgssd uses the sunrpc cache mechanism to exchange data with the kernel, not the pipefs.
--- .gitignore | 1 + systemd/Makefile.am | 4 +- systemd/rpc-pipefs-generator.c | 256 +++++++++++++++++++++++++++++++++++++++++ systemd/rpc-svcgssd.service | 3 +- 4 files changed, 261 insertions(+), 3 deletions(-) create mode 100644 systemd/rpc-pipefs-generator.c
.gitignore +1 -0
@@ -70,6 +70,7 @@ tests/nsm_client/nlm_sm_inter_svc.c tests/nsm_client/nlm_sm_inter_xdr.c utils/nfsidmap/nfsidmap systemd/nfs-server-generator +systemd/rpc-pipefs-generator systemd/nfs-config.service systemd/rpc-gssd.service # cscope database files
systemd/Makefile.am +3 -1
@@ -42,12 +42,14 @@ EXTRA_DIST = $(unit_files) $(man5_MANS) $(man7_MANS) unit_dir = /usr/lib/systemd/system generator_dir = /usr/lib/systemd/system-generators -EXTRA_PROGRAMS = nfs-server-generator +EXTRA_PROGRAMS = nfs-server-generator rpc-pipefs-generator genexecdir = $(generator_dir) nfs_server_generator_LDADD = ../support/export/libexport.a \ ../support/nfs/libnfs.a \ ../support/misc/libmisc.a +rpc_pipefs_generator_LDADD = ../support/nfs/libnfs.a + if INSTALL_SYSTEMD genexec_PROGRAMS = nfs-server-generator install-data-hook: $(unit_files)
systemd/rpc-pipefs-generator.c new file +256 -0
256 lines not on this page · raw message
systemd/rpc-svcgssd.service +1 -2
@@ -1,8 +1,7 @@ [Unit] Description=RPC security service for NFS server DefaultDependencies=no -Requires=var-lib-nfs-rpc_pipefs.mount -After=var-lib-nfs-rpc_pipefs.mount local-fs.target +After=local-fs.target PartOf=nfs-server.service PartOf=nfs-utils.service
Signature · 1 line
2.9.3
Quoted 113 lines · Scott Mayhew
These patches aim to make it a little easier to change the mountpoint. Right now if you change the pipefs-directory in
/etc/nfs.conf, you still need to manually override the dependencies in the systemd unit files in order for the change to actually work.The first patch moves rpc.idmapd's (mostly) undocumented pipefs-directory from
/etc/idmapd.confto/etc/nfs.conf, which rpc.gssd already can use for it's pipefs-directory configuration.The second patch adds a systemd generator that reads the pipefs-directory configurations from
/etc/nfs.conf, and if they differ from the default it will automatically 1) create a systemd mount unit file for the pipefs mountpoint and 2) it will create a drop-in configuration file to override the Requires= and After= directives for that service.I did run into a bit of a snag though. Depsite overriding the dependencies for both idmapd and gssd, I wind up with two pipefs filesystems mounted:
[root@coeurl ~]# grep pipefs
/proc/mounts
sunrpc/var/lib/nfs/rpc_pipefsrpc_pipefsrw,relatime 0 0 sunrpc/run/rpc_pipefsrpc_pipefsrw,relatime 0 0systemd still shows the dependency on the default pipefs mountpoint:
[root@coeurl ~]# systemctl list-dependencies --before var-lib-nfs-rpc_pipefs.mount var-lib-nfs-rpc_pipefs.mount
● ├─nfs-idmapd.service ● └─rpc-gssd.serviceas well as the new one:
[root@coeurl ~]# systemctl list-dependencies --before run-rpc_pipefs.mount run-rpc_pipefs.mount
● ├─nfs-idmapd.service ● └─rpc-gssd.serviceThe drop-in configs to override the pipefs mountpoint look correct. I'm clearing both Requires= and After= before setting them:
[root@coeurl ~]# cat
/run/systemd/generator/nfs-idmapd.service.d/10-pipefs.conf# Automatically generated by rpc-pipefs-generator[Unit]
Requires=
Requires=run-rpc_pipefs.mount
After=
After=run-rpc_pipefs.mount local-fs.target[root@coeurl ~]# cat
/run/systemd/generator/rpc-gssd.service.d/10-pipefs.conf# Automatically generated by rpc-pipefs-generator[Unit]
Requires=
Requires=run-rpc_pipefs.mount
After=
After=run-rpc_pipefs.mountThe generated mount unit file also looks correct:
[root@coeurl ~]# cat
/run/systemd/generator/run-rpc_pipefs.mount# Automatically generated by rpc-pipefs-generator[Unit]
Description=RPC Pipe File System
DefaultDependencies=no
After=systemd-tmpfiles-setup.service
Conflicts=umount.target[Mount]
What=sunrpc
Where=/run/rpc_pipefs
Type=rpc_pipefssystemd shows that the drop-in config was picked up:
[root@coeurl ~]# systemctl status nfs-idmapd
● nfs-idmapd.service - NFSv4 ID-name mapping service
Loaded: loaded (/usr/lib/systemd/system/nfs-idmapd.service; static; vendor preset: disabled)
Drop-In:/run/systemd/generator/nfs-idmapd.service.d
└─10-pipefs.conf
Active: active (running) since Fri 2017-03-31 16:54:24 EDT; 5min ago
Process: 27831 ExecStart=/usr/sbin/rpc.idmapd $RPCIDMAPDARGS (code=exited, status=0/SUCCESS)
Main PID: 27832 (rpc.idmapd)Tasks: 1 (limit: 4915) CGroup: /system.slice/nfs-idmapd.service └─27832 /usr/sbin/rpc.idmapdand lsof shows that the correct mountpoint is being used:
[root@coeurl ~]# lsof -p 27832 2>/dev/null | grep pipefs
rpc.idmap 27832 root 10r DIR 0,42 0 103/run/rpc_pipefs/nfsThe same for gssd:
[root@coeurl ~]# systemctl status rpc-gssd
● rpc-gssd.service - RPC security service for NFS client and server
Loaded: loaded (/usr/lib/systemd/system/rpc-gssd.service; static; vendor preset: disabled)
Drop-In:/run/systemd/generator/rpc-gssd.service.d
└─10-pipefs.conf
Active: active (running) since Fri 2017-03-31 16:54:29 EDT; 6min ago
Process: 27839 ExecStart=/usr/sbin/rpc.gssd $RPCGSSDARGS (code=exited, status=0/SUCCESS)
Main PID: 27840 (rpc.gssd)Tasks: 1 (limit: 4915) CGroup: /system.slice/rpc-gssd.service └─27840 /usr/sbin/rpc.gssd[root@coeurl ~]# lsof -p 27840 2>/dev/null | grep pipefs
rpc.gssd 27840 root cwd DIR 0,42 0 24637 /run/rpc_pipefs rpc.gssd 27840 root 7r DIR 0,42 0 24637 /run/rpc_pipefs rpc.gssd 27840 root 11u FIFO 0,42 0t0 112 /run/rpc_pipefs/gssd/clntXX/gssd
Quoted 7 lines
So it looks like systemd is using both sets of dependencies, even though the programs themselves are only looking for what's specified in
/etc/nfs.conf. I'm not sure what to do about that. Maybe remove the var-lib-nfs-rpc_pipefs.mount unit as well as the dependencies in the nfs-idmapd.service and rpc-gssd.service files, and have the generator create those automatically as well?
Towards the end of the systemd.unit man page is the text:
Note that dependencies (After=, etc.) cannot be reset to an empty list,
so dependencies can only be added in drop-ins. If you want to remove dependencies, you have to override the entire unit.
which is consistent with what you discovered.
Maybe create a "rpc_pipefs.target" which
Requires=var-lib-nfs-rpc_pipefs.mount After=var-lib-nfs-rpc_pipefs.mount
and have all the other unit files specified their dependencies against this target.
Then your generator would conditionally create a new "rpc_pipefs.target" and matching foo.mount. The new .target would depend in the foo.mount, and the service files would already depend on that.
Might work.
Thanks,
NeilBrown
Quoted 24 lines
-Scott
Scott Mayhew (2):
idmapd: move the pipefs-directory config option to nfs.conf
systemd: add a generator for therpc_pipefsmountpoint.gitignore | 1 + nfs.conf | 3 + systemd/Makefile.am | 4 +- systemd/nfs.conf.man | 9 ++ systemd/rpc-pipefs-generator.c | 256 +++++++++++++++++++++++++++++++++++++++++ systemd/rpc-svcgssd.service | 3 +- utils/idmapd/idmapd.c | 35 +++--- utils/idmapd/idmapd.man | 19 ++- 8 files changed, 305 insertions(+), 25 deletions(-) create mode 100644 systemd/rpc-pipefs-generator.cSignature · 6 lines
2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC nfs-utils PATCH 1/2] idmapd: move the pipefs-directory config option to nfs.conf
In reply to Scott MayhewQuoted 6 lines · Scott Mayhew
Changed idmapd to read its value for the pipefs-directory from
/etc/nfs.confrather than/etc/idmapd.conf. All other configurations related to id mapping still reside in/etc/idmapd.conffor now.Removed the -c option, since it would be confusing as whether it should override nfs.conf, idmapd.conf, or both.
You didn't remove mention of the -c option from idmapd.man. Otherwise:
Thanks,
NeilBrown
Quoted 163 lines
Signed-off-by Scott Mayhew <[email protected]>--- nfs.conf | 3 +++ systemd/nfs.conf.man | 9 +++++++++ utils/idmapd/idmapd.c | 35 ++++++++++++++--------------------- utils/idmapd/idmapd.man | 19 ++++++++++++++++++- 4 files changed, 44 insertions(+), 22 deletions(-)nfs.conf +3
-0@@ -17,6 +17,9 @@ # cred-cache-directory= # preferred-realm= # +#[idmapd] +# pipefs-directory=/var/lib/nfs/rpc_pipefs +# #[lockd] # port=0 # udp-port=0systemd/nfs.conf.man +9
-0@@ -215,6 +215,15 @@ See for details. .TP +.B idmapd +Recognized values: +.BR pipefs-directory . + +See +.BR rpc.idmapd (8) +for details. + +.TP .B svcgssd Recognized values: .BR principal .utils/idmapd/idmapd.c +14
-21@@ -214,13 +214,11 @@ main(int argc, char **argv)struct event initialize;struct passwd *pw;struct group *gr; -struct stat sb;char *xpipefsdir =NULL ;int serverstart =1 , clientstart =1 ;int ret;char *progname; - conf_path = _PATH_IDMAPDCONF; nobodyuser =NFS4NOBODY_USER ; nobodygroup =NFS4NOBODY_GROUP ;strlcpy (pipefsdir,PIPEFS_DIR ,sizeof (pipefsdir));@@ -231,11 +229,9 @@ main(int argc, char **argv) progname = argv[0 ];xlog_open (progname); -#define GETOPTSTR "hvfd:p:U:G:c:CS" +#define GETOPTSTR "hvfd:p:U:G:CS" opterr=0 ;/* Turn off error messages */ while ((opt =getopt (argc, argv,GETOPTSTR )) !=-1 ) { -if (opt =='c' ) - conf_path = optarg;if (opt =='?' ) {if (strchr (GETOPTSTR , optopt))warnx ("'-%c' option requires an argument." , optopt);@@ -247,20 +243,19 @@ main(int argc, char **argv) } optind =1 ; -if (stat (conf_path, &sb) ==-1 && (errno ==ENOENT || errno ==EACCES )) { -warn ("Skipping configuration file \"%s\"" , conf_path); - conf_path =NULL ; - }else { -conf_init (); - verbose =conf_get_num ("General" ,"Verbosity" ,0 ); - cache_entry_expiration =conf_get_num ("General" , -"Cache-Expiration" ,DEFAULT_IDMAP_CACHE_EXPIRY ); -CONF_SAVE (xpipefsdir,conf_get_str ("General" ,"Pipefs-Directory" )); -if (xpipefsdir !=NULL ) -strlcpy (pipefsdir, xpipefsdir,sizeof (pipefsdir)); -CONF_SAVE (nobodyuser,conf_get_str ("Mapping" ,"Nobody-User" )); -CONF_SAVE (nobodygroup,conf_get_str ("Mapping" ,"Nobody-Group" )); - } + conf_path =NFS_CONFFILE ; +conf_init (); +CONF_SAVE (xpipefsdir,conf_get_str ("idmapd" ,"pipefs-directory" )); +if (xpipefsdir !=NULL ) +strlcpy (pipefsdir, xpipefsdir,sizeof (pipefsdir)); + + conf_path = _PATH_IDMAPDCONF; +conf_init (); + verbose =conf_get_num ("General" ,"Verbosity" ,0 ); + cache_entry_expiration =conf_get_num ("General" , +"cache-expiration" ,DEFAULT_IDMAP_CACHE_EXPIRY ); +CONF_SAVE (nobodyuser,conf_get_str ("Mapping" ,"Nobody-User" )); +CONF_SAVE (nobodygroup,conf_get_str ("Mapping" ,"Nobody-Group" ));while ((opt =getopt (argc, argv,GETOPTSTR )) !=-1 )switch (opt) {@@ -307,8 +302,6 @@ main(int argc, char **argv)#ifdef HAVE_NFS4_SET_DEBUG nfs4_set_debug (verbose, xlog_warn);#endif -if (conf_path ==NULL ) - conf_path = _PATH_IDMAPDCONF;if (nfs4_init_name_mapping (conf_path))errx (1 ,"Unable to create name to user id mappings." );utils/idmapd/idmapd.man +18
-1@@ -78,6 +78,21 @@ Client-only: perform no idmapping for any NFS server, even if one is detected. .It Fl S Server-only: perform no idmapping for any NFS client, even if one is detected. .El +.Sh CONFIGURATION FILES +The +.Sy [idmapd] +section of the +.Pa /etc/nfs.conf +configuration file recognizes the following value: +.Bl -tag -width Ds_imagedir +.It Sy pipefs-directory +Equivalent to +.Sy -p . +.El +.Pp +All other settings related to id mapping are found in the +.Pa /etc/idmapd.conf +configuration file. .Sh EXAMPLES .Cm rpc.idmapd -f -vvv .Pp@@ -94,9 +109,11 @@ messages to console, and with a verbosity level of 3. .\" This next request is for sections 1, 6, 7 & 8 only. .\" .Sh ENVIRONMENT .Sh FILES -.Pa /etc/idmapd.conf +.Pa /etc/idmapd.conf , +.Pa /etc/nfs.conf .Sh SEE ALSO .Xr idmapd.conf 5 , +.Xr nfs.conf 5 , .Xr nfsidmap 8 .\".Sh SEE ALSO .\".Xr nylon.conf 4Signature · 6 lines
2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 123 lines · NeilBrown
Quoted 113 lines · Scott Mayhew
These patches aim to make it a little easier to change the mountpoint. Right now if you change the pipefs-directory in
/etc/nfs.conf, you still need to manually override the dependencies in the systemd unit files in order for the change to actually work.The first patch moves rpc.idmapd's (mostly) undocumented pipefs-directory from
/etc/idmapd.confto/etc/nfs.conf, which rpc.gssd already can use for it's pipefs-directory configuration.The second patch adds a systemd generator that reads the pipefs-directory configurations from
/etc/nfs.conf, and if they differ from the default it will automatically 1) create a systemd mount unit file for the pipefs mountpoint and 2) it will create a drop-in configuration file to override the Requires= and After= directives for that service.I did run into a bit of a snag though. Depsite overriding the dependencies for both idmapd and gssd, I wind up with two pipefs filesystems mounted:
[root@coeurl ~]# grep pipefs
/proc/mounts
sunrpc/var/lib/nfs/rpc_pipefsrpc_pipefsrw,relatime 0 0 sunrpc/run/rpc_pipefsrpc_pipefsrw,relatime 0 0systemd still shows the dependency on the default pipefs mountpoint:
[root@coeurl ~]# systemctl list-dependencies --before var-lib-nfs-rpc_pipefs.mount var-lib-nfs-rpc_pipefs.mount
● ├─nfs-idmapd.service ● └─rpc-gssd.serviceas well as the new one:
[root@coeurl ~]# systemctl list-dependencies --before run-rpc_pipefs.mount run-rpc_pipefs.mount
● ├─nfs-idmapd.service ● └─rpc-gssd.serviceThe drop-in configs to override the pipefs mountpoint look correct. I'm clearing both Requires= and After= before setting them:
[root@coeurl ~]# cat
/run/systemd/generator/nfs-idmapd.service.d/10-pipefs.conf# Automatically generated by rpc-pipefs-generator[Unit]
Requires=
Requires=run-rpc_pipefs.mount
After=
After=run-rpc_pipefs.mount local-fs.target[root@coeurl ~]# cat
/run/systemd/generator/rpc-gssd.service.d/10-pipefs.conf# Automatically generated by rpc-pipefs-generator[Unit]
Requires=
Requires=run-rpc_pipefs.mount
After=
After=run-rpc_pipefs.mountThe generated mount unit file also looks correct:
[root@coeurl ~]# cat
/run/systemd/generator/run-rpc_pipefs.mount# Automatically generated by rpc-pipefs-generator[Unit]
Description=RPC Pipe File System
DefaultDependencies=no
After=systemd-tmpfiles-setup.service
Conflicts=umount.target[Mount]
What=sunrpc
Where=/run/rpc_pipefs
Type=rpc_pipefssystemd shows that the drop-in config was picked up:
[root@coeurl ~]# systemctl status nfs-idmapd
● nfs-idmapd.service - NFSv4 ID-name mapping service
Loaded: loaded (/usr/lib/systemd/system/nfs-idmapd.service; static; vendor preset: disabled)
Drop-In:/run/systemd/generator/nfs-idmapd.service.d
└─10-pipefs.conf
Active: active (running) since Fri 2017-03-31 16:54:24 EDT; 5min ago
Process: 27831 ExecStart=/usr/sbin/rpc.idmapd $RPCIDMAPDARGS (code=exited, status=0/SUCCESS)
Main PID: 27832 (rpc.idmapd)Tasks: 1 (limit: 4915) CGroup: /system.slice/nfs-idmapd.service └─27832 /usr/sbin/rpc.idmapdand lsof shows that the correct mountpoint is being used:
[root@coeurl ~]# lsof -p 27832 2>/dev/null | grep pipefs
rpc.idmap 27832 root 10r DIR 0,42 0 103/run/rpc_pipefs/nfsThe same for gssd:
[root@coeurl ~]# systemctl status rpc-gssd
● rpc-gssd.service - RPC security service for NFS client and server
Loaded: loaded (/usr/lib/systemd/system/rpc-gssd.service; static; vendor preset: disabled)
Drop-In:/run/systemd/generator/rpc-gssd.service.d
└─10-pipefs.conf
Active: active (running) since Fri 2017-03-31 16:54:29 EDT; 6min ago
Process: 27839 ExecStart=/usr/sbin/rpc.gssd $RPCGSSDARGS (code=exited, status=0/SUCCESS)
Main PID: 27840 (rpc.gssd)Tasks: 1 (limit: 4915) CGroup: /system.slice/rpc-gssd.service └─27840 /usr/sbin/rpc.gssd[root@coeurl ~]# lsof -p 27840 2>/dev/null | grep pipefs
rpc.gssd 27840 root cwd DIR 0,42 0 24637 /run/rpc_pipefs rpc.gssd 27840 root 7r DIR 0,42 0 24637 /run/rpc_pipefs rpc.gssd 27840 root 11u FIFO 0,42 0t0 112 /run/rpc_pipefs/gssd/clntXX/gssdQuoted 7 lines
So it looks like systemd is using both sets of dependencies, even though the programs themselves are only looking for what's specified in
/etc/nfs.conf. I'm not sure what to do about that. Maybe remove the var-lib-nfs-rpc_pipefs.mount unit as well as the dependencies in the nfs-idmapd.service and rpc-gssd.service files, and have the generator create those automatically as well?
Quoted 8 lines
Towards the end of the systemd.unit man page is the text:
Note that dependencies (After=, etc.) cannot be reset to an empty list,
so dependencies can only be added in drop-ins. If you want to remove dependencies, you have to override the entire unit.which is consistent with what you discovered.
Doh, that's what I get for not reading all the way to the end.
Quoted 7 lines
Maybe create a "rpc_pipefs.target" which
Requires=var-lib-nfs-rpc_pipefs.mount After=var-lib-nfs-rpc_pipefs.mount
and have all the other unit files specified their dependencies against this target.
Quoted 5 lines
Then your generator would conditionally create a new "rpc_pipefs.target" and matching foo.mount. The new .target would depend in the foo.mount, and the service files would already depend on that.
Might work.
That looks like it works, but what should happen then if programs were to intentionally specify two different values for the pipefs-directory in nfs.conf? Or is that something that wouldn't make sense to do and should be prevented? I can't think of a reason why you'd want more than one rpc_pipefs filesystem mounted...
Maybe it would make sense to create a 'global' section and have the programs all look at that instead of looking in their specific config sections... or maybe have the program check global section and then a program-specific section, but include a big fat warning that if you specify it in the program-specific section then you need to override all of them with the same value.
-Scott
Quoted 29 lines
Thanks,
NeilBrownQuoted 24 lines
-Scott
Scott Mayhew (2):
idmapd: move the pipefs-directory config option to nfs.conf
systemd: add a generator for therpc_pipefsmountpoint.gitignore | 1 + nfs.conf | 3 + systemd/Makefile.am | 4 +- systemd/nfs.conf.man | 9 ++ systemd/rpc-pipefs-generator.c | 256 +++++++++++++++++++++++++++++++++++++++++ systemd/rpc-svcgssd.service | 3 +- utils/idmapd/idmapd.c | 35 +++--- utils/idmapd/idmapd.man | 19 ++- 8 files changed, 305 insertions(+), 25 deletions(-) create mode 100644 systemd/rpc-pipefs-generator.cSignature · 6 lines
2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC nfs-utils PATCH 1/2] idmapd: move the pipefs-directory config option to nfs.conf
In reply to Scott MayhewSorry for the delayed response... A long weekend ;-)
Quoted 39 lines · Scott Mayhew
Changed idmapd to read its value for the pipefs-directory from
/etc/nfs.confrather than/etc/idmapd.conf. All other configurations related to id mapping still reside in/etc/idmapd.conffor now.Removed the -c option, since it would be confusing as whether it should override nfs.conf, idmapd.conf, or both.
Signed-off-by Scott Mayhew <[email protected]>--- nfs.conf | 3 +++ systemd/nfs.conf.man | 9 +++++++++ utils/idmapd/idmapd.c | 35 ++++++++++++++--------------------- utils/idmapd/idmapd.man | 19 ++++++++++++++++++- 4 files changed, 44 insertions(+), 22 deletions(-)nfs.conf +3
-0@@ -17,6 +17,9 @@ # cred-cache-directory= # preferred-realm= # +#[idmapd] +# pipefs-directory=/var/lib/nfs/rpc_pipefs +# #[lockd] # port=0 # udp-port=0systemd/nfs.conf.man +2
-0@@ -215,6 +215,15 @@ See for details. .TP +.B idmapd +Recognized values:
systemd/nfs.conf.man See · line 229
Quoted 10 lines
systemd/nfs.conf.man +7
-0+.BR pipefs-directory . + +See +.BR rpc.idmapd (8) +for details. + +.TP .B svcgssd Recognized values: .BR principal .
Now that the pipefs-directory define for both gssd and idmap, let move the definition into a [global] section so it does not have to changed in two different places.
Quoted 19 lines
utils/idmapd/idmapd.c +0
-2@@ -214,13 +214,11 @@ main(int argc, char **argv)struct event initialize;struct passwd *pw;struct group *gr; -struct stat sb;char *xpipefsdir =NULL ;int serverstart =1 , clientstart =1 ;int ret;char *progname; - conf_path = _PATH_IDMAPDCONF; nobodyuser =NFS4NOBODY_USER ; nobodygroup =NFS4NOBODY_GROUP ;strlcpy (pipefsdir,PIPEFS_DIR ,sizeof (pipefsdir));
utils/idmapd/idmapd.c main(int argc, char **argv) · line 238
Quoted 9 lines
utils/idmapd/idmapd.c +1
-3@@ -231,11 +229,9 @@ main(int argc, char **argv) progname = argv[0 ];xlog_open (progname); -#define GETOPTSTR "hvfd:p:U:G:c:CS" +#define GETOPTSTR "hvfd:p:U:G:CS" opterr=0 ;/* Turn off error messages */ while ((opt =getopt (argc, argv,GETOPTSTR )) !=-1 ) { -if (opt =='c' ) - conf_path = optarg;
Removing command line argument (aka changing API) is always a difficult thing... IMHO. You never know what you are going to break...
How about this... Instead just removing the flag, deprecated it. Meaning when the flag is use throw out an error message saying the flag has be deprecated, please use /etc/nfs.conf. Also mentioning in the man page will probably give us enough cover :-)
BTW, thanks for do this work!
steved.
Quoted 86 lines
utils/idmapd/idmapd.c +13
-16if (opt =='?' ) {if (strchr (GETOPTSTR , optopt))warnx ("'-%c' option requires an argument." , optopt);@@ -247,20 +243,19 @@ main(int argc, char **argv) } optind =1 ; -if (stat (conf_path, &sb) ==-1 && (errno ==ENOENT || errno ==EACCES )) { -warn ("Skipping configuration file \"%s\"" , conf_path); - conf_path =NULL ; - }else { -conf_init (); - verbose =conf_get_num ("General" ,"Verbosity" ,0 ); - cache_entry_expiration =conf_get_num ("General" , -"Cache-Expiration" ,DEFAULT_IDMAP_CACHE_EXPIRY ); -CONF_SAVE (xpipefsdir,conf_get_str ("General" ,"Pipefs-Directory" )); -if (xpipefsdir !=NULL ) -strlcpy (pipefsdir, xpipefsdir,sizeof (pipefsdir)); -CONF_SAVE (nobodyuser,conf_get_str ("Mapping" ,"Nobody-User" )); -CONF_SAVE (nobodygroup,conf_get_str ("Mapping" ,"Nobody-Group" )); - } + conf_path =NFS_CONFFILE ; +conf_init (); +CONF_SAVE (xpipefsdir,conf_get_str ("idmapd" ,"pipefs-directory" )); +if (xpipefsdir !=NULL ) +strlcpy (pipefsdir, xpipefsdir,sizeof (pipefsdir)); + + conf_path = _PATH_IDMAPDCONF; +conf_init (); + verbose =conf_get_num ("General" ,"Verbosity" ,0 ); + cache_entry_expiration =conf_get_num ("General" , +"cache-expiration" ,DEFAULT_IDMAP_CACHE_EXPIRY ); +CONF_SAVE (nobodyuser,conf_get_str ("Mapping" ,"Nobody-User" )); +CONF_SAVE (nobodygroup,conf_get_str ("Mapping" ,"Nobody-Group" ));while ((opt =getopt (argc, argv,GETOPTSTR )) !=-1 )switch (opt) {@@ -307,8 +302,6 @@ main(int argc, char **argv)#ifdef HAVE_NFS4_SET_DEBUG nfs4_set_debug (verbose, xlog_warn);#endif -if (conf_path ==NULL ) - conf_path = _PATH_IDMAPDCONF;if (nfs4_init_name_mapping (conf_path))errx (1 ,"Unable to create name to user id mappings." );utils/idmapd/idmapd.man +18
-1@@ -78,6 +78,21 @@ Client-only: perform no idmapping for any NFS server, even if one is detected. .It Fl S Server-only: perform no idmapping for any NFS client, even if one is detected. .El +.Sh CONFIGURATION FILES +The +.Sy [idmapd] +section of the +.Pa /etc/nfs.conf +configuration file recognizes the following value: +.Bl -tag -width Ds_imagedir +.It Sy pipefs-directory +Equivalent to +.Sy -p . +.El +.Pp +All other settings related to id mapping are found in the +.Pa /etc/idmapd.conf +configuration file. .Sh EXAMPLES .Cm rpc.idmapd -f -vvv .Pp@@ -94,9 +109,11 @@ messages to console, and with a verbosity level of 3. .\" This next request is for sections 1, 6, 7 & 8 only. .\" .Sh ENVIRONMENT .Sh FILES -.Pa /etc/idmapd.conf +.Pa /etc/idmapd.conf , +.Pa /etc/nfs.conf .Sh SEE ALSO .Xr idmapd.conf 5 , +.Xr nfs.conf 5 , .Xr nfsidmap 8 .\".Sh SEE ALSO .\".Xr nylon.conf 4
Quoted 147 lines · Scott Mayhew
Quoted 123 lines · NeilBrown
Quoted 113 lines · Scott Mayhew
These patches aim to make it a little easier to change the mountpoint. Right now if you change the pipefs-directory in
/etc/nfs.conf, you still need to manually override the dependencies in the systemd unit files in order for the change to actually work.The first patch moves rpc.idmapd's (mostly) undocumented pipefs-directory from
/etc/idmapd.confto/etc/nfs.conf, which rpc.gssd already can use for it's pipefs-directory configuration.The second patch adds a systemd generator that reads the pipefs-directory configurations from
/etc/nfs.conf, and if they differ from the default it will automatically 1) create a systemd mount unit file for the pipefs mountpoint and 2) it will create a drop-in configuration file to override the Requires= and After= directives for that service.I did run into a bit of a snag though. Depsite overriding the dependencies for both idmapd and gssd, I wind up with two pipefs filesystems mounted:
[root@coeurl ~]# grep pipefs
/proc/mounts
sunrpc/var/lib/nfs/rpc_pipefsrpc_pipefsrw,relatime 0 0 sunrpc/run/rpc_pipefsrpc_pipefsrw,relatime 0 0systemd still shows the dependency on the default pipefs mountpoint:
[root@coeurl ~]# systemctl list-dependencies --before var-lib-nfs-rpc_pipefs.mount var-lib-nfs-rpc_pipefs.mount
● ├─nfs-idmapd.service ● └─rpc-gssd.serviceas well as the new one:
[root@coeurl ~]# systemctl list-dependencies --before run-rpc_pipefs.mount run-rpc_pipefs.mount
● ├─nfs-idmapd.service ● └─rpc-gssd.serviceThe drop-in configs to override the pipefs mountpoint look correct. I'm clearing both Requires= and After= before setting them:
[root@coeurl ~]# cat
/run/systemd/generator/nfs-idmapd.service.d/10-pipefs.conf# Automatically generated by rpc-pipefs-generator[Unit]
Requires=
Requires=run-rpc_pipefs.mount
After=
After=run-rpc_pipefs.mount local-fs.target[root@coeurl ~]# cat
/run/systemd/generator/rpc-gssd.service.d/10-pipefs.conf# Automatically generated by rpc-pipefs-generator[Unit]
Requires=
Requires=run-rpc_pipefs.mount
After=
After=run-rpc_pipefs.mountThe generated mount unit file also looks correct:
[root@coeurl ~]# cat
/run/systemd/generator/run-rpc_pipefs.mount# Automatically generated by rpc-pipefs-generator[Unit]
Description=RPC Pipe File System
DefaultDependencies=no
After=systemd-tmpfiles-setup.service
Conflicts=umount.target[Mount]
What=sunrpc
Where=/run/rpc_pipefs
Type=rpc_pipefssystemd shows that the drop-in config was picked up:
[root@coeurl ~]# systemctl status nfs-idmapd
● nfs-idmapd.service - NFSv4 ID-name mapping service
Loaded: loaded (/usr/lib/systemd/system/nfs-idmapd.service; static; vendor preset: disabled)
Drop-In:/run/systemd/generator/nfs-idmapd.service.d
└─10-pipefs.conf
Active: active (running) since Fri 2017-03-31 16:54:24 EDT; 5min ago
Process: 27831 ExecStart=/usr/sbin/rpc.idmapd $RPCIDMAPDARGS (code=exited, status=0/SUCCESS)
Main PID: 27832 (rpc.idmapd)Tasks: 1 (limit: 4915) CGroup: /system.slice/nfs-idmapd.service └─27832 /usr/sbin/rpc.idmapdand lsof shows that the correct mountpoint is being used:
[root@coeurl ~]# lsof -p 27832 2>/dev/null | grep pipefs
rpc.idmap 27832 root 10r DIR 0,42 0 103/run/rpc_pipefs/nfsThe same for gssd:
[root@coeurl ~]# systemctl status rpc-gssd
● rpc-gssd.service - RPC security service for NFS client and server
Loaded: loaded (/usr/lib/systemd/system/rpc-gssd.service; static; vendor preset: disabled)
Drop-In:/run/systemd/generator/rpc-gssd.service.d
└─10-pipefs.conf
Active: active (running) since Fri 2017-03-31 16:54:29 EDT; 6min ago
Process: 27839 ExecStart=/usr/sbin/rpc.gssd $RPCGSSDARGS (code=exited, status=0/SUCCESS)
Main PID: 27840 (rpc.gssd)Tasks: 1 (limit: 4915) CGroup: /system.slice/rpc-gssd.service └─27840 /usr/sbin/rpc.gssd[root@coeurl ~]# lsof -p 27840 2>/dev/null | grep pipefs
rpc.gssd 27840 root cwd DIR 0,42 0 24637 /run/rpc_pipefs rpc.gssd 27840 root 7r DIR 0,42 0 24637 /run/rpc_pipefs rpc.gssd 27840 root 11u FIFO 0,42 0t0 112 /run/rpc_pipefs/gssd/clntXX/gssdQuoted 7 lines
So it looks like systemd is using both sets of dependencies, even though the programs themselves are only looking for what's specified in
/etc/nfs.conf. I'm not sure what to do about that. Maybe remove the var-lib-nfs-rpc_pipefs.mount unit as well as the dependencies in the nfs-idmapd.service and rpc-gssd.service files, and have the generator create those automatically as well?Quoted 8 lines
Towards the end of the systemd.unit man page is the text:
Note that dependencies (After=, etc.) cannot be reset to an empty list,
so dependencies can only be added in drop-ins. If you want to remove dependencies, you have to override the entire unit.which is consistent with what you discovered.
Doh, that's what I get for not reading all the way to the end.
Quoted 11 lines
Maybe create a "rpc_pipefs.target" which
Requires=var-lib-nfs-rpc_pipefs.mount After=var-lib-nfs-rpc_pipefs.mount
and have all the other unit files specified their dependencies against this target.Then your generator would conditionally create a new "rpc_pipefs.target" and matching foo.mount. The new .target would depend in the foo.mount, and the service files would already depend on that.
Quoted 7 lines
Quoted 1 line
Might work.
That looks like it works, but what should happen then if programs were to intentionally specify two different values for the pipefs-directory in nfs.conf? Or is that something that wouldn't make sense to do and should be prevented? I can't think of a reason why you'd want more than one
rpc_pipefsfilesystem mounted...
I agree. I cannot think of any good reason.
I'm not sure it would be such a bad idea to fix a mount point at compile time, but not that we have run-time configuration it is safe to stick with it.
Quoted 7 lines
Maybe it would make sense to create a 'global' section and have the programs all look at that instead of looking in their specific config sections... or maybe have the program check global section and then a program-specific section, but include a big fat warning that if you specify it in the program-specific section then you need to override all of them with the same value.
I support a "global" section of rpc-pipefs mount point.
I probably should have put pipefs-directory in a "global" section to start with. I don't recall why I didn't.
Thanks,
NeilBrown
Quoted 31 lines
-Scott
Quoted 29 lines
Thanks,
NeilBrownQuoted 24 lines
-Scott
Scott Mayhew (2):
idmapd: move the pipefs-directory config option to nfs.conf
systemd: add a generator for therpc_pipefsmountpoint.gitignore | 1 + nfs.conf | 3 + systemd/Makefile.am | 4 +- systemd/nfs.conf.man | 9 ++ systemd/rpc-pipefs-generator.c | 256 +++++++++++++++++++++++++++++++++++++++++ systemd/rpc-svcgssd.service | 3 +- utils/idmapd/idmapd.c | 35 +++--- utils/idmapd/idmapd.man | 19 ++- 8 files changed, 305 insertions(+), 25 deletions(-) create mode 100644 systemd/rpc-pipefs-generator.cSignature · 6 lines
2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html