Skip to content

Commit 8dce06e

Browse files
torvaldsrostedt
authored andcommitted
eventfs: Clean up dentry ops and add revalidate function
In order for the dentries to stay up-to-date with the eventfs changes, just add a 'd_revalidate' function that checks the 'is_freed' bit. Also, clean up the dentry release to actually use d_release() rather than the slightly odd d_iput() function. We don't care about the inode, all we want to do is to get rid of the refcount to the eventfs data added by dentry->d_fsdata. It would probably be cleaner to make eventfs its own filesystem, or at least set its own dentry ops when looking up eventfs files. But as it is, only eventfs dentries use d_fsdata, so we don't really need to split these things up by use. Another thing that might be worth doing is to make all eventfs lookups mark their dentries as not worth caching. We could do that with d_delete(), but the DCACHE_DONTCACHE flag would likely be even better. As it is, the dentries are all freeable, but they only tend to get freed at memory pressure rather than more proactively. But that's a separate issue. Link: https://lore.kernel.org/linux-trace-kernel/[email protected]/ Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Cc: [email protected] Cc: Masami Hiramatsu <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Al Viro <[email protected]> Cc: Ajay Kaher <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Fixes: c1504e5 ("eventfs: Implement eventfs dir creation functions") Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 408600b commit 8dce06e

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

fs/tracefs/event_inode.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,12 @@ static void free_ei(struct eventfs_inode *ei)
378378
}
379379

380380
/**
381-
* eventfs_set_ei_status_free - remove the dentry reference from an eventfs_inode
382-
* @ti: the tracefs_inode of the dentry
381+
* eventfs_d_release - dentry is going away
383382
* @dentry: dentry which has the reference to remove.
384383
*
385384
* Remove the association between a dentry from an eventfs_inode.
386385
*/
387-
void eventfs_set_ei_status_free(struct tracefs_inode *ti, struct dentry *dentry)
386+
void eventfs_d_release(struct dentry *dentry)
388387
{
389388
struct eventfs_inode *ei;
390389
int i;

fs/tracefs/inode.c

+18-9
Original file line numberDiff line numberDiff line change
@@ -377,21 +377,30 @@ static const struct super_operations tracefs_super_operations = {
377377
.show_options = tracefs_show_options,
378378
};
379379

380-
static void tracefs_dentry_iput(struct dentry *dentry, struct inode *inode)
380+
/*
381+
* It would be cleaner if eventfs had its own dentry ops.
382+
*
383+
* Note that d_revalidate is called potentially under RCU,
384+
* so it can't take the eventfs mutex etc. It's fine - if
385+
* we open a file just as it's marked dead, things will
386+
* still work just fine, and just see the old stale case.
387+
*/
388+
static void tracefs_d_release(struct dentry *dentry)
381389
{
382-
struct tracefs_inode *ti;
390+
if (dentry->d_fsdata)
391+
eventfs_d_release(dentry);
392+
}
383393

384-
if (!dentry || !inode)
385-
return;
394+
static int tracefs_d_revalidate(struct dentry *dentry, unsigned int flags)
395+
{
396+
struct eventfs_inode *ei = dentry->d_fsdata;
386397

387-
ti = get_tracefs(inode);
388-
if (ti && ti->flags & TRACEFS_EVENT_INODE)
389-
eventfs_set_ei_status_free(ti, dentry);
390-
iput(inode);
398+
return !(ei && ei->is_freed);
391399
}
392400

393401
static const struct dentry_operations tracefs_dentry_operations = {
394-
.d_iput = tracefs_dentry_iput,
402+
.d_revalidate = tracefs_d_revalidate,
403+
.d_release = tracefs_d_release,
395404
};
396405

397406
static int trace_fill_super(struct super_block *sb, void *data, int silent)

fs/tracefs/internal.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct dentry *tracefs_start_creating(const char *name, struct dentry *parent);
7878
struct dentry *tracefs_end_creating(struct dentry *dentry);
7979
struct dentry *tracefs_failed_creating(struct dentry *dentry);
8080
struct inode *tracefs_get_inode(struct super_block *sb);
81-
void eventfs_set_ei_status_free(struct tracefs_inode *ti, struct dentry *dentry);
81+
82+
void eventfs_d_release(struct dentry *dentry);
8283

8384
#endif /* _TRACEFS_INTERNAL_H */

0 commit comments

Comments
 (0)