• Darrick J. Wong's avatar
    xfs: use dontcache for grabbing inodes during scrub · b27ce0da
    Darrick J. Wong authored
    Back when I wrote commit a03297a0, I had thought that we'd be doing
    users a favor by only marking inodes dontcache at the end of a scrub
    operation, and only if there's only one reference to that inode.  This
    was more or less true back when I_DONTCACHE was an XFS iflag and the
    only thing it did was change the outcome of xfs_fs_drop_inode to 1.
    
    Note: If there are dentries pointing to the inode when scrub finishes,
    the inode will have positive i_count and stay around in cache until
    dentry reclaim.
    
    But now we have d_mark_dontcache, which cause the inode *and* the
    dentries attached to it all to be marked I_DONTCACHE, which means that
    we drop the dentries ASAP, which drops the inode ASAP.
    
    This is bad if scrub found problems with the inode, because now they can
    be scheduled for inactivation, which can cause inodegc to trip on it and
    shut down the filesystem.
    
    Even if the inode isn't bad, this is still suboptimal because phases 3-7
    each initiate inode scans.  Dropping the inode immediately during phase
    3 is silly because phase 5 will reload it and drop it immediately, etc.
    It's fine to mark the inodes dontcache, but if there have been accesses
    to the file that set up dentries, we should keep them.
    
    I validated this by setting up ftrace to capture xfs_iget_recycle*
    tracepoints and ran xfs/285 for 30 seconds.  With current djwong-wtf I
    saw ~30,000 recycle events.  I then dropped the d_mark_dontcache calls
    and set XFS_IGET_DONTCACHE, and the recycle events dropped to ~5,000 per
    30 seconds.
    
    Therefore, grab the inode with XFS_IGET_DONTCACHE, which only has the
    effect of setting I_DONTCACHE for cache misses.  Remove the
    d_mark_dontcache call that can happen in xchk_irele.
    
    Fixes: a03297a0 ("xfs: manage inode DONTCACHE status at irele time")
    Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    b27ce0da
common.c 36.1 KB