]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
convert tracefs
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 9 May 2024 03:51:40 +0000 (23:51 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 16 Nov 2025 06:35:03 +0000 (01:35 -0500)
A mix of persistent and non-persistent dentries in there.  Strictly
speaking, no need for kill_litter_super() anyway - it pins an internal
mount whenever a persistent dentry is created, so at fs shutdown time
there won't be any to deal with.

However, let's make it explicit - replace d_instantiate() with
d_make_persistent() + dput() (the latter in tracefs_end_creating(),
where it folds with inode_unlock() into simple_done_creating())
for dentries we want persistent and have d_make_discardable() done
either by simple_recursive_removal() (used by tracefs_remove())
or explicitly in eventfs_remove_events_dir().

Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/tracefs/event_inode.c
fs/tracefs/inode.c

index 93c231601c8e23cb891e6b039d3d5b13013b3951..61cbdafa2411a657ea3fae63600bb7339e4415aa 100644 (file)
@@ -823,7 +823,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
         * something not worth much. Keeping directory links at 1
         * tells userspace not to trust the link number.
         */
-       d_instantiate(dentry, inode);
+       d_make_persistent(dentry, inode);
        /* The dentry of the "events" parent does keep track though */
        inc_nlink(dentry->d_parent->d_inode);
        fsnotify_mkdir(dentry->d_parent->d_inode, dentry);
@@ -910,5 +910,5 @@ void eventfs_remove_events_dir(struct eventfs_inode *ei)
         * and destroyed dynamically.
         */
        d_invalidate(dentry);
-       dput(dentry);
+       d_make_discardable(dentry);
 }
index 0c023941a316fa747131694599f1aa6e9281ec07..d9d8932a7b9c9718f9fb0a72072f324056074ffe 100644 (file)
@@ -538,7 +538,7 @@ static struct file_system_type trace_fs_type = {
        .name =         "tracefs",
        .init_fs_context = tracefs_init_fs_context,
        .parameters     = tracefs_param_specs,
-       .kill_sb =      kill_litter_super,
+       .kill_sb =      kill_anon_super,
 };
 MODULE_ALIAS_FS("tracefs");
 
@@ -571,16 +571,15 @@ struct dentry *tracefs_start_creating(const char *name, struct dentry *parent)
 
 struct dentry *tracefs_failed_creating(struct dentry *dentry)
 {
-       inode_unlock(d_inode(dentry->d_parent));
-       dput(dentry);
+       simple_done_creating(dentry);
        simple_release_fs(&tracefs_mount, &tracefs_mount_count);
        return NULL;
 }
 
 struct dentry *tracefs_end_creating(struct dentry *dentry)
 {
-       inode_unlock(d_inode(dentry->d_parent));
-       return dentry;
+       simple_done_creating(dentry);
+       return dentry;  // borrowed
 }
 
 /* Find the inode that this will use for default */
@@ -661,7 +660,7 @@ struct dentry *tracefs_create_file(const char *name, umode_t mode,
        inode->i_private = data;
        inode->i_uid = d_inode(dentry->d_parent)->i_uid;
        inode->i_gid = d_inode(dentry->d_parent)->i_gid;
-       d_instantiate(dentry, inode);
+       d_make_persistent(dentry, inode);
        fsnotify_create(d_inode(dentry->d_parent), dentry);
        return tracefs_end_creating(dentry);
 }
@@ -692,7 +691,7 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent,
 
        /* directory inodes start off with i_nlink == 2 (for "." entry) */
        inc_nlink(inode);
-       d_instantiate(dentry, inode);
+       d_make_persistent(dentry, inode);
        inc_nlink(d_inode(dentry->d_parent));
        fsnotify_mkdir(d_inode(dentry->d_parent), dentry);
        return tracefs_end_creating(dentry);