• A
    namei: stash the sampled ->d_seq into nameidata · 03fa86e9
    Al Viro 提交于
    New field: nd->next_seq.  Set to 0 outside of RCU mode, holds the sampled
    value for the next dentry to be considered.  Used instead of an arseload
    of local variables, arguments, etc.
    
    step_into() has lost seq argument; nd->next_seq is used, so dentry passed
    to it must be the one ->next_seq is about.
    
    There are two requirements for RCU pathwalk:
    	1) it should not give a hard failure (other than -ECHILD) unless
    non-RCU pathwalk might fail that way given suitable timings.
    	2) it should not succeed unless non-RCU pathwalk might succeed
    with the same end location given suitable timings.
    
    The use of seq numbers is the way we achieve that.  Invariant we want
    to maintain is:
    	if RCU pathwalk can reach the state with given nd->path, nd->inode
    and nd->seq after having traversed some part of pathname, it must be possible
    for non-RCU pathwalk to reach the same nd->path and nd->inode after having
    traversed the same part of pathname, and observe the nd->path.dentry->d_seq
    equal to what RCU pathwalk has in nd->seq
    
    	For transition from parent to child, we sample child's ->d_seq
    and verify that parent's ->d_seq remains unchanged.  Anything that
    disrupts parent-child relationship would've bumped ->d_seq on both.
    	For transitions from child to parent we sample parent's ->d_seq
    and verify that child's ->d_seq has not changed.  Same reasoning as
    for the previous case applies.
    	For transition from mountpoint to root of mounted we sample
    the ->d_seq of root and verify that nobody has touched mount_lock since
    the beginning of pathwalk.  That guarantees that mount we'd found had
    been there all along, with these mountpoint and root of the mounted.
    It would be possible for a non-RCU pathwalk to reach the previous state,
    find the same mount and observe its root at the moment we'd sampled
    ->d_seq of that
    	For transitions from root of mounted to mountpoint we sample
    ->d_seq of mountpoint and verify that mount_lock had not been touched
    since the beginning of pathwalk.  The same reasoning as in the
    previous case applies.
    Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
    03fa86e9
namei.c 135.2 KB