]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
configfs: mark pinned dentries persistent
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 12 May 2026 16:18:21 +0000 (12:18 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 8 Jun 2026 18:53:09 +0000 (14:53 -0400)
on the removal side we can (finally) get rid of __simple_unlink()
and __simple_rmdir() kludges now that dentries in question are
properly marked persistent - simple_unlink() and simple_rmdir()
will do the right thing for those.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/configfs/dir.c
fs/configfs/symlink.c

index 4836ffb3b70f784420b98f8afdb84986784df84f..479d37b8d806a5ce6993bf94a170368c689f5deb 100644 (file)
@@ -315,9 +315,7 @@ static int configfs_create_dir(struct config_item *item, struct dentry *dentry,
        inode->i_fop = &configfs_dir_operations;
        /* directory inodes start off with i_nlink == 2 (for "." entry) */
        inc_nlink(inode);
-       d_instantiate(dentry, inode);
-       /* already hashed */
-       dget(dentry);  /* pin directory dentries in core */
+       d_make_persistent(dentry, inode);
        inc_nlink(d_inode(p));
        item->ci_dentry = dentry;
        return 0;
@@ -385,8 +383,7 @@ int configfs_create_link(struct configfs_dirent *target, struct dentry *parent,
 
        inode->i_link = body;
        inode->i_op = &configfs_symlink_inode_operations;
-       d_instantiate(dentry, inode);
-       dget(dentry);  /* pin link dentries in core */
+       d_make_persistent(dentry, inode);
        return 0;
 
 out_remove:
@@ -413,12 +410,8 @@ static void configfs_remove_dir(struct dentry *d)
        configfs_remove_dirent(d);
 
        if (d_really_is_positive(d)) {
-               if (likely(simple_empty(d))) {
-                       __simple_rmdir(d_inode(parent),d);
-                       dput(d);
-               } else {
+               if (unlikely(simple_rmdir(d_inode(parent), d)))
                        pr_warn("remove_dir (%pd): attributes remain", d);
-               }
        }
 
        pr_debug(" o %pd removing done (%d)\n", d, d_count(d));
index f3f79c67add5df5f5b628fa77311cd723fb34eac..31eb28b2730913efe2fb335023259b7d4f5b3c7a 100644 (file)
@@ -229,9 +229,8 @@ int configfs_unlink(struct inode *dir, struct dentry *dentry)
        spin_lock(&configfs_dirent_lock);
        list_del_init(&sd->s_sibling);
        spin_unlock(&configfs_dirent_lock);
-       configfs_drop_dentry(sd, dentry->d_parent);
-       dput(dentry);
        configfs_put(sd);
+       simple_unlink(dir, dentry);
 
        /*
         * drop_link() must be called before