Add support for handling NOTIFY4_ADD_ENTRY events. When a notification comes in, marshall the event to the notify_spool and kick off the callback. Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx> --- fs/nfsd/nfs4proc.c | 2 +- fs/nfsd/nfs4state.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 77b6d0363b9f4cfea96f3f1abd3e462fd2a77754..a2996343fa0db33e014731f62aaa4e7c72506a76 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -2292,7 +2292,7 @@ nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, return status == nfserr_same ? nfs_ok : status; } -#define SUPPORTED_NOTIFY_MASK BIT(NOTIFY4_REMOVE_ENTRY) +#define SUPPORTED_NOTIFY_MASK BIT(NOTIFY4_REMOVE_ENTRY|NOTIFY4_ADD_ENTRY) static __be32 nfsd4_get_dir_delegation(struct svc_rqst *rqstp, diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index a610a90d119a771771cdb60ce3ee4ab3604cb8a3..9dc607e355d5839d80946d4983205c15ece6a71e 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -9697,6 +9697,31 @@ nfsd_handle_dir_event(u32 mask, const struct inode *dir, const void *data, ent->notify_vals.data = p; ++nns->nns_idx; } + if (mask & FS_CREATE) { + static uint32_t notify_add_bitmap = BIT(NOTIFY4_ADD_ENTRY); + struct notify4 *ent = &nns->nns_ent[nns->nns_idx]; + struct notify_add4 na = { }; + u8 *p = (u8 *)(stream->p); + + if (!(flc->flc_flags & FL_IGN_DIR_CREATE)) + continue; + + na.nad_new_entry.ne_file.len = name->len; + na.nad_new_entry.ne_file.data = (char *)name->name; + na.nad_new_entry.ne_attrs.attrmask.count = 1; + na.nad_new_entry.ne_attrs.attrmask.element = &zerobm; + if (!xdrgen_encode_notify_add4(stream, &na)) { + pr_warn("nfsd: unable to marshal notify_add4 to xdr stream\n"); + continue; + } + + /* grab a notify4 in the buffer and set it up */ + ent->notify_mask.count = 1; + ent->notify_mask.element = ¬ify_add_bitmap; + ent->notify_vals.len = (u8 *)stream->p - p; + ent->notify_vals.data = p; + ++nns->nns_idx; + } if (nns->nns_idx) nfsd4_run_cb_notify(ncn); -- 2.49.0