We had a long standing issue with an NFS share being mounted on multiple Linux hosts, and randomly we encountered caching issues. https://marc.info/?l=linux-nfs&m=170013171720335 We could not exactly reproduce the issue, howewer, with two different machines mounting the same share, we have been faced the issue once in a week or two. With a trial patch thanks to @Rick Macklem, our FreeBSD based TrueNAS now reports the change_attr_type as NFS4_CHANGE_TYPE_IS_VERSION_COUNTER_NOPNFS, and for two months now we have not met the issue.
^triage. unable to change status.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=709c18911ad70978d47198556c0fb1c0e703fb68 commit 709c18911ad70978d47198556c0fb1c0e703fb68 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2025-01-20 21:51:33 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2025-01-20 21:51:33 +0000 nfsd: Add support for the NFSv4.2 change_attr_type attribute Richard Kojedzinszky reported an intermittent problem where the Linux NFSv4.2 client would sometimes not see changes done to a directory by another client, although the change attribute for the directory had changed. A test patch that added the change_attr_type attribute to the server and always returned NFS4_CHANGE_TYPE_VERSION_COUNTER_NOPNFS seems to have resolved the issue. Somewhat oddly, the Linux knfsd server does not support this attribute but does not seem to exhibit the stale caching problem. This patch uses the VFCF_FILEREVINC flag on a file system (UFS, ZFS) to return NFS4_CHANGE_TYPE_VERSION_COUNTER_NOPNFS. It also returns NFS4_CHANGE_TYPE_TIME_METADATA if VFCF_FILEREVCT is set, which may be useful for exported fuse file systems. PR: 284186 Reported by: Richard Kojedzinszky <richard@kojedz.in> Tested by: Richard Kojedzinszky <richard@kojedz.in> MFC after: 2 weeks sys/fs/nfs/nfs_commonsubs.c | 32 ++++++++++++++++++++++++++++++++ sys/fs/nfs/nfsproto.h | 11 ++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-)
Created attachment 256861 [details] Add VFCF_FILEREVxx flags and set VFCF_FILEREVINC for UFS This patch adds VFCF_FILEREVxx flags that file systems can use to indicate how they update va_filerev. These flags are used by the changeattrtype patch.
Created attachment 256863 [details] Add support for teh NFSv4.2 change_attr_type attribute This patch uses VFCF_FILEREVxx flags to return the change_attr_type attribute to NFSv4.2 clients. This patch plus attachment #256861 [details] have been committed to main and will be MFC'd.
Created attachment 256864 [details] Set VFCF_FILEREVINC for ZFS file systems This patch sets VFCF_FILEREVINC for ZFS file systems. It will be submitted as a Pull Request for OpenZFS soon.
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=a6b4af5e07af3309695de49207f9edba524e748f commit a6b4af5e07af3309695de49207f9edba524e748f Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2025-01-20 21:51:33 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2025-02-01 03:23:15 +0000 nfsd: Add support for the NFSv4.2 change_attr_type attribute Richard Kojedzinszky reported an intermittent problem where the Linux NFSv4.2 client would sometimes not see changes done to a directory by another client, although the change attribute for the directory had changed. A test patch that added the change_attr_type attribute to the server and always returned NFS4_CHANGE_TYPE_VERSION_COUNTER_NOPNFS seems to have resolved the issue. Somewhat oddly, the Linux knfsd server does not support this attribute but does not seem to exhibit the stale caching problem. This patch uses the VFCF_FILEREVINC flag on a file system (UFS, ZFS) to return NFS4_CHANGE_TYPE_VERSION_COUNTER_NOPNFS. It also returns NFS4_CHANGE_TYPE_TIME_METADATA if VFCF_FILEREVCT is set, which may be useful for exported fuse file systems. PR: 284186 (cherry picked from commit 709c18911ad70978d47198556c0fb1c0e703fb68) sys/fs/nfs/nfs_commonsubs.c | 32 ++++++++++++++++++++++++++++++++ sys/fs/nfs/nfsproto.h | 11 ++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-)
The first two patches have been committed to main and MFC'd. The third patch has been committed to OpenZFS's origin and should be pulled into FreeBSD at some point.