Wandering Thoughts archives

2023-08-04

On Linux, NFS v4 mounts are a different filesystem type than NFS (v3) mounts

For more or less historical reasons, we currently use NFS v3 to mount filesystems from our fileservers. We're likely going to (slowly) move over to NFS v4 (after successful experiments), so I've been working on various preparations for that, such as making sure our automounter system doesn't specifically force NFS v3 but instead leaves it up to the system to pick a version. In the process of this, I've discovered a surprise.

On Linux, NFS v4 mounts have the filesystem type 'nfs4', not 'nfs'; the 'nfs' filesystem type is for NFS v3 (and NFS v2, if you're using that, which you probably shouldn't be). Linux's normal 'mount' program will accept 'mount -t nfs ...' and do a NFS v4 mount if the server supports it, but listing mounts with 'mount -t nfs' will only list NFS v3 ones, and the actual filesystem type in /proc/mounts (aka /proc/self/mounts) and other things is 'nfs4'.

This ripples through to all sorts of things. If you're listing 'all NFS mounts', you need to use 'mount -t nfs,nfs4'. If you're configuring the Prometheus host agent to exclude NFS mounts from the filesystems it reports on, now you need to exclude another filesystem type ('nfs4'). If you have something that scans /proc/self/mountstats to report 'NFS' mount information, you need to accept both 'fstype nfs' and 'fstype nfs4' (or possibly handle 'nfs4' differently, since it has different NFS operations). Once you're collecting information on NFS v4 mounts, you may then need to make additional changes to things like alerts, metrics dashboards, and so on to either include or exclude NFS v4 filesystems as appropriate.

I'm sure the Linux kernel has good internal reasons for doing this, regardless of how I find it inconvenient for our purposes. The two different filesystem types are defined and seem to be used in fs/nfs/fs_context.c, where they seem to have mostly the same contents in their 'struct file_system_type' but the kernel code distinguishes between them when parsing mount options (in nfs_fs_context_parse_monolithic() and the code it calls). Possibly this creates additional changes later in things like what VFS operations are supported; I haven't read the kernel code in that much detail.

(NFS v3 and NFS v4 mounts have kernel level mount options that give you the NFS version involved. A NFS v3 mount will have 'vers=3' and I believe always 'mountvers=3'; a NFS v4 mount has a 'vers' that has things like '4.2', depending on the NFS v4 sub-version you wind up using.)

linux/NFSv4MountsNewFilesystemType written at 21:34:20;


Page tools: See As Normal.
Search:
Login: Password:

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.