• Darrick J. Wong's avatar
    xfs: implement live inode scan for scrub · 8660c7b7
    Darrick J. Wong authored
    This patch implements a live file scanner for online fsck functions that
    require the ability to walk a filesystem to gather metadata records and
    stay informed about metadata changes to files that have already been
    visited.
    
    The iscan structure consists of two inode number cursors: one to track
    which inode we want to visit next, and a second one to track which
    inodes have already been visited.  This second cursor is key to
    capturing live updates to files previously scanned while the main thread
    continues scanning -- any inode greater than this value hasn't been
    scanned and can go on its way; any other update must be incorporated
    into the collected data.  It is critical for the scanning thraad to hold
    exclusive access on the inode until after marking the inode visited.
    
    This new code is a separate patch from the patchsets adding callers for
    the sake of enabling the author to move patches around his tree with
    ease.  The intended usage model for this code is roughly:
    
    	xchk_iscan_start(iscan, 0, 0);
    	while ((error = xchk_iscan_iter(sc, iscan, &ip)) == 1) {
    		xfs_ilock(ip, ...);
    		/* capture inode metadata */
    		xchk_iscan_mark_visited(iscan, ip);
    		xfs_iunlock(ip, ...);
    
    		xfs_irele(ip);
    	}
    	xchk_iscan_stop(iscan);
    	if (error)
    		return error;
    
    Hook functions for live updates can then do:
    
    	if (xchk_iscan_want_live_update(...))
    		/* update the captured inode metadata */
    Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    8660c7b7
Makefile 4.58 KB