• Dave Chinner's avatar
    xfs: xfs_log_force_lsn isn't passed a LSN · 5f9b4b0d
    Dave Chinner authored
    In doing an investigation into AIL push stalls, I was looking at the
    log force code to see if an async CIL push could be done instead.
    This lead me to xfs_log_force_lsn() and looking at how it works.
    
    xfs_log_force_lsn() is only called from inode synchronisation
    contexts such as fsync(), and it takes the ip->i_itemp->ili_last_lsn
    value as the LSN to sync the log to. This gets passed to
    xlog_cil_force_lsn() via xfs_log_force_lsn() to flush the CIL to the
    journal, and then used by xfs_log_force_lsn() to flush the iclogs to
    the journal.
    
    The problem is that ip->i_itemp->ili_last_lsn does not store a
    log sequence number. What it stores is passed to it from the
    ->iop_committing method, which is called by xfs_log_commit_cil().
    The value this passes to the iop_committing method is the CIL
    context sequence number that the item was committed to.
    
    As it turns out, xlog_cil_force_lsn() converts the sequence to an
    actual commit LSN for the related context and returns that to
    xfs_log_force_lsn(). xfs_log_force_lsn() overwrites it's "lsn"
    variable that contained a sequence with an actual LSN and then uses
    that to sync the iclogs.
    
    This caused me some confusion for a while, even though I originally
    wrote all this code a decade ago. ->iop_committing is only used by
    a couple of log item types, and only inode items use the sequence
    number it is passed.
    
    Let's clean up the API, CIL structures and inode log item to call it
    a sequence number, and make it clear that the high level code is
    using CIL sequence numbers and not on-disk LSNs for integrity
    synchronisation purposes.
    Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
    Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
    Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
    Reviewed-by: default avatarAllison Henderson <allison.henderson@oracle.com>
    Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
    5f9b4b0d
xfs_log_cil.c 39.9 KB