• Darrick J. Wong's avatar
    xfs: introduce vectored scrub mode · c77b3758
    Darrick J. Wong authored
    Introduce a variant on XFS_SCRUB_METADATA that allows for a vectored
    mode.  The caller specifies the principal metadata object that they want
    to scrub (allocation group, inode, etc.) once, followed by an array of
    scrub types they want called on that object.  The kernel runs the scrub
    operations and writes the output flags and errno code to the
    corresponding array element.
    
    A new pseudo scrub type BARRIER is introduced to force the kernel to
    return to userspace if any corruptions have been found when scrubbing
    the previous scrub types in the array.  This enables userspace to
    schedule, for example, the sequence:
    
     1. data fork
     2. barrier
     3. directory
    
    If the data fork scrub is clean, then the kernel will perform the
    directory scrub.  If not, the barrier in 2 will exit back to userspace.
    
    The alternative would have been an interface where userspace passes a
    pointer to an empty buffer, and the kernel formats that with
    xfs_scrub_vecs that tell userspace what it scrubbed and what the outcome
    was.  With that the kernel would have to communicate that the buffer
    needed to have been at least X size, even though for our cases
    XFS_SCRUB_TYPE_NR + 2 would always be enough.
    
    Compared to that, this design keeps all the dependency policy and
    ordering logic in userspace where it already resides instead of
    duplicating it in the kernel. The downside of that is that it needs the
    barrier logic.
    
    When running fstests in "rebuild all metadata after each test" mode, I
    observed a 10% reduction in runtime due to fewer transitions across the
    system call boundary.
    Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    c77b3758
xfs_scrub.h 538 Bytes