• Brian Foster's avatar
    xfs: detect and trim torn writes during log recovery · 7088c413
    Brian Foster authored
    Certain types of storage, such as persistent memory, do not provide
    sector atomicity for writes. This means that if a crash occurs while XFS
    is writing log records, only part of those records might make it to the
    storage. This is problematic because log recovery uses the cycle value
    packed at the top of each log block to locate the head/tail of the log.
    This can lead to CRC verification failures during log recovery and an
    unmountable fs for a filesystem that is otherwise consistent.
    
    Update log recovery to incorporate log record CRC verification as part
    of the head/tail discovery process. Once the head is located via the
    traditional algorithm, run a CRC-only pass over the records up to the
    head of the log. If CRC verification fails, assume that the records are
    torn as a matter of policy and trim the head block back to the start of
    the first bad record.
    Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
    Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
    Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
    
    7088c413
xfs_log_recover.c 142 KB