From: Jan Kara <jack@suse.cz>
To: Jeff Layton <jlayton@kernel.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
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>,
Trond Myklebust <trondmy@kernel.org>,
Anna Schumaker <anna@kernel.org>,
Steve French <sfrench@samba.org>,
Paulo Alcantara <pc@manguebit.org>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Shyam Prasad N <sprasad@microsoft.com>,
Tom Talpey <tom@talpey.com>,
Bharath SM <bharathsm@microsoft.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
David Howells <dhowells@redhat.com>,
Tyler Hicks <code@tyhicks.com>, NeilBrown <neil@brown.name>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>,
Amir Goldstein <amir73il@gmail.com>,
Namjae Jeon <linkinjeon@kernel.org>,
Steve French <smfrench@gmail.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Carlos Maiolino <cem@kernel.org>,
Kuniyuki Iwashima <kuniyu@google.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org,
samba-technical@lists.samba.org, netfs@lists.linux.dev,
ecryptfs@vger.kernel.org, linux-unionfs@vger.kernel.org,
linux-xfs@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH 05/13] vfs: allow rmdir to wait for delegation break on parent
Date: Mon, 20 Oct 2025 11:38:25 +0200 [thread overview]
Message-ID: <dmixw6ybhw2bqfejcpd5xq6i6o77heuunhnezy3nwrgraw2fce@e7xhnz24u6yn> (raw)
In-Reply-To: <20251013-dir-deleg-ro-v1-5-406780a70e5e@kernel.org>
On Mon 13-10-25 10:48:03, 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.
>
> Add a "delegated_inode" return pointer to vfs_rmdir() and populate that
> pointer with the parent inode if it's non-NULL. Most existing in-kernel
> callers pass in a NULL pointer.
>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> drivers/base/devtmpfs.c | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/namei.c | 22 +++++++++++++++++-----
> fs/nfsd/nfs4recover.c | 4 ++--
> fs/nfsd/vfs.c | 2 +-
> fs/overlayfs/overlayfs.h | 2 +-
> fs/smb/server/vfs.c | 4 ++--
> include/linux/fs.h | 3 ++-
> 8 files changed, 27 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
> index 0e79621cb0f79870003b867ca384199171ded4e0..104025104ef75381984fd94dfbd50feeaa8cdd22 100644
> --- a/drivers/base/devtmpfs.c
> +++ b/drivers/base/devtmpfs.c
> @@ -261,7 +261,7 @@ static int dev_rmdir(const char *name)
> return PTR_ERR(dentry);
> if (d_inode(dentry)->i_private == &thread)
> err = vfs_rmdir(&nop_mnt_idmap, d_inode(parent.dentry),
> - dentry);
> + dentry, NULL);
> else
> err = -EPERM;
>
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index 35830b3144f8f71374a78b3e7463b864f4fc216e..88631291b32535f623a3fbe4ea9b6ed48a306ca0 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -540,7 +540,7 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
> if (d_unhashed(lower_dentry))
> rc = -EINVAL;
> else
> - rc = vfs_rmdir(&nop_mnt_idmap, lower_dir, lower_dentry);
> + rc = vfs_rmdir(&nop_mnt_idmap, lower_dir, lower_dentry, NULL);
> }
> if (!rc) {
> clear_nlink(d_inode(dentry));
> diff --git a/fs/namei.c b/fs/namei.c
> index 86cf6eca1f485361c6732974e4103cf5ea721539..4b5a99653c558397e592715d9d4663cd4a63ef86 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -4522,9 +4522,10 @@ SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode)
>
> /**
> * vfs_rmdir - remove directory
> - * @idmap: idmap of the mount the inode was found from
> - * @dir: inode of the parent directory
> - * @dentry: dentry of the child directory
> + * @idmap: idmap of the mount the inode was found from
> + * @dir: inode of the parent directory
> + * @dentry: dentry of the child directory
> + * @delegated_inode: returns parent inode, if it's delegated.
> *
> * Remove a directory.
> *
> @@ -4535,7 +4536,7 @@ SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode)
> * raw inode simply pass @nop_mnt_idmap.
> */
> int vfs_rmdir(struct mnt_idmap *idmap, struct inode *dir,
> - struct dentry *dentry)
> + struct dentry *dentry, struct inode **delegated_inode)
> {
> int error = may_delete(idmap, dir, dentry, 1);
>
> @@ -4557,6 +4558,10 @@ int vfs_rmdir(struct mnt_idmap *idmap, struct inode *dir,
> if (error)
> goto out;
>
> + error = try_break_deleg(dir, delegated_inode);
> + if (error)
> + goto out;
> +
> error = dir->i_op->rmdir(dir, dentry);
> if (error)
> goto out;
> @@ -4583,6 +4588,7 @@ int do_rmdir(int dfd, struct filename *name)
> struct qstr last;
> int type;
> unsigned int lookup_flags = 0;
> + struct inode *delegated_inode = NULL;
> retry:
> error = filename_parentat(dfd, name, lookup_flags, &path, &last, &type);
> if (error)
> @@ -4612,7 +4618,8 @@ int do_rmdir(int dfd, struct filename *name)
> error = security_path_rmdir(&path, dentry);
> if (error)
> goto exit4;
> - error = vfs_rmdir(mnt_idmap(path.mnt), path.dentry->d_inode, dentry);
> + error = vfs_rmdir(mnt_idmap(path.mnt), path.dentry->d_inode,
> + dentry, &delegated_inode);
> exit4:
> dput(dentry);
> exit3:
> @@ -4620,6 +4627,11 @@ int do_rmdir(int dfd, struct filename *name)
> mnt_drop_write(path.mnt);
> exit2:
> path_put(&path);
> + 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;
> diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
> index 3dfbb85c9a1166b56e56eb9f1d6bfd140584730b..ad3acbb956d90cac88f74e5f598719af6f1f8328 100644
> --- a/fs/nfsd/nfs4recover.c
> +++ b/fs/nfsd/nfs4recover.c
> @@ -275,7 +275,7 @@ nfsd4_unlink_clid_dir(char *name, struct nfsd_net *nn)
> status = -ENOENT;
> if (d_really_is_negative(dentry))
> goto out;
> - status = vfs_rmdir(&nop_mnt_idmap, d_inode(dir), dentry);
> + status = vfs_rmdir(&nop_mnt_idmap, d_inode(dir), dentry, NULL);
> out:
> dput(dentry);
> out_unlock:
> @@ -367,7 +367,7 @@ purge_old(struct dentry *parent, char *cname, struct nfsd_net *nn)
> inode_lock_nested(d_inode(parent), I_MUTEX_PARENT);
> child = lookup_one(&nop_mnt_idmap, &QSTR(cname), parent);
> if (!IS_ERR(child)) {
> - status = vfs_rmdir(&nop_mnt_idmap, d_inode(parent), child);
> + status = vfs_rmdir(&nop_mnt_idmap, d_inode(parent), child, NULL);
> if (status)
> printk("failed to remove client recovery directory %pd\n",
> child);
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index 447f5ab8e0b92288c9f220060ab15f32f2a84de9..7d8cd2595f197be9741ee6320d43ed6651896647 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -2194,7 +2194,7 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
> break;
> }
> } else {
> - host_err = vfs_rmdir(&nop_mnt_idmap, dirp, rdentry);
> + host_err = vfs_rmdir(&nop_mnt_idmap, dirp, rdentry, NULL);
> }
> fh_fill_post_attrs(fhp);
>
> diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
> index 0f65f9a5d54d4786b39e4f4f30f416d5b9016e70..d215d7349489686b66bb66e939b27046f7d836f6 100644
> --- a/fs/overlayfs/overlayfs.h
> +++ b/fs/overlayfs/overlayfs.h
> @@ -206,7 +206,7 @@ static inline int ovl_do_notify_change(struct ovl_fs *ofs,
> static inline int ovl_do_rmdir(struct ovl_fs *ofs,
> struct inode *dir, struct dentry *dentry)
> {
> - int err = vfs_rmdir(ovl_upper_mnt_idmap(ofs), dir, dentry);
> + int err = vfs_rmdir(ovl_upper_mnt_idmap(ofs), dir, dentry, NULL);
>
> pr_debug("rmdir(%pd2) = %i\n", dentry, err);
> return err;
> diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
> index 3d2190f26623b23ea79c63410905a3c3ad684048..c5f0f3170d586cb2dc4d416b80948c642797fb82 100644
> --- a/fs/smb/server/vfs.c
> +++ b/fs/smb/server/vfs.c
> @@ -609,7 +609,7 @@ int ksmbd_vfs_remove_file(struct ksmbd_work *work, const struct path *path)
>
> idmap = mnt_idmap(path->mnt);
> if (S_ISDIR(d_inode(path->dentry)->i_mode)) {
> - err = vfs_rmdir(idmap, d_inode(parent), path->dentry);
> + err = vfs_rmdir(idmap, d_inode(parent), path->dentry, NULL);
> if (err && err != -ENOTEMPTY)
> ksmbd_debug(VFS, "rmdir failed, err %d\n", err);
> } else {
> @@ -1090,7 +1090,7 @@ int ksmbd_vfs_unlink(struct file *filp)
> dget(dentry);
>
> if (S_ISDIR(d_inode(dentry)->i_mode))
> - err = vfs_rmdir(idmap, d_inode(dir), dentry);
> + err = vfs_rmdir(idmap, d_inode(dir), dentry, NULL);
> else
> err = vfs_unlink(idmap, d_inode(dir), dentry, NULL);
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 1040df3792794cd353b86558b41618294e25b8a6..d8bdaf7c87502ff17775602f5391d375738b4ed8 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2120,7 +2120,8 @@ int vfs_symlink(struct mnt_idmap *, struct inode *,
> struct dentry *, const char *);
> int vfs_link(struct dentry *, struct mnt_idmap *, struct inode *,
> struct dentry *, struct inode **);
> -int vfs_rmdir(struct mnt_idmap *, struct inode *, struct dentry *);
> +int vfs_rmdir(struct mnt_idmap *, struct inode *, struct dentry *,
> + struct inode **);
> int vfs_unlink(struct mnt_idmap *, struct inode *, struct dentry *,
> struct inode **);
>
>
> --
> 2.51.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2025-10-20 9:38 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-13 14:47 [PATCH 00/13] vfs: recall-only directory delegations for knfsd Jeff Layton
2025-10-13 14:47 ` [PATCH 01/13] filelock: push the S_ISREG check down to ->setlease handlers Jeff Layton
2025-10-14 5:37 ` NeilBrown
2025-10-14 11:07 ` Jeff Layton
2025-10-13 14:48 ` [PATCH 02/13] filelock: add a lm_may_setlease lease_manager callback Jeff Layton
2025-10-14 5:34 ` NeilBrown
2025-10-14 11:10 ` Jeff Layton
2025-10-14 22:10 ` NeilBrown
2025-10-15 11:35 ` Jeff Layton
2025-10-13 14:48 ` [PATCH 03/13] vfs: add try_break_deleg calls for parents to vfs_{link,rename,unlink} Jeff Layton
2025-10-20 9:38 ` Jan Kara
2025-10-13 14:48 ` [PATCH 04/13] vfs: allow mkdir to wait for delegation break on parent Jeff Layton
2025-10-20 9:38 ` Jan Kara
2025-10-13 14:48 ` [PATCH 05/13] vfs: allow rmdir " Jeff Layton
2025-10-20 9:38 ` Jan Kara [this message]
2025-10-13 14:48 ` [PATCH 06/13] vfs: break parent dir delegations in open(..., O_CREAT) codepath Jeff Layton
2025-10-20 9:38 ` Jan Kara
2025-10-13 14:48 ` [PATCH 07/13] vfs: make vfs_create break delegations on parent directory Jeff Layton
2025-10-13 20:33 ` Jeff Layton
2025-10-20 9:38 ` Jan Kara
2025-10-13 14:48 ` [PATCH 08/13] vfs: make vfs_mknod " Jeff Layton
2025-10-20 9:38 ` Jan Kara
2025-10-13 14:48 ` [PATCH 09/13] filelock: lift the ban on directory leases in generic_setlease Jeff Layton
2025-10-13 14:48 ` [PATCH 10/13] nfsd: allow filecache to hold S_IFDIR files Jeff Layton
2025-10-14 5:45 ` NeilBrown
2025-10-13 14:48 ` [PATCH 11/13] nfsd: allow DELEGRETURN on directories Jeff Layton
2025-10-13 14:48 ` [PATCH 12/13] nfsd: check for delegation conflicts vs. the same client Jeff Layton
2025-10-14 5:48 ` NeilBrown
2025-10-13 14:48 ` [PATCH 13/13] nfsd: wire up GET_DIR_DELEGATION handling Jeff Layton
2025-10-13 14:52 ` [PATCH 00/13] vfs: recall-only directory delegations for knfsd Chuck Lever
2025-10-13 15:26 ` 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=dmixw6ybhw2bqfejcpd5xq6i6o77heuunhnezy3nwrgraw2fce@e7xhnz24u6yn \
--to=jack@suse.cz \
--cc=Dai.Ngo@oracle.com \
--cc=alex.aring@gmail.com \
--cc=amir73il@gmail.com \
--cc=anna@kernel.org \
--cc=bharathsm@microsoft.com \
--cc=brauner@kernel.org \
--cc=cem@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=code@tyhicks.com \
--cc=dakr@kernel.org \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=ecryptfs@vger.kernel.org \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=horms@kernel.org \
--cc=jlayton@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=neil@brown.name \
--cc=netdev@vger.kernel.org \
--cc=netfs@lists.linux.dev \
--cc=okorniev@redhat.com \
--cc=pabeni@redhat.com \
--cc=pc@manguebit.org \
--cc=rafael@kernel.org \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=senozhatsky@chromium.org \
--cc=sfrench@samba.org \
--cc=smfrench@gmail.com \
--cc=sprasad@microsoft.com \
--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).