[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <jshbhldhrbr2vbzfvuary3qowbfavcgkjznbgnjwhnxvmudvhw@c2uam4vtghcw>
Date: Fri, 26 Sep 2025 17:33:19 +0200
From: Jan Kara <jack@...e.cz>
To: Jeff Layton <jlayton@...nel.org>
Cc: Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>, Chuck Lever <chuck.lever@...cle.com>,
Alexander Aring <alex.aring@...il.com>, Trond Myklebust <trondmy@...nel.org>,
Anna Schumaker <anna@...nel.org>, Steve French <sfrench@...ba.org>,
Ronnie Sahlberg <ronniesahlberg@...il.com>, Shyam Prasad N <sprasad@...rosoft.com>,
Tom Talpey <tom@...pey.com>, Bharath SM <bharathsm@...rosoft.com>,
NeilBrown <neil@...wn.name>, Olga Kornievskaia <okorniev@...hat.com>,
Dai Ngo <Dai.Ngo@...cle.com>, Jonathan Corbet <corbet@....net>,
Amir Goldstein <amir73il@...il.com>, Miklos Szeredi <miklos@...redi.hu>,
Paulo Alcantara <pc@...guebit.org>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>, Danilo Krummrich <dakr@...nel.org>,
David Howells <dhowells@...hat.com>, Tyler Hicks <code@...icks.com>,
Namjae Jeon <linkinjeon@...nel.org>, Steve French <smfrench@...il.com>,
Sergey Senozhatsky <senozhatsky@...omium.org>, Carlos Maiolino <cem@...nel.org>,
Steven Rostedt <rostedt@...dmis.org>, Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>, Rick Macklem <rick.macklem@...il.com>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org, linux-nfs@...r.kernel.org,
linux-cifs@...r.kernel.org, samba-technical@...ts.samba.org, linux-doc@...r.kernel.org,
netfs@...ts.linux.dev, ecryptfs@...r.kernel.org, linux-unionfs@...r.kernel.org,
linux-xfs@...r.kernel.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH v3 07/38] vfs: make vfs_create break delegations on
parent directory
On Fri 26-09-25 17:23:41, Jan Kara wrote:
> On Wed 24-09-25 14:05:53, Jeff Layton wrote:
> > In order to add directory delegation support, we need to break
> > delegations on the parent whenever there is going to be a change in the
> > directory.
> >
> > Rename vfs_create as __vfs_create, make it static, and add a new
> > delegated_inode parameter. Fix do_mknodat to call __vfs_create and wait
> > for a delegation break if there is one. Add a new exported vfs_create
> > wrapper that passes in NULL for delegated_inode.
> >
> > Signed-off-by: Jeff Layton <jlayton@...nel.org>
>
> Looks good. Feel free to add:
>
> Reviewed-by: Jan Kara <jack@...e.cz>
Sorry, I've sent this twise by mistake.
Honza
> > ---
> > fs/namei.c | 55 ++++++++++++++++++++++++++++++++++++-------------------
> > 1 file changed, 36 insertions(+), 19 deletions(-)
> >
> > diff --git a/fs/namei.c b/fs/namei.c
> > index 903b70a82530938a0fdf10508529a1b7cc38136d..d4b8330a3eb97e205dc2e71766fed1e45503323b 100644
> > --- a/fs/namei.c
> > +++ b/fs/namei.c
> > @@ -3370,6 +3370,32 @@ static inline umode_t vfs_prepare_mode(struct mnt_idmap *idmap,
> > return mode;
> > }
> >
> > +static int __vfs_create(struct mnt_idmap *idmap, struct inode *dir,
> > + struct dentry *dentry, umode_t mode, bool want_excl,
> > + struct inode **delegated_inode)
> > +{
> > + int error;
> > +
> > + error = may_create(idmap, dir, dentry);
> > + if (error)
> > + return error;
> > +
> > + if (!dir->i_op->create)
> > + return -EACCES; /* shouldn't it be ENOSYS? */
> > +
> > + mode = vfs_prepare_mode(idmap, dir, mode, S_IALLUGO, S_IFREG);
> > + error = security_inode_create(dir, dentry, mode);
> > + if (error)
> > + return error;
> > + error = try_break_deleg(dir, delegated_inode);
> > + if (error)
> > + return error;
> > + error = dir->i_op->create(idmap, dir, dentry, mode, want_excl);
> > + if (!error)
> > + fsnotify_create(dir, dentry);
> > + return error;
> > +}
> > +
> > /**
> > * vfs_create - create new file
> > * @idmap: idmap of the mount the inode was found from
> > @@ -3389,23 +3415,7 @@ static inline umode_t vfs_prepare_mode(struct mnt_idmap *idmap,
> > int vfs_create(struct mnt_idmap *idmap, struct inode *dir,
> > struct dentry *dentry, umode_t mode, bool want_excl)
> > {
> > - int error;
> > -
> > - error = may_create(idmap, dir, dentry);
> > - if (error)
> > - return error;
> > -
> > - if (!dir->i_op->create)
> > - return -EACCES; /* shouldn't it be ENOSYS? */
> > -
> > - mode = vfs_prepare_mode(idmap, dir, mode, S_IALLUGO, S_IFREG);
> > - error = security_inode_create(dir, dentry, mode);
> > - if (error)
> > - return error;
> > - error = dir->i_op->create(idmap, dir, dentry, mode, want_excl);
> > - if (!error)
> > - fsnotify_create(dir, dentry);
> > - return error;
> > + return __vfs_create(idmap, dir, dentry, mode, want_excl, NULL);
> > }
> > EXPORT_SYMBOL(vfs_create);
> >
> > @@ -4278,6 +4288,7 @@ static int do_mknodat(int dfd, struct filename *name, umode_t mode,
> > struct path path;
> > int error;
> > unsigned int lookup_flags = 0;
> > + struct inode *delegated_inode = NULL;
> >
> > error = may_mknod(mode);
> > if (error)
> > @@ -4296,8 +4307,9 @@ static int do_mknodat(int dfd, struct filename *name, umode_t mode,
> > idmap = mnt_idmap(path.mnt);
> > switch (mode & S_IFMT) {
> > case 0: case S_IFREG:
> > - error = vfs_create(idmap, path.dentry->d_inode,
> > - dentry, mode, true);
> > + error = __vfs_create(idmap, path.dentry->d_inode,
> > + dentry, mode, true,
> > + &delegated_inode);
> > if (!error)
> > security_path_post_mknod(idmap, dentry);
> > break;
> > @@ -4312,6 +4324,11 @@ static int do_mknodat(int dfd, struct filename *name, umode_t mode,
> > }
> > out2:
> > done_path_create(&path, dentry);
> > + if (delegated_inode) {
> > + error = break_deleg_wait(&delegated_inode);
> > + if (!error)
> > + goto retry;
> > + }
> > if (retry_estale(error, lookup_flags)) {
> > lookup_flags |= LOOKUP_REVAL;
> > goto retry;
> >
> > --
> > 2.51.0
> >
> --
> Jan Kara <jack@...e.com>
> SUSE Labs, CR
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists