• Darrick J. Wong's avatar
    xfs: fix an ABBA deadlock in xfs_rename · 6da1b4b1
    Darrick J. Wong authored
    When overlayfs is running on top of xfs and the user unlinks a file in
    the overlay, overlayfs will create a whiteout inode and ask xfs to
    "rename" the whiteout file atop the one being unlinked.  If the file
    being unlinked loses its one nlink, we then have to put the inode on the
    unlinked list.
    
    This requires us to grab the AGI buffer of the whiteout inode to take it
    off the unlinked list (which is where whiteouts are created) and to grab
    the AGI buffer of the file being deleted.  If the whiteout was created
    in a higher numbered AG than the file being deleted, we'll lock the AGIs
    in the wrong order and deadlock.
    
    Therefore, grab all the AGI locks we think we'll need ahead of time, and
    in order of increasing AG number per the locking rules.
    Reported-by: default avatarwenli xie <wlxie7296@gmail.com>
    Fixes: 93597ae8 ("xfs: Fix deadlock between AGI and AGF when target_ip exists in xfs_rename()")
    Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
    6da1b4b1
xfs_dir2.h 7.33 KB