Hello, On Tue, Aug 23, 2022 at 01:49:07PM +0800, Chengming Zhou wrote: > > - if (pos->flags & KERNFS_ACTIVATED) > > + if (kernfs_active(pos) || (kn->flags & KERNFS_REMOVING)) > > May I ask a question, what's the difference between kernfs_active() and KERNFS_ACTIVATED? > > KERNFS_ACTIVATED is always set when kernfs_activate() and never clear, so I think it means: > > 1. !KERNFS_ACTIVATED : allocated but not activated > 2. KERNFS_ACTIVATED && !kernfs_active() : make deactivated by kernfs_deactivate_locked() > > I see most code check kernfs_active(), but two places check KERNFS_ACTIVATED, I'm not sure where > should check KERNFS_ACTIVATED, or is there any chance we can remove KERNFS_ACTIVATED? Yeah, ACTIVATED means taht created but never activated while kernfs_active() means currently active. I tried to substitute all ACTIVATED tests with kernfs_active() and remove the former but I wasn't sure about changing kernfs_add_one() behavior. I think it's too confusing to combine the initial activated state with user-requested show/hide state and causes other problems like kernfs_activate() used to activate newly created files unhiding files explicitly deactivated. Lemme separate out show/hide state into something separate so that the distinction is clear. Thanks. -- tejun