From: Al Viro <viro@zeniv.linux.org.uk>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org,
Andreas Hindborg <a.hindborg@kernel.org>,
Breno Leitao <leitao@debian.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Christian Brauner <brauner@kernel.org>
Subject: Re: [RFC PATCH 13/14] kill configfs_drop_dentry()
Date: Tue, 19 May 2026 16:37:24 +0100 [thread overview]
Message-ID: <20260519153724.GD2636677@ZenIV> (raw)
In-Reply-To: <ugllhpqcy62ludmg2wgc4dcsmm4z4m6pgpzdhcehkp7jvxnf4d@6mxgiskj5ct7>
On Tue, May 19, 2026 at 03:12:56PM +0200, Jan Kara wrote:
> Why is it safe to call dget_dlock() here? We hold only configfs_dirent_lock
> so cannot we race with somebody doing dget() on the 'child' dentry? Even if
> it is indeed safe for some reason I'm missing, it would deserve a comment I
> guess?
Because of the braindamage on conflict resolution. Thanks for spotting,
fixed and force-pushed. Updated version of commit:
commit 85863f5773c15f02ff6518ad034e3b380b78ca53
Author: Al Viro <viro@zeniv.linux.org.uk>
Date: Tue May 12 12:53:35 2026 -0400
kill configfs_drop_dentry()
Fold into the only remaining user, don't bother with the timestamps
of parent - we are going to rmdir it shortly anyway, which will
override those.
Fix the locking of inode, while we are at it - updating the link
count and timestamps ought to be done with the inode locked.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h
index 0b969d0eb8ff..acdeea8e2d69 100644
--- a/fs/configfs/configfs_internal.h
+++ b/fs/configfs/configfs_internal.h
@@ -76,7 +76,6 @@ extern int configfs_make_dirent(struct configfs_dirent *, struct dentry *,
extern int configfs_dirent_is_ready(struct configfs_dirent *);
extern const unsigned char * configfs_get_name(struct configfs_dirent *sd);
-extern void configfs_drop_dentry(struct configfs_dirent *sd, struct dentry *parent);
extern int configfs_setattr(struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *iattr);
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 740ea2c115bd..a68b4a9241c0 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -562,12 +562,33 @@ static void detach_attrs(struct dentry *dentry)
parent_sd = dentry->d_fsdata;
list_for_each_entry_safe(sd, tmp, &parent_sd->s_children, s_sibling) {
+ struct dentry *child;
if (!sd->s_element || !(sd->s_type & CONFIGFS_NOT_PINNED))
continue;
spin_lock(&configfs_dirent_lock);
list_del_init(&sd->s_sibling);
+ child = sd->s_dentry;
+ if (child) {
+ spin_lock(&child->d_lock);
+ if (simple_positive(child)) {
+ dget_dlock(child);
+ spin_unlock(&child->d_lock);
+ } else {
+ spin_unlock(&child->d_lock);
+ child = NULL;
+ }
+ }
spin_unlock(&configfs_dirent_lock);
- configfs_drop_dentry(sd, dentry);
+ if (child) {
+ struct inode *inode = child->d_inode;
+ d_drop(child);
+
+ inode_lock_nested(inode, I_MUTEX_NONDIR2);
+ inode_set_ctime_current(inode);
+ drop_nlink(inode);
+ inode_unlock(inode);
+ dput(child);
+ }
configfs_put(sd);
}
}
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index bc507b720a01..3c26b6c443be 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -195,25 +195,3 @@ const unsigned char * configfs_get_name(struct configfs_dirent *sd)
}
return NULL;
}
-
-
-/*
- * Unhashes the dentry corresponding to given configfs_dirent
- * Called with parent inode's i_mutex held.
- */
-void configfs_drop_dentry(struct configfs_dirent * sd, struct dentry * parent)
-{
- struct dentry * dentry = sd->s_dentry;
-
- if (dentry) {
- spin_lock(&dentry->d_lock);
- if (simple_positive(dentry)) {
- dget_dlock(dentry);
- __d_drop(dentry);
- spin_unlock(&dentry->d_lock);
- __simple_unlink(d_inode(parent), dentry);
- dput(dentry);
- } else
- spin_unlock(&dentry->d_lock);
- }
-}
next prev parent reply other threads:[~2026-05-19 15:37 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 7:06 [RFC PATCH 00/14] configfs cleanups and fixes Al Viro
2026-05-19 7:06 ` [RFC PATCH 01/14] configfs_lookup(): don't leave ->s_dentry dangling on failure Al Viro
2026-05-19 9:57 ` Jan Kara
2026-05-21 16:38 ` Breno Leitao
2026-05-19 7:06 ` [RFC PATCH 02/14] configfs_mkdir(): use take_dentry_name_snapshot() Al Viro
2026-05-19 9:59 ` Jan Kara
2026-05-21 16:54 ` Breno Leitao
2026-05-19 7:06 ` [RFC PATCH 03/14] configfs_detach_prep(): pass configfs_dirent instead of dentry Al Viro
2026-05-19 10:12 ` Jan Kara
2026-05-21 17:03 ` Breno Leitao
2026-05-19 7:06 ` [RFC PATCH 04/14] configfs_depend_prep(): " Al Viro
2026-05-19 10:18 ` Jan Kara
2026-05-19 7:06 ` [RFC PATCH 05/14] configfs_do_depend_item(): " Al Viro
2026-05-19 10:25 ` Jan Kara
2026-05-19 7:06 ` [RFC PATCH 06/14] configfs_detach_rollback(): " Al Viro
2026-05-19 10:26 ` Jan Kara
2026-05-19 7:06 ` [RFC PATCH 07/14] populate_group(): move cleanup on failure to the sole caller Al Viro
2026-05-19 10:29 ` Jan Kara
2026-05-19 7:06 ` [RFC PATCH 08/14] populate_attrs(): move cleanup " Al Viro
2026-05-19 10:31 ` Jan Kara
2026-05-19 7:06 ` [RFC PATCH 09/14] configfs_remove_dir(), detach_attrs(): switch to passing dentry Al Viro
2026-05-19 10:42 ` Jan Kara
2026-05-19 7:06 ` [RFC PATCH 10/14] switch configfs_detach_{group,item}() " Al Viro
2026-05-19 12:10 ` Jan Kara
2026-05-19 7:06 ` [RFC PATCH 11/14] configfs: dentry refcount needs to be pinned only once Al Viro
2026-05-19 13:21 ` Jan Kara
2026-05-19 7:06 ` [RFC PATCH 12/14] configfs: mark pinned dentries persistent Al Viro
2026-05-19 13:03 ` Jan Kara
2026-05-19 7:06 ` [RFC PATCH 13/14] kill configfs_drop_dentry() Al Viro
2026-05-19 13:12 ` Jan Kara
2026-05-19 14:44 ` Linus Torvalds
2026-05-19 15:37 ` Al Viro [this message]
2026-05-19 21:06 ` Jan Kara
2026-05-19 7:06 ` [RFC PATCH 14/14] configfs_create(): lift parent timestamp updates into callers Al Viro
2026-05-19 13:23 ` Jan Kara
2026-06-03 7:47 ` [PATCH v2 00/18] configfs cleanups and fixes Al Viro
2026-06-03 7:47 ` [PATCH v2 01/18] configfs_lookup(): don't leave ->s_dentry dangling on failure Al Viro
2026-06-03 7:47 ` [PATCH v2 1/3] get rid of impossible checks in detach_attrs()/configfs_detach_item() Al Viro
2026-06-03 7:53 ` Al Viro
2026-06-03 8:09 ` Christian Brauner
2026-06-03 8:28 ` Al Viro
2026-06-03 7:47 ` [PATCH v2 2/3] configfs_detach_item(): victim is never negative Al Viro
2026-06-03 7:47 ` [PATCH v2 02/18] configfs: fix lockless traversals of ->s_children Al Viro
2026-06-03 7:47 ` [PATCH v2 3/3] configfs: expand the call of simple_rmdir() Al Viro
2026-06-03 7:48 ` [PATCH v2 03/18] configfs_mkdir(): use take_dentry_name_snapshot() Al Viro
2026-06-03 7:48 ` [PATCH v2 04/18] configfs_detach_prep(): pass configfs_dirent instead of dentry Al Viro
2026-06-03 7:48 ` [PATCH v2 05/18] configfs_depend_prep(): " Al Viro
2026-06-03 7:48 ` [PATCH v2 06/18] configfs_do_depend_item(): " Al Viro
2026-06-03 7:48 ` [PATCH v2 07/18] configfs_detach_rollback(): " Al Viro
2026-06-03 7:48 ` [PATCH v2 08/18] populate_group(): move cleanup on failure to the sole caller Al Viro
2026-06-03 7:48 ` [PATCH v2 09/18] populate_attrs(): move cleanup " Al Viro
2026-06-03 7:48 ` [PATCH v2 10/18] configfs_remove_dir(), detach_attrs(): switch to passing dentry Al Viro
2026-06-03 7:48 ` [PATCH v2 11/18] switch configfs_detach_{group,item}() " Al Viro
2026-06-03 7:48 ` [PATCH v2 12/18] configfs: dentry refcount needs to be pinned only once Al Viro
2026-06-03 7:48 ` [PATCH v2 13/18] configfs: mark pinned dentries persistent Al Viro
2026-06-03 7:48 ` [PATCH v2 14/18] kill configfs_drop_dentry() Al Viro
2026-06-03 7:48 ` [PATCH v2 15/18] configfs_create(): lift parent timestamp updates into callers Al Viro
2026-06-03 7:48 ` [PATCH v2 16/18] configs_attach_item(): drop unused parent_item argument Al Viro
2026-06-03 7:48 ` [PATCH v2 17/18] configfs_attach_group(): drop the " Al Viro
2026-06-03 7:48 ` [PATCH v2 18/18] create_default_group(): pass parent's dentry instead of config_group Al Viro
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=20260519153724.GD2636677@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=a.hindborg@kernel.org \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=leitao@debian.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.