Bug 284186 - NFS v4.2: improve change_attr_type
Summary: NFS v4.2: improve change_attr_type
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Some People
Assignee: Rick Macklem
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-20 08:12 UTC by richard@kojedz.in
Modified: 2025-02-01 03:39 UTC (History)
4 users (show)

See Also:
rmacklem: mfc-stable14+
rmacklem: mfc-stable13-


Attachments
Add VFCF_FILEREVxx flags and set VFCF_FILEREVINC for UFS (895 bytes, patch)
2025-01-20 22:03 UTC, Rick Macklem
no flags Details | Diff
Add support for teh NFSv4.2 change_attr_type attribute (2.70 KB, patch)
2025-01-20 22:05 UTC, Rick Macklem
no flags Details | Diff
Set VFCF_FILEREVINC for ZFS file systems (685 bytes, patch)
2025-01-20 22:07 UTC, Rick Macklem
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description richard@kojedz.in 2025-01-20 08:12:58 UTC
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.
Comment 1 Dudley Innocent 2025-01-20 12:53:57 UTC
^triage. unable to change status.
Comment 2 commit-hook freebsd_committer freebsd_triage 2025-01-20 21:52:58 UTC
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(-)
Comment 3 Rick Macklem freebsd_committer freebsd_triage 2025-01-20 22:03:23 UTC
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.
Comment 4 Rick Macklem freebsd_committer freebsd_triage 2025-01-20 22:05:37 UTC
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.
Comment 5 Rick Macklem freebsd_committer freebsd_triage 2025-01-20 22:07:10 UTC
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.
Comment 6 commit-hook freebsd_committer freebsd_triage 2025-02-01 03:25:40 UTC
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(-)
Comment 7 Rick Macklem freebsd_committer freebsd_triage 2025-02-01 03:39:22 UTC
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.