mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chuck Lever" <cel@kernel.org>
To: "Jeff Layton" <jlayton@kernel.org>, NeilBrown <neil@brown.name>,
	"Olga Kornievskaia" <okorniev@redhat.com>,
	"Dai Ngo" <Dai.Ngo@oracle.com>, "Tom Talpey" <tom@talpey.com>,
	"Trond Myklebust" <trondmy@kernel.org>,
	"Anna Schumaker" <anna@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>
Cc: "Steven Rostedt" <rostedt@goodmis.org>,
	"Alexander Aring" <alex.aring@gmail.com>,
	"Amir Goldstein" <amir73il@gmail.com>, "Jan Kara" <jack@suse.cz>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Christian Brauner" <brauner@kernel.org>,
	"Calum Mackay" <calum.mackay@oracle.com>,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-nfs@vger.kernel.org
Subject: Re: [PATCH v6 02/20] nfsd: add protocol support for CB_NOTIFY
Date: Thu, 11 Jun 2026 17:33:23 -0400	[thread overview]
Message-ID: <9119f5c0-cf25-4f30-bad2-b928a2db239d@app.fastmail.com> (raw)
In-Reply-To: <20260611-dir-deleg-v6-2-4c45080e5f3f@kernel.org>


On Thu, Jun 11, 2026, at 1:50 PM, Jeff Layton wrote:

> diff --git a/Documentation/sunrpc/xdr/nfs4_1.x 
> b/Documentation/sunrpc/xdr/nfs4_1.x
> index 5b45547b2ebc..632f5b579c39 100644
> --- a/Documentation/sunrpc/xdr/nfs4_1.x
> +++ b/Documentation/sunrpc/xdr/nfs4_1.x
> @@ -45,19 +45,165 @@ pragma header nfs4;
>  /*
>   * Basic typedefs for RFC 1832 data type definitions
>   */
> -typedef hyper		int64_t;
> -typedef unsigned int	uint32_t;
> +typedef int                  int32_t;
> +typedef unsigned int         uint32_t;
> +typedef hyper                int64_t;
> +typedef unsigned hyper       uint64_t;
> +
> +const NFS4_VERIFIER_SIZE        = 8;
> +const NFS4_FHSIZE               = 128;
> +
> +enum nfsstat4 {
> + NFS4_OK                = 0,    /* everything is okay      */
> + NFS4ERR_PERM           = 1,    /* caller not privileged   */
> + NFS4ERR_NOENT          = 2,    /* no such file/directory  */
> + NFS4ERR_IO             = 5,    /* hard I/O error          */
> + NFS4ERR_NXIO           = 6,    /* no such device          */
> + NFS4ERR_ACCESS         = 13,   /* access denied           */
> + NFS4ERR_EXIST          = 17,   /* file already exists     */
> + NFS4ERR_XDEV           = 18,   /* different filesystems   */
> +
> + /*
> +  * Please do not allocate value 19; it was used in NFSv3
> +  * and we do not want a value in NFSv3 to have a different
> +  * meaning in NFSv4.x.
> +  */
> +
> + NFS4ERR_NOTDIR         = 20,   /* should be a directory   */
> + NFS4ERR_ISDIR          = 21,   /* should not be directory */
> + NFS4ERR_INVAL          = 22,   /* invalid argument        */
> + NFS4ERR_FBIG           = 27,   /* file exceeds server max */
> + NFS4ERR_NOSPC          = 28,   /* no space on filesystem  */
> + NFS4ERR_ROFS           = 30,   /* read-only filesystem    */
> + NFS4ERR_MLINK          = 31,   /* too many hard links     */
> + NFS4ERR_NAMETOOLONG    = 63,   /* name exceeds server max */
> + NFS4ERR_NOTEMPTY       = 66,   /* directory not empty     */
> + NFS4ERR_DQUOT          = 69,   /* hard quota limit reached*/
> + NFS4ERR_STALE          = 70,   /* file no longer exists   */
> + NFS4ERR_BADHANDLE      = 10001,/* Illegal filehandle      */
> + NFS4ERR_BAD_COOKIE     = 10003,/* READDIR cookie is stale */
> + NFS4ERR_NOTSUPP        = 10004,/* operation not supported */
> + NFS4ERR_TOOSMALL       = 10005,/* response limit exceeded */
> + NFS4ERR_SERVERFAULT    = 10006,/* undefined server error  */
> + NFS4ERR_BADTYPE        = 10007,/* type invalid for CREATE */
> + NFS4ERR_DELAY          = 10008,/* file "busy" - retry     */
> + NFS4ERR_SAME           = 10009,/* nverify says attrs same */
> + NFS4ERR_DENIED         = 10010,/* lock unavailable        */
> + NFS4ERR_EXPIRED        = 10011,/* lock lease expired      */
> + NFS4ERR_LOCKED         = 10012,/* I/O failed due to lock  */
> + NFS4ERR_GRACE          = 10013,/* in grace period         */
> + NFS4ERR_FHEXPIRED      = 10014,/* filehandle expired      */
> + NFS4ERR_SHARE_DENIED   = 10015,/* share reserve denied    */
> + NFS4ERR_WRONGSEC       = 10016,/* wrong security flavor   */
> + NFS4ERR_CLID_INUSE     = 10017,/* clientid in use         */
> +
> + /* NFS4ERR_RESOURCE is not a valid error in NFSv4.1 */
> + NFS4ERR_RESOURCE       = 10018,/* resource exhaustion     */
> +
> + NFS4ERR_MOVED          = 10019,/* filesystem relocated    */
> + NFS4ERR_NOFILEHANDLE   = 10020,/* current FH is not set   */
> + NFS4ERR_MINOR_VERS_MISMATCH= 10021,/* minor vers not supp */
> + NFS4ERR_STALE_CLIENTID = 10022,/* server has rebooted     */
> + NFS4ERR_STALE_STATEID  = 10023,/* server has rebooted     */
> + NFS4ERR_OLD_STATEID    = 10024,/* state is out of sync    */
> + NFS4ERR_BAD_STATEID    = 10025,/* incorrect stateid       */
> + NFS4ERR_BAD_SEQID      = 10026,/* request is out of seq.  */
> + NFS4ERR_NOT_SAME       = 10027,/* verify - attrs not same */
> + NFS4ERR_LOCK_RANGE     = 10028,/* overlapping lock range  */
> + NFS4ERR_SYMLINK        = 10029,/* should be file/directory*/
> + NFS4ERR_RESTOREFH      = 10030,/* no saved filehandle     */
> + NFS4ERR_LEASE_MOVED    = 10031,/* some filesystem moved   */
> + NFS4ERR_ATTRNOTSUPP    = 10032,/* recommended attr not sup*/
> + NFS4ERR_NO_GRACE       = 10033,/* reclaim outside of grace*/
> + NFS4ERR_RECLAIM_BAD    = 10034,/* reclaim error at server */
> + NFS4ERR_RECLAIM_CONFLICT= 10035,/* conflict on reclaim    */
> + NFS4ERR_BADXDR         = 10036,/* XDR decode failed       */
> + NFS4ERR_LOCKS_HELD     = 10037,/* file locks held at CLOSE*/
> + NFS4ERR_OPENMODE       = 10038,/* conflict in OPEN and I/O*/
> + NFS4ERR_BADOWNER       = 10039,/* owner translation bad   */
> + NFS4ERR_BADCHAR        = 10040,/* utf-8 char not supported*/
> + NFS4ERR_BADNAME        = 10041,/* name not supported      */
> + NFS4ERR_BAD_RANGE      = 10042,/* lock range not supported*/
> + NFS4ERR_LOCK_NOTSUPP   = 10043,/* no atomic up/downgrade  */
> + NFS4ERR_OP_ILLEGAL     = 10044,/* undefined operation     */
> + NFS4ERR_DEADLOCK       = 10045,/* file locking deadlock   */
> + NFS4ERR_FILE_OPEN      = 10046,/* open file blocks op.    */
> + NFS4ERR_ADMIN_REVOKED  = 10047,/* lockowner state revoked */
> + NFS4ERR_CB_PATH_DOWN   = 10048,/* callback path down      */
> +
> + /* NFSv4.1 errors start here. */
> +
> + NFS4ERR_BADIOMODE      = 10049,
> + NFS4ERR_BADLAYOUT      = 10050,
> + NFS4ERR_BAD_SESSION_DIGEST = 10051,
> + NFS4ERR_BADSESSION     = 10052,
> + NFS4ERR_BADSLOT        = 10053,
> + NFS4ERR_COMPLETE_ALREADY = 10054,
> + NFS4ERR_CONN_NOT_BOUND_TO_SESSION = 10055,
> + NFS4ERR_DELEG_ALREADY_WANTED = 10056,
> + NFS4ERR_BACK_CHAN_BUSY = 10057,/*backchan reqs outstanding*/
> + NFS4ERR_LAYOUTTRYLATER = 10058,
> + NFS4ERR_LAYOUTUNAVAILABLE = 10059,
> + NFS4ERR_NOMATCHING_LAYOUT = 10060,
> + NFS4ERR_RECALLCONFLICT = 10061,
> + NFS4ERR_UNKNOWN_LAYOUTTYPE = 10062,
> + NFS4ERR_SEQ_MISORDERED = 10063,/* unexpected seq.ID in req*/
> + NFS4ERR_SEQUENCE_POS   = 10064,/* [CB_]SEQ. op not 1st op */
> + NFS4ERR_REQ_TOO_BIG    = 10065,/* request too big         */
> + NFS4ERR_REP_TOO_BIG    = 10066,/* reply too big           */
> + NFS4ERR_REP_TOO_BIG_TO_CACHE =10067,/* rep. not all cached*/
> + NFS4ERR_RETRY_UNCACHED_REP =10068,/* retry & rep. uncached*/
> + NFS4ERR_UNSAFE_COMPOUND =10069,/* retry/recovery too hard */
> + NFS4ERR_TOO_MANY_OPS   = 10070,/*too many ops in [CB_]COMP*/
> + NFS4ERR_OP_NOT_IN_SESSION =10071,/* op needs [CB_]SEQ. op */
> + NFS4ERR_HASH_ALG_UNSUPP = 10072, /* hash alg. not supp.   */
> +                                /* Error 10073 is unused.  */
> + NFS4ERR_CLIENTID_BUSY  = 10074,/* clientid has state      */
> + NFS4ERR_PNFS_IO_HOLE   = 10075,/* IO to _SPARSE file hole */
> + NFS4ERR_SEQ_FALSE_RETRY= 10076,/* Retry != original req.  */
> + NFS4ERR_BAD_HIGH_SLOT  = 10077,/* req has bad highest_slot*/
> + NFS4ERR_DEADSESSION    = 10078,/*new req sent to dead sess*/
> + NFS4ERR_ENCR_ALG_UNSUPP= 10079,/* encr alg. not supp.     */
> + NFS4ERR_PNFS_NO_LAYOUT = 10080,/* I/O without a layout    */
> + NFS4ERR_NOT_ONLY_OP    = 10081,/* addl ops not allowed    */
> + NFS4ERR_WRONG_CRED     = 10082,/* op done by wrong cred   */
> + NFS4ERR_WRONG_TYPE     = 10083,/* op on wrong type object */
> + NFS4ERR_DIRDELEG_UNAVAIL=10084,/* delegation not avail.   */
> + NFS4ERR_REJECT_DELEG   = 10085,/* cb rejected delegation  */
> + NFS4ERR_RETURNCONFLICT = 10086,/* layout get before return*/
> + NFS4ERR_DELEG_REVOKED  = 10087, /* deleg./layout revoked   */
> + NFS4ERR_PARTNER_NOTSUPP = 10088,
> + NFS4ERR_PARTNER_NO_AUTH = 10089,
> + NFS4ERR_UNION_NOTSUPP = 10090,
> + NFS4ERR_OFFLOAD_DENIED = 10091,
> + NFS4ERR_WRONG_LFS = 10092,
> + NFS4ERR_BADLABEL = 10093,
> + NFS4ERR_OFFLOAD_NO_REQS = 10094,
> + NFS4ERR_NOXATTR = 10095,
> + NFS4ERR_XATTR2BIG = 10096,
> +
> + /* always set this to one more than the last one in the enum */
> + NFS4ERR_FIRST_FREE = 10097
> +};

This value can be leaked onto the wire. The basic enum encoder
checks that these values are part of the .x before sticking
them on the wire.

Please keep the .x document aligned with the specification. If
you need a "maximum value" symbolic constant, please define it
in one of the hand-rolled headers. (I guess this one was copied
over from the existing hand-rolled NFS4ERR definitions).

I see that NFS4ERR_FIRST_FREE is used to determine the numeric
value for NFSERR_EOF.

fs/nfsd/nfs3xdr.c:              if (xdr_stream_encode_bool(xdr, resp->common.err == nfserr_eof) < 0)
fs/nfsd/nfs4xdr.c:      return nfsd4_encode_bool(xdr, readdir->common.err == nfserr_eof);
fs/nfsd/nfsd.h: __be32                  err;    /* 0, nfserr, or nfserr_eof */
fs/nfsd/nfsd.h:#define  nfserr_eof              cpu_to_be32(NFSERR_EOF)
fs/nfsd/nfsxdr.c:               if (xdr_stream_encode_bool(xdr, resp->common.err == nfserr_eof) < 0)
fs/nfsd/vfs.c:          cdp->err = nfserr_eof; /* will be cleared on successful read */
fs/nfsd/vfs.c:  if (err == nfserr_eof || err == nfserr_toosmall)

A better interim approach might be to select an impossible value
for NFSERR_EOF, as is done for the internal NLM error status codes:

fs/lockd/lockd.h:#define nlm__int__drop_reply   cpu_to_be32(30000)
fs/lockd/lockd.h:#define nlm__int__deadlock     cpu_to_be32(30001)
fs/lockd/lockd.h:#define nlm__int__stale_fh     cpu_to_be32(30002)
fs/lockd/lockd.h:#define nlm__int__failed       cpu_to_be32(30003)


> @@ -245,3 +406,88 @@ const FATTR4_ACL_TRUEFORM	= 89;
>  const FATTR4_ACL_TRUEFORM_SCOPE	= 90;
>  const FATTR4_POSIX_DEFAULT_ACL	= 91;
>  const FATTR4_POSIX_ACCESS_ACL	= 92;
> +
> +/*
> + * Directory notification types.
> + */
> +enum notify_type4 {
> +        NOTIFY4_CHANGE_CHILD_ATTRS = 0,
> +        NOTIFY4_CHANGE_DIR_ATTRS = 1,
> +        NOTIFY4_REMOVE_ENTRY = 2,
> +        NOTIFY4_ADD_ENTRY = 3,
> +        NOTIFY4_RENAME_ENTRY = 4,
> +        NOTIFY4_CHANGE_COOKIE_VERIFIER = 5
> +};
> +
> +/* Changed entry information.  */
> +struct notify_entry4 {
> +        component4      ne_file;
> +        fattr4          ne_attrs;
> +};
> +
> +/* Previous entry information */
> +struct prev_entry4 {
> +        notify_entry4   pe_prev_entry;
> +        /* what READDIR returned for this entry */
> +        nfs_cookie4     pe_prev_entry_cookie;
> +};
> +
> +struct notify_remove4 {
> +        notify_entry4   nrm_old_entry;
> +        nfs_cookie4     nrm_old_entry_cookie;
> +};
> +pragma public notify_remove4;
> +
> +struct notify_add4 {
> +        /*
> +         * Information on object
> +         * possibly renamed over.
> +         */
> +        notify_remove4      nad_old_entry<1>;
> +        notify_entry4       nad_new_entry;
> +        /* what READDIR would have returned for this entry */
> +        nfs_cookie4         nad_new_entry_cookie<1>;
> +        prev_entry4         nad_prev_entry<1>;
> +        bool                nad_last_entry;
> +};
> +pragma public notify_add4;
> +
> +struct notify_attr4 {
> +        notify_entry4   na_changed_entry;
> +};
> +pragma public notify_attr4;
> +
> +struct notify_rename4 {
> +        notify_remove4  nrn_old_entry;
> +        notify_add4     nrn_new_entry;
> +};
> +pragma public notify_rename4;
> +
> +struct notify_verifier4 {
> +        verifier4       nv_old_cookieverf;
> +        verifier4       nv_new_cookieverf;
> +};
> +
> +/*
> + * Objects of type notify_<>4 and
> + * notify_device_<>4 are encoded in this.
> + */
> +typedef opaque notifylist4<>;
> +
> +struct notify4 {
> +        /* composed from notify_type4 or notify_deviceid_type4 */
> +        bitmap4         notify_mask;
> +        notifylist4     notify_vals;
> +};
> +
> +struct CB_NOTIFY4args {
> +        stateid4    cna_stateid;
> +        nfs_fh4     cna_fh;
> +        notify4     cna_changes<>;
> +};
> +pragma public CB_NOTIFY4args;
> +
> +struct CB_NOTIFY4res {
> +        nfsstat4    cnr_status;
> +};
> +pragma public CB_NOTIFY4res;

Let's add the "pragma public" directives in the patches where
they are first needed, instead of here. As subsequent patches
are modified, the need for these directives might vanish.


-- 
Chuck Lever

  reply	other threads:[~2026-06-11 21:33 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11 17:50 [PATCH v6 00/20] nfsd: add support for CB_NOTIFY callbacks in directory delegations Jeff Layton
2026-06-11 17:50 ` [PATCH v6 01/20] nfsd: check fl_lmops in nfsd_breaker_owns_lease() Jeff Layton
2026-06-11 17:50 ` [PATCH v6 02/20] nfsd: add protocol support for CB_NOTIFY Jeff Layton
2026-06-11 21:33   ` Chuck Lever [this message]
2026-06-11 17:50 ` [PATCH v6 03/20] nfs_common: add new NOTIFY4_* flags proposed in RFC8881bis Jeff Layton
2026-06-11 17:50 ` [PATCH v6 04/20] nfsd: allow nfsd to get a dir lease with an ignore mask Jeff Layton
2026-06-11 17:50 ` [PATCH v6 05/20] nfsd: update the fsnotify mark when setting or removing a dir delegation Jeff Layton
2026-06-11 17:50 ` [PATCH v6 06/20] nfsd: make nfsd4_callback_ops->prepare operation bool return Jeff Layton
2026-06-11 17:50 ` [PATCH v6 07/20] nfsd: add callback encoding and decoding linkages for CB_NOTIFY Jeff Layton
2026-06-11 17:50 ` [PATCH v6 08/20] nfsd: use RCU to protect fi_deleg_file Jeff Layton
2026-06-11 17:50 ` [PATCH v6 09/20] nfsd: add data structures for handling CB_NOTIFY Jeff Layton
2026-06-11 17:50 ` [PATCH v6 10/20] nfsd: add notification handlers for dir events Jeff Layton
2026-06-12 17:51   ` Chuck Lever
2026-06-12 18:36     ` Jeff Layton
2026-06-11 17:50 ` [PATCH v6 11/20] nfsd: apply the notify mask to the delegation when requested Jeff Layton
2026-06-12 17:57   ` Chuck Lever
2026-06-11 17:50 ` [PATCH v6 12/20] nfsd: add helper to marshal a fattr4 from completed args Jeff Layton
2026-06-11 17:50 ` [PATCH v6 13/20] nfsd: allow nfsd4_encode_fattr4_change() to work with no export Jeff Layton
2026-06-11 17:50 ` [PATCH v6 14/20] nfsd: send basic file attributes in CB_NOTIFY Jeff Layton
2026-06-11 17:50 ` [PATCH v6 15/20] nfsd: allow encoding a filehandle into fattr4 without a svc_fh Jeff Layton
2026-06-12 18:03   ` Chuck Lever
2026-06-11 17:50 ` [PATCH v6 16/20] nfsd: add a fi_connectable flag to struct nfs4_file Jeff Layton
2026-06-12 18:06   ` Chuck Lever
2026-06-11 17:50 ` [PATCH v6 17/20] nfsd: add the filehandle to returned attributes in CB_NOTIFY Jeff Layton
2026-06-12 18:08   ` Chuck Lever
2026-06-11 17:50 ` [PATCH v6 18/20] nfsd: properly track requested child attributes Jeff Layton
2026-06-12 18:10   ` Chuck Lever
2026-06-11 17:50 ` [PATCH v6 19/20] nfsd: track requested dir attributes Jeff Layton
2026-06-12 18:13   ` Chuck Lever
2026-06-11 17:50 ` [PATCH v6 20/20] nfsd: add support to CB_NOTIFY for dir attribute changes Jeff Layton
2026-06-12 18:21   ` Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9119f5c0-cf25-4f30-bad2-b928a2db239d@app.fastmail.com \
    --to=cel@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=alex.aring@gmail.com \
    --cc=amir73il@gmail.com \
    --cc=anna@kernel.org \
    --cc=brauner@kernel.org \
    --cc=calum.mackay@oracle.com \
    --cc=corbet@lwn.net \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=skhan@linuxfoundation.org \
    --cc=tom@talpey.com \
    --cc=trondmy@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®