• Darrick J. Wong's avatar
    xfs: fix parent pointer scrub racing with subdirectory reparenting · 0916056e
    Darrick J. Wong authored
    Jan Kara pointed out that rename() doesn't lock a subdirectory that is
    being moved from one parent to another, even though the move requires an
    update to the subdirectory's dotdot entry.  This means that it's *not*
    sufficient to hold a directory's IOLOCK to stabilize the dotdot entry.
    We must hold the ILOCK of both the child and the alleged parent, and
    there's no use in holding the parent's IOLOCK.
    
    With that in mind, we can get rid of all the messy code that tries to
    grab the parent's IOLOCK, which means we don't need to let go of the
    ILOCK of the directory whose parent we are checking.  We still have to
    use nonblocking mode to take the ILOCK of the alleged parent, so the
    revalidation loop has to stay.
    
    However, we can remove the retry counter, since threads aren't supposed
    to hold the ILOCK for long periods of time.  Remove the inverted ilock
    helper from the common code since nobody uses it.  Remove the entire
    source of -EDEADLOCK-based "retry harder" scrub executions.
    
    Link: https://lore.kernel.org/linux-xfs/20230117123735.un7wbamlbdihninm@quack3/Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
    Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
    0916056e
parent.c 5.67 KB