• Darrick J. Wong's avatar
    xfs: fix an inode lookup race in xchk_get_inode · 302436c2
    Darrick J. Wong authored
    In commit d658e, we tried to improve the robustnes of xchk_get_inode in
    the face of EINVAL returns from iget by calling xfs_imap to see if the
    inobt itself thinks that the inode is allocated.  Unfortunately, that
    commit didn't consider the possibility that the inode gets allocated
    after iget but before imap.  In this case, the imap call will succeed,
    but we turn that into a corruption error and tell userspace the inode is
    corrupt.
    
    Avoid this false corruption report by grabbing the AGI header and
    retrying the iget before calling imap.  If the iget succeeds, we can
    proceed with the usual scrub-by-handle code.  Fix all the incorrect
    comments too, since unreadable/corrupt inodes no longer result in EINVAL
    returns.
    
    Fixes: d658e72b ("xfs: distinguish between corrupt inode and invalid inum in xfs_scrub_get_inode")
    Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
    Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
    302436c2
xfs_icache.h 2.95 KB