From: Jan Kara <jack@suse.cz>
To: Jeff Layton <jlayton@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Chuck Lever <chuck.lever@oracle.com>,
Alexander Aring <alex.aring@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.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>,
Amir Goldstein <amir73il@gmail.com>,
Calum Mackay <calum.mackay@oracle.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-nfs@vger.kernel.org
Subject: Re: [PATCH v2 07/28] fsnotify: add FSNOTIFY_EVENT_RENAME data type
Date: Fri, 17 Apr 2026 13:56:45 +0200 [thread overview]
Message-ID: <njcjrskw4lfsjn7pjfan4xyqmk37jzlc5amgc7snbhpsrbsdnq@mawp7fdkczrk> (raw)
In-Reply-To: <20260416-dir-deleg-v2-7-851426a550f6@kernel.org>
On Thu 16-04-26 10:35:08, Jeff Layton wrote:
> Add a new fsnotify_rename_data struct and FSNOTIFY_EVENT_RENAME data
> type that carries both the moved dentry and the inode that was
> overwritten by the rename (if any).
>
> Update fsnotify_data_inode(), fsnotify_data_dentry(), and
> fsnotify_data_sb() to handle the new type, and add a new
> fsnotify_data_rename_target() helper for extracting the overwritten
> target inode.
>
> Update fsnotify_move() to use the new data type for FS_RENAME and
> FS_MOVED_TO events, passing the overwritten target inode through the
> event data. FS_MOVED_FROM is unchanged since the source directory
> doesn't need overwrite information.
>
> This is done so that fsnotify consumers like nfsd can atomically
> observe the overwritten file when a rename replaces an existing entry,
> without needing a separate FS_DELETE event.
>
> Assisted-by: Claude (Anthropic Claude Code)
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> include/linux/fsnotify.h | 8 ++++++--
> include/linux/fsnotify_backend.h | 20 ++++++++++++++++++++
> 2 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
> index 079c18bcdbde..bda798bc67bc 100644
> --- a/include/linux/fsnotify.h
> +++ b/include/linux/fsnotify.h
> @@ -257,6 +257,10 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
> __u32 new_dir_mask = FS_MOVED_TO;
> __u32 rename_mask = FS_RENAME;
> const struct qstr *new_name = &moved->d_name;
> + struct fsnotify_rename_data rd = {
> + .moved = moved,
> + .target = target,
> + };
>
> if (isdir) {
> old_dir_mask |= FS_ISDIR;
> @@ -265,12 +269,12 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
> }
>
> /* Event with information about both old and new parent+name */
> - fsnotify_name(rename_mask, moved, FSNOTIFY_EVENT_DENTRY,
> + fsnotify_name(rename_mask, &rd, FSNOTIFY_EVENT_RENAME,
> old_dir, old_name, 0);
>
> fsnotify_name(old_dir_mask, source, FSNOTIFY_EVENT_INODE,
> old_dir, old_name, fs_cookie);
> - fsnotify_name(new_dir_mask, source, FSNOTIFY_EVENT_INODE,
> + fsnotify_name(new_dir_mask, &rd, FSNOTIFY_EVENT_RENAME,
> new_dir, new_name, fs_cookie);
>
> if (target)
> diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
> index 66e185bd1b1b..f8c8fb7f34ae 100644
> --- a/include/linux/fsnotify_backend.h
> +++ b/include/linux/fsnotify_backend.h
> @@ -311,6 +311,7 @@ enum fsnotify_data_type {
> FSNOTIFY_EVENT_DENTRY,
> FSNOTIFY_EVENT_MNT,
> FSNOTIFY_EVENT_ERROR,
> + FSNOTIFY_EVENT_RENAME,
> };
>
> struct fs_error_report {
> @@ -335,6 +336,11 @@ struct fsnotify_mnt {
> u64 mnt_id;
> };
>
> +struct fsnotify_rename_data {
> + struct dentry *moved; /* the dentry that was renamed */
> + struct inode *target; /* inode overwritten by rename, or NULL */
> +};
> +
> static inline struct inode *fsnotify_data_inode(const void *data, int data_type)
> {
> switch (data_type) {
> @@ -348,6 +354,8 @@ static inline struct inode *fsnotify_data_inode(const void *data, int data_type)
> return d_inode(file_range_path(data)->dentry);
> case FSNOTIFY_EVENT_ERROR:
> return ((struct fs_error_report *)data)->inode;
> + case FSNOTIFY_EVENT_RENAME:
> + return d_inode(((const struct fsnotify_rename_data *)data)->moved);
> default:
> return NULL;
> }
> @@ -363,6 +371,8 @@ static inline struct dentry *fsnotify_data_dentry(const void *data, int data_typ
> return ((const struct path *)data)->dentry;
> case FSNOTIFY_EVENT_FILE_RANGE:
> return file_range_path(data)->dentry;
> + case FSNOTIFY_EVENT_RENAME:
> + return ((struct fsnotify_rename_data *)data)->moved;
> default:
> return NULL;
> }
> @@ -395,6 +405,8 @@ static inline struct super_block *fsnotify_data_sb(const void *data,
> return file_range_path(data)->dentry->d_sb;
> case FSNOTIFY_EVENT_ERROR:
> return ((struct fs_error_report *) data)->sb;
> + case FSNOTIFY_EVENT_RENAME:
> + return ((const struct fsnotify_rename_data *)data)->moved->d_sb;
> default:
> return NULL;
> }
> @@ -430,6 +442,14 @@ static inline struct fs_error_report *fsnotify_data_error_report(
> }
> }
>
> +static inline struct inode *fsnotify_data_rename_target(const void *data,
> + int data_type)
> +{
> + if (data_type == FSNOTIFY_EVENT_RENAME)
> + return ((const struct fsnotify_rename_data *)data)->target;
> + return NULL;
> +}
> +
> static inline const struct file_range *fsnotify_data_file_range(
> const void *data,
> int data_type)
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2026-04-17 11:57 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-16 17:35 [PATCH v2 00/28] vfs/nfsd: add support for CB_NOTIFY callbacks in directory delegations Jeff Layton
2026-04-16 17:35 ` [PATCH v2 01/28] filelock: pass current blocking lease to trace_break_lease_block() rather than "new_fl" Jeff Layton
2026-04-16 17:35 ` [PATCH v2 02/28] filelock: add support for ignoring deleg breaks for dir change events Jeff Layton
2026-04-16 17:35 ` [PATCH v2 03/28] filelock: add a tracepoint to start of break_lease() Jeff Layton
2026-04-16 17:35 ` [PATCH v2 04/28] filelock: add an inode_lease_ignore_mask helper Jeff Layton
2026-04-16 17:35 ` [PATCH v2 05/28] fsnotify: new tracepoint in fsnotify() Jeff Layton
2026-04-17 11:49 ` Jan Kara
2026-04-16 17:35 ` [PATCH v2 06/28] fsnotify: add fsnotify_modify_mark_mask() Jeff Layton
2026-04-16 17:35 ` [PATCH v2 07/28] fsnotify: add FSNOTIFY_EVENT_RENAME data type Jeff Layton
2026-04-16 19:24 ` Amir Goldstein
2026-04-16 20:52 ` Jeff Layton
2026-04-17 11:56 ` Jan Kara [this message]
2026-04-16 17:35 ` [PATCH v2 08/28] nfsd: check fl_lmops in nfsd_breaker_owns_lease() Jeff Layton
2026-04-16 17:35 ` [PATCH v2 09/28] nfsd: add protocol support for CB_NOTIFY Jeff Layton
2026-04-16 17:35 ` [PATCH v2 10/28] nfs_common: add new NOTIFY4_* flags proposed in RFC8881bis Jeff Layton
2026-04-16 17:35 ` [PATCH v2 11/28] nfsd: allow nfsd to get a dir lease with an ignore mask Jeff Layton
2026-04-16 17:35 ` [PATCH v2 12/28] nfsd: update the fsnotify mark when setting or removing a dir delegation Jeff Layton
2026-04-16 17:35 ` [PATCH v2 13/28] nfsd: make nfsd4_callback_ops->prepare operation bool return Jeff Layton
2026-04-16 17:35 ` [PATCH v2 14/28] nfsd: add callback encoding and decoding linkages for CB_NOTIFY Jeff Layton
2026-04-16 17:35 ` [PATCH v2 15/28] nfsd: use RCU to protect fi_deleg_file Jeff Layton
2026-04-16 17:35 ` [PATCH v2 16/28] nfsd: add data structures for handling CB_NOTIFY Jeff Layton
2026-04-16 17:35 ` [PATCH v2 17/28] nfsd: add notification handlers for dir events Jeff Layton
2026-04-16 17:35 ` [PATCH v2 18/28] nfsd: add tracepoint to dir_event handler Jeff Layton
2026-04-16 17:35 ` [PATCH v2 19/28] nfsd: apply the notify mask to the delegation when requested Jeff Layton
2026-04-16 17:35 ` [PATCH v2 20/28] nfsd: add helper to marshal a fattr4 from completed args Jeff Layton
2026-04-16 17:35 ` [PATCH v2 21/28] nfsd: allow nfsd4_encode_fattr4_change() to work with no export Jeff Layton
2026-04-16 17:35 ` [PATCH v2 22/28] nfsd: send basic file attributes in CB_NOTIFY Jeff Layton
2026-04-16 17:35 ` [PATCH v2 23/28] nfsd: allow encoding a filehandle into fattr4 without a svc_fh Jeff Layton
2026-04-16 17:35 ` [PATCH v2 24/28] nfsd: add a fi_connectable flag to struct nfs4_file Jeff Layton
2026-04-16 17:35 ` [PATCH v2 25/28] nfsd: add the filehandle to returned attributes in CB_NOTIFY Jeff Layton
2026-04-16 17:35 ` [PATCH v2 26/28] nfsd: properly track requested child attributes Jeff Layton
2026-04-16 17:35 ` [PATCH v2 27/28] nfsd: track requested dir attributes Jeff Layton
2026-04-16 17:35 ` [PATCH v2 28/28] nfsd: add support to CB_NOTIFY for dir attribute changes Jeff Layton
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=njcjrskw4lfsjn7pjfan4xyqmk37jzlc5amgc7snbhpsrbsdnq@mawp7fdkczrk \
--to=jack@suse.cz \
--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=chuck.lever@oracle.com \
--cc=corbet@lwn.net \
--cc=jlayton@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).