Re: [PATCH -next -v4 01/17] fs: pass struct path to notify_change()
From: Al Viro
Date: Tue Nov 17 2026 - 13:32:23 EST
On Tue, Nov 17, 2026 at 11:05:26PM +0800, Cai Xinchen wrote:
> +notify_change() and do_truncate() now take a const struct path * instead
> +of a struct dentry *. They use path->dentry, so callers that only have a
> +dentry must provide a struct path. struct iattr has a new ia_path member,
> +which notify_change() sets for the duration of the call; it must not be
> +stored beyond that. Filesystems that forward a change to another inode
> +can use notify_change_target() to update the target dentry while keeping
> +the caller-supplied path in ia_path.
That needs a bit along the lines of "path MUST be consistent - don't combine
a dentry from one filesystem with mount of another". All in-kernel callers
might have appropriate struct mount references on hand, but for out-of-tree
code that might be not true and we'd better be upfront about the headache
we are inflicting.
I'm not sure we really want to provide those mount references, TBH - it does
add a constraint not just on out-of-tree callers, but upon the future uses
in the kernel. If NTFS is the only reason... ugh.
> diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
> index 11c70888f38b..410906a66ee9 100644
> --- a/drivers/base/devtmpfs.c
> +++ b/drivers/base/devtmpfs.c
> @@ -284,13 +284,14 @@ static int handle_create(const char *nodename, umode_t mode, kuid_t uid,
> dev->devt, NULL);
> if (!err) {
> struct iattr newattrs;
> + struct path attr_path = { .mnt = path.mnt, .dentry = dentry };
>
> newattrs.ia_mode = mode;
> newattrs.ia_uid = uid;
> newattrs.ia_gid = gid;
> newattrs.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID;
> inode_lock(d_inode(dentry));
> - notify_change(&nop_mnt_idmap, dentry, &newattrs, NULL);
> + notify_change(&nop_mnt_idmap, &attr_path, &newattrs, NULL);
BTW, why not something like
notify_change(&nop_mnt_idmap,
&(struct path){.mnt = path.mnt, .dentry = dentry},
&newattrs, NULL);
instead of that named local? Same question for other places like that...
> +int notify_change_target(const struct mnt_idmap *idmap,
> + const struct path *path, struct dentry *target,
> + struct iattr *attr,
> + struct delegated_inode *delegated_inode)
> +{
> + if (WARN_ON_ONCE(!target))
> + return -EINVAL;
> + return do_notify_change(path, idmap, target, attr, delegated_inode);
> +}