On 03.12.20 15:59, Jan Beulich wrote: > On 01.12.2020 09:21, Juergen Gross wrote: >> In order to better support resource allocation and locking for dynamic >> hypfs nodes add enter() and exit() callbacks to struct hypfs_funcs. >> >> The enter() callback is called when entering a node during hypfs user >> actions (traversing, reading or writing it), while the exit() callback >> is called when leaving a node (accessing another node at the same or a >> higher directory level, or when returning to the user). >> >> For avoiding recursion this requires a parent pointer in each node. >> Let the enter() callback return the entry address which is stored as >> the last accessed node in order to be able to use a template entry for >> that purpose in case of dynamic entries. > > I guess I'll learn in subsequent patches why this is necessary / > useful. Right now it looks odd for the function to simple return > the incoming argument, as this way it's clear the caller knows > the correct value already. Basically for dynamic entries based on a template the entry function will return the address of template->e instead of the dynamic entry itself. This will enable to have the standard entry functions for any nodes being linked to the template. > >> @@ -100,11 +112,58 @@ static void hypfs_unlock(void) >> } >> } >> >> +const struct hypfs_entry *hypfs_node_enter(const struct hypfs_entry *entry) >> +{ >> + return entry; >> +} >> + >> +void hypfs_node_exit(const struct hypfs_entry *entry) >> +{ >> +} >> + >> +static int node_enter(const struct hypfs_entry *entry) >> +{ >> + const struct hypfs_entry **last = &this_cpu(hypfs_last_node_entered); >> + >> + entry = entry->funcs->enter(entry); >> + if ( IS_ERR(entry) ) >> + return PTR_ERR(entry); >> + >> + ASSERT(!*last || *last == entry->parent); >> + >> + *last = entry; >> + >> + return 0; >> +} >> + >> +static void node_exit(const struct hypfs_entry *entry) >> +{ >> + const struct hypfs_entry **last = &this_cpu(hypfs_last_node_entered); >> + >> + if ( !*last ) >> + return; > > Under what conditions is this legitimate to happen? IOW shouldn't > there be an ASSERT_UNREACHABLE() here? This is for the "/" node. Juergen