• Al Viro's avatar
    pick_link(): pass it struct path already with normal refcounting rules · 84f0cd9e
    Al Viro authored
    step_into() tries to avoid grabbing and dropping mount references
    on the steps that do not involve crossing mountpoints (which is
    obviously the majority of cases).  So it uses a local struct path
    with unusual refcounting rules - path.mnt is pinned if and only if
    it's not equal to nd->path.mnt.
    
    We used to have similar beasts all over the place and we had quite
    a few bugs crop up in their handling - it's easy to get confused
    when changing e.g. cleanup on failure exits (or adding a new check,
    etc.)
    
    Now that's mostly gone - the step_into() instance (which is what
    we need them for) is the only one left.  It is exposed to mount
    traversal and it's (shortly) seen by pick_link().  Since pick_link()
    needs to store it in link stack, where the normal rules apply,
    it has to make sure that mount is pinned regardless of nd->path.mnt
    value.  That's done on all calls of pick_link() and very early
    in those.  Let's do that in the caller (step_into()) instead -
    that way the fewer places need to be aware of such struct path
    instances.
    Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
    84f0cd9e
namei.c 121 KB