Re: [PATCH v2] nfsd: recall deleg if a requested dir attr change can't be encoded

"Chuck Lever" <[email protected]>
Newsgroups gmane.linux.nfs,gmane.linux.kernel
Message-ID <[email protected]>

On Fri, Jun 19, 2026, at 5:32 PM, Jeff Layton wrote:
> When the client requested NOTIFY4_CHANGE_DIR_ATTRS,
> nfsd4_cb_notify_prepare() tried to append the dir attribute change to
> the CB_NOTIFY, but silently dropped it if the attrmask space
> reservation failed or nfsd4_encode_dir_attr_change() failed to marshal
> the change into the buffer. It then returned true and transmitted a
> CB_NOTIFY lacking the requested notification, leaving the client's
> cached directory attributes stale with no indication.
>
> RFC 8881 s10.9.4 requires the server to recall the delegation when the
> directory changes in a way that is not covered by the notification.
> Treat a failure to encode the dir attribute change like the per-event
> encode failures already handled in the loop above: set error and fall
> through to out_recall.
>
> The granted notification mask and the requested dir attribute mask come
> from independent fields of the GET_DIR_DELEGATION request, so a client
> can be granted NOTIFY4_CHANGE_DIR_ATTRS while requesting no specific dir
> attributes. nfsd4_encode_dir_attr_change() now distinguishes a genuine
> encode failure (which forces the recall) from that benign case (which
> simply omits the event).
>
> While we're in there, also remove an unneeded check for
> NOTIFY4_CHANGE_DIR_ATTRS from nfsd4_encode_dir_attr_change().
>
> Fixes: 757a16cd93d5 ("nfsd: add support to CB_NOTIFY for dir attribute 
> changes")
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Jeff Layton <[email protected]>
> ---
> This version should address Chuck's comments about the NULL pointer
> handling.
> ---
> Changes in v2:
> - Allow nfsd4_encode_dir_attr_change() to return ERR_PTR when there are 
> errors
> - Drop unneeded NOTIFY4_CHANGE_DIR_ATTRS check
> - Link to v1: 
> https://lore.kernel.org/r/[email protected]
> ---
>  fs/nfsd/nfs4state.c | 43 ++++++++++++++++++++++++++++---------------
>  fs/nfsd/nfs4xdr.c   | 30 +++++++++++++++++-------------
>  2 files changed, 45 insertions(+), 28 deletions(-)

Sashiko reports (and gpt-5.5 agrees):

Pre-existing issues:
- [High] Genuine encode failures and `vfs_getattr` failures are silently masked as 0-length attributes, causing the directory attribute change event to be erroneously omitted instead of triggering a delegation recall.

But this isn’t really a pre-existing issue. It pre-exists this fix, yes,
but it was introduced by “nfsd: add support to CB_NOTIFY for dir
attribute changes”. What that means is this patch is not yet a complete
fix.


-- 
Chuck Lever
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.