convert tracefs

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>
This commit is contained in:
Al Viro 2024-05-08 23:51:40 -04:00
parent eec876df5e
commit 50d7fd3c3a
2 changed files with 8 additions and 9 deletions

View 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 * something not worth much. Keeping directory links at 1
* tells userspace not to trust the link number. * 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 */ /* The dentry of the "events" parent does keep track though */
inc_nlink(dentry->d_parent->d_inode); inc_nlink(dentry->d_parent->d_inode);
fsnotify_mkdir(dentry->d_parent->d_inode, dentry); fsnotify_mkdir(dentry->d_parent->d_inode, dentry);
@ -910,5 +910,5 @@ void eventfs_remove_events_dir(struct eventfs_inode *ei)
* and destroyed dynamically. * and destroyed dynamically.
*/ */
d_invalidate(dentry); d_invalidate(dentry);
dput(dentry); d_make_discardable(dentry);
} }

View File

@ -538,7 +538,7 @@ static struct file_system_type trace_fs_type = {
.name = "tracefs", .name = "tracefs",
.init_fs_context = tracefs_init_fs_context, .init_fs_context = tracefs_init_fs_context,
.parameters = tracefs_param_specs, .parameters = tracefs_param_specs,
.kill_sb = kill_litter_super, .kill_sb = kill_anon_super,
}; };
MODULE_ALIAS_FS("tracefs"); 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) struct dentry *tracefs_failed_creating(struct dentry *dentry)
{ {
inode_unlock(d_inode(dentry->d_parent)); simple_done_creating(dentry);
dput(dentry);
simple_release_fs(&tracefs_mount, &tracefs_mount_count); simple_release_fs(&tracefs_mount, &tracefs_mount_count);
return NULL; return NULL;
} }
struct dentry *tracefs_end_creating(struct dentry *dentry) struct dentry *tracefs_end_creating(struct dentry *dentry)
{ {
inode_unlock(d_inode(dentry->d_parent)); simple_done_creating(dentry);
return dentry; return dentry; // borrowed
} }
/* Find the inode that this will use for default */ /* 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_private = data;
inode->i_uid = d_inode(dentry->d_parent)->i_uid; inode->i_uid = d_inode(dentry->d_parent)->i_uid;
inode->i_gid = d_inode(dentry->d_parent)->i_gid; 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); fsnotify_create(d_inode(dentry->d_parent), dentry);
return tracefs_end_creating(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) */ /* directory inodes start off with i_nlink == 2 (for "." entry) */
inc_nlink(inode); inc_nlink(inode);
d_instantiate(dentry, inode); d_make_persistent(dentry, inode);
inc_nlink(d_inode(dentry->d_parent)); inc_nlink(d_inode(dentry->d_parent));
fsnotify_mkdir(d_inode(dentry->d_parent), dentry); fsnotify_mkdir(d_inode(dentry->d_parent), dentry);
return tracefs_end_creating(dentry); return tracefs_end_creating(dentry);