Skip to content

Improve nfsmount.conf configuration parsing.

Scott Mayhew linux-nfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4mount.nfs: avoid unnecessary duplication of options passed to mount(2)support/include/conffile.h support/nfs/conffile.c utils/mount/configfile.c+5 -34 replies
2/4mount.nfs: avoid sending conflicting mount optionsutils/mount/configfile.c+19 -50 replies
3/4mount.nfs: improve handling of MNT_NOARG type optionsutils/mount/configfile.c+50 -03 replies
4/4mount.nfs: clean up conf_parse_mntopts()utils/mount/configfile.c+5 -80 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [nfs-utils PATCH 0/4] Improve nfsmount.conf configuration parsing.

The parsing of the nfsmount.conf configuration file has various issues.

Here's an example config file I've been testing with:

# cat /etc/nfsmount.conf
[ NFSMount_Global_Options ]
	Acl=False
	Ac=False
	Timeo=600
	Background=True

[ Server "nfs.smayhew.test" ]

	Sec=krb5p
	Nfsvers=4
	Acl=True
	Ac=True
	Timeo=300
	Sloppy=True
	Foreground=True

[ Server "rhel7alpha2.smayhew.test" ]
Sec=krb5i
Nfsvers=4

[ Server "rhel6u2.smayhew.test" ]
Nfsvers=4

[ Server "rhel5u8.smayhew.test" ]
Nfsvers=3

[ Server "rhel4u8.smayhew.test" ]
Nfsvers=3

[ MountPoint "/mnt/nfs" ]

	Timeo=150
	Background=False
	Ac=False
	Sloppy=False

I then mount a filesystem using:

# mount nfs.smayhew.test:/export /mnt/nfs
# mount | grep smayhew
nfs.smayhew.test:/export on /mnt/nfs type nfs
(rw,timeo=600,bg,sec=krb5p,nfsvers=4,acl,ac,timeo=300,sloppy,fg,sec=krb5p,nfsvers=4,nfsvers=4,nfsvers=4,nfsvers=4,addr=192.168.122.179,clientaddr=192.168.122.202)
# grep smayhew /proc/mounts
nfs.smayhew.test:/export/ /mnt/nfs nfs4
rw,relatime,vers=4,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=300,retrans=2,sec=krb5p,clientaddr=192.168.122.202,minorversion=0,local_lock=none,addr=192.168.122.179
0 0

In the output of mount (no arguments) as well as /etc/mtab,
1. nfsvers=4 is shown four times
2. sec=krb5p is shown twice
3. both fg and bg is shown
4. timeo appears twice

In /proc/mounts we can see that we have the wrong value for timeo (it should be 150).

In newer distros where /etc/mtab is a symlink to /proc/mounts, you're unlikely to see most of these issues unless you're watching the mount command with something like systemtap, e.g.

# stap -e 'probe syscall.mount { printf("%s %s\n", probefunc(),
# kernel_string($data)) }'
sys_mount
timeo=600,bg,sec=krb5p,nfsvers=4,acl,ac,timeo=300,sloppy,fg,sec=krb5p,nfsvers=4,nfsvers=4,nfsvers=4,nfsvers=4,addr=192.168.122.179,clientaddr=192.168.122.202

Regardless, rather than sending a slew of mount options and letting the kernel sort it out, we can do a better job of parsing them on the front end.

Scott Mayhew (4):
mount.nfs: avoid unnecessary duplication of options passed to

    mount(2)

mount.nfs: avoid sending conflicting mount options mount.nfs: improve handling of MNT_NOARG type options mount.nfs: clean up conf_parse_mntopts()

 support/include/conffile.h |  2 +-
 support/nfs/conffile.c     |  4 ++-
 utils/mount/configfile.c   | 77 +++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 73 insertions(+), 10 deletions(-)
Signature · 1 line
1.7.11.7