From: Al Viro Date: Tue, 12 May 2026 16:53:35 +0000 (-0400) Subject: kill configfs_drop_dentry() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43b45755e80e5eee9d3f6271d301940af7dbc29b;p=thirdparty%2Fkernel%2Flinux.git 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. Reviewed-by: Jan Kara Signed-off-by: Al Viro --- diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h index 0b969d0eb8ff9..acdeea8e2d69a 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 479d37b8d806a..4a4bad1741cfe 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -581,12 +581,34 @@ static void detach_attrs(struct dentry *dentry) spin_lock(&configfs_dirent_lock); for (sd = next_dirent(parent_sd, NULL); sd; sd = next) { + struct dentry *child; + next = next_dirent(parent_sd, sd); if (!(sd->s_type & CONFIGFS_NOT_PINNED)) continue; list_del_init(&sd->s_sibling); + child = sd->s_dentry; + if (child) { + spin_lock(&child->d_lock); + if (simple_positive(child)) { + dget_dlock(child); + __d_drop(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; + + inode_lock_nested(inode, I_MUTEX_NONDIR2); + inode_set_ctime_current(inode); + drop_nlink(inode); + inode_unlock(inode); + dput(child); + } configfs_put(sd); spin_lock(&configfs_dirent_lock); } diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c index bc507b720a01d..3c26b6c443be9 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); - } -}