From nobody Mon Jan 20 21:52:42 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YcPG32L1Jz5l14C; Mon, 20 Jan 2025 21:52:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YcPG31T39z4HlQ; Mon, 20 Jan 2025 21:52:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737409963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fcR0m1u2fHEewNaNWjYfhteXS9AUlfZggYQHClpx2TU=; b=EnsEfVydTJlhaOglbWwLjnENwr+jZmUcxDT6dTRbMrkpe1tUSqGDbjHt+HvZSPFoomxKcx fa0LLWDTfhbYBPZ9oc9CQEs4DfV6k4dIiV/iVXlZy0MRtY7AziSPwBUyvSUb2zwmU8aTzu W4w4u5yDgaOQlMUE6m1135TqWQOsWXCMJjp6oinhUZ5EZZSaMfkXeHPT1CVqNYeYKsQLXd Xiea3Z+CtZ0LSRZS9rJq5tQUEHR4ur/CQMTjw0pPoVBMa1O8SlhwuKr0mJWdP2e95F1bDR RKtAm9OSmXwONDrl2cmGzYJEdzrG7Nt2NrvgkJy7dekJjw21DBdQdsEf1QBz6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737409963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fcR0m1u2fHEewNaNWjYfhteXS9AUlfZggYQHClpx2TU=; b=pE2wS5hTqYygiBf3byZ5aWdLeHUhOl81b0F+BGC4Xm6V6A8aBvQbqhn0W9mJKN7ARt7frB svYPRKrjba7u8DZb7lLeqBuc7xXpv9Yio3Iac6Jdjfreq6+Pyz3vStAiFLte8UhcGJL67c cddMlAaqyPYe07jZm5t4NEfzpojgVHVcuajkBZDTIAI8nnakfqUamOgWJz5GqnHDtPP5DY x3kZHyBqVmyBH6TEUQW1bjTxI7m/ncrAYU+R8FW+q/N6P7ARMoQlNrDh77P+xHNz+95y5j CEvoaycGqLMUHeuyW2MSTifV9pyfLPzG9KGydtatvgWi1kkm1MDJ7plSB9jEWw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737409963; a=rsa-sha256; cv=none; b=LSRl8XjH72ZozYny/02kTe74VvuojtjL8bwH96AKHIvxm5WU2/yKTZAhpYMTeOXrycQXxX qcpBF7r61lneukvGwwfUEZn9DXIg/NLwEAAm7ojpSaEVFppI/WTMOwASBGnX5hxK0BBdUc +NbOiJ87Z1FnM/xoorqUEemQAOiu8i+JuUOimmbd1p0kMptpbrJUSu284wVwWjg8zlvJ4Z L4vlesF+BcikMkdf99I+PURi31Q5wc1uG07T9TH22PkATRZY8nNYNOoE31aQGT0S4YRdKX vlZQymCOOAPFRr5ONZrpUpwjf00kmmPaMrY7G4fks8AyNSOeMnaCN4jG1eYpgA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YcPG30JhSzfdC; Mon, 20 Jan 2025 21:52:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50KLqgqW030399; Mon, 20 Jan 2025 21:52:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50KLqg1C030396; Mon, 20 Jan 2025 21:52:42 GMT (envelope-from git) Date: Mon, 20 Jan 2025 21:52:42 GMT Message-Id: <202501202152.50KLqg1C030396@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 709c18911ad7 - main - nfsd: Add support for the NFSv4.2 change_attr_type attribute List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 709c18911ad70978d47198556c0fb1c0e703fb68 Auto-Submitted: auto-generated The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=709c18911ad70978d47198556c0fb1c0e703fb68 commit 709c18911ad70978d47198556c0fb1c0e703fb68 Author: Rick Macklem AuthorDate: 2025-01-20 21:51:33 +0000 Commit: Rick Macklem 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 Tested by: Richard Kojedzinszky MFC after: 2 weeks --- sys/fs/nfs/nfs_commonsubs.c | 32 ++++++++++++++++++++++++++++++++ sys/fs/nfs/nfsproto.h | 11 ++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index fc01630f77f9..d4d97f4eb966 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -2303,6 +2303,23 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp, if (compare && !(*retcmpp) && i != nfs_srvmaxio) *retcmpp = NFSERR_NOTSAME; break; + case NFSATTRBIT_CHANGEATTRTYPE: + NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED); + if (compare) { + if (!(*retcmpp)) { + tuint = NFSV4CHANGETYPE_UNDEFINED; + if ((vp->v_mount->mnt_vfc->vfc_flags & + VFCF_FILEREVINC) != 0) + tuint = NFSV4CHANGETYPE_VERS_COUNTER_NOPNFS; + else if ((vp->v_mount->mnt_vfc->vfc_flags & + VFCF_FILEREVCT) != 0) + tuint = NFSV4CHANGETYPE_TIME_METADATA; + if (fxdr_unsigned(uint32_t, *tl) != tuint) + *retcmpp = NFSERR_NOTSAME; + } + } + attrsum += NFSX_UNSIGNED; + break; default: printf("EEK! nfsv4_loadattr unknown attr=%d\n", bitpos); @@ -3127,6 +3144,21 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount *mp, vnode_t vp, *tl = 0; retnum += 2 * NFSX_UNSIGNED; break; + case NFSATTRBIT_CHANGEATTRTYPE: + NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV4CHANGETYPE_UNDEFINED); + if (mp != NULL) { + if ((mp->mnt_vfc->vfc_flags & + VFCF_FILEREVINC) != 0) + *tl = txdr_unsigned( + NFSV4CHANGETYPE_VERS_COUNTER_NOPNFS); + else if ((mp->mnt_vfc->vfc_flags & + VFCF_FILEREVCT) != 0) + *tl = txdr_unsigned( + NFSV4CHANGETYPE_TIME_METADATA); + } + retnum += NFSX_UNSIGNED; + break; default: printf("EEK! Bad V4 attribute bitpos=%d\n", bitpos); } diff --git a/sys/fs/nfs/nfsproto.h b/sys/fs/nfs/nfsproto.h index ce7acf102d41..323746ebbb6c 100644 --- a/sys/fs/nfs/nfsproto.h +++ b/sys/fs/nfs/nfsproto.h @@ -1176,6 +1176,7 @@ struct nfsv3_sattr { NFSATTRBM_LAYOUTBLKSIZE | \ NFSATTRBM_LAYOUTALIGNMENT | \ NFSATTRBM_SUPPATTREXCLCREAT | \ + NFSATTRBM_CHANGEATTRTYPE | \ NFSATTRBM_XATTRSUPPORT) /* @@ -1221,7 +1222,8 @@ struct nfsv3_sattr { * NFSATTRBIT_NFSV42 - Attributes only supported by NFSv4.2. */ #define NFSATTRBIT_NFSV42_2 \ - (NFSATTRBM_XATTRSUPPORT | \ + (NFSATTRBM_CHANGEATTRTYPE | \ + NFSATTRBM_XATTRSUPPORT | \ NFSATTRBM_MODEUMASK) /* @@ -1657,4 +1659,11 @@ typedef struct nfsv4stateid nfsv4stateid_t; #define NFSV4SXATTR_CREATE 1 #define NFSV4SXATTR_REPLACE 2 +/* Values for ChangeAttrType (RFC-7862). */ +#define NFSV4CHANGETYPE_MONOTONIC_INCR 0 +#define NFSV4CHANGETYPE_VERS_COUNTER 1 +#define NFSV4CHANGETYPE_VERS_COUNTER_NOPNFS 2 +#define NFSV4CHANGETYPE_TIME_METADATA 3 +#define NFSV4CHANGETYPE_UNDEFINED 4 + #endif /* _NFS_NFSPROTO_H_ */