Re: [PATCH v2 4/7] tracefs: dentry lookup crapectomy

From: Steven Rostedt
Date: Wed Jan 31 2024 - 22:22:25 EST


On Thu, 1 Feb 2024 03:02:05 +0000
Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:

> > We had a problem here with just returning NULL. It leaves the negative
> > dentry around and doesn't get refreshed.
>
> Why would that dentry stick around? And how would anyone find
> it, anyway, when it's not hashed?

We (Linus and I) got it wrong. It originally had:

d_add(dentry, NULL);
[..]
return NULL;

and it caused the:


# ls events/kprobes/sched/
ls: cannot access 'events/kprobes/sched/': No such file or directory

# echo 'p:sched schedule' >> /sys/kernel/tracing/kprobe_events
# ls events/kprobes/sched/
ls: cannot access 'events/kprobes/sched/': No such file or directory

I just changed the code to simply return NULL, and it had no issues:

# ls events/kprobes/sched/
ls: cannot access 'events/kprobes/sched/': No such file or directory

# echo 'p:sched schedule' >> /sys/kernel/tracing/kprobe_events
# ls events/kprobes/sched/
enable filter format hist hist_debug id inject trigger

But then I added the: d_add(dentry, NULL); that we originally had, and then
it caused the issue again.

So it wasn't the returning NULL that was causing a problem, it was calling
the d_add(dentry, NULL); that was.

I'll update the patch.

-- Steve