• B
    xfs: sync lazy sb accounting on quiesce of read-only mounts · 50d25484
    Brian Foster 提交于
    xfs_log_sbcount() syncs the superblock specifically to accumulate
    the in-core percpu superblock counters and commit them to disk. This
    is required to maintain filesystem consistency across quiesce
    (freeze, read-only mount/remount) or unmount when lazy superblock
    accounting is enabled because individual transactions do not update
    the superblock directly.
    
    This mechanism works as expected for writable mounts, but
    xfs_log_sbcount() skips the update for read-only mounts. Read-only
    mounts otherwise still allow log recovery and write out an unmount
    record during log quiesce. If a read-only mount performs log
    recovery, it can modify the in-core superblock counters and write an
    unmount record when the filesystem unmounts without ever syncing the
    in-core counters. This leaves the filesystem with a clean log but in
    an inconsistent state with regard to lazy sb counters.
    
    Update xfs_log_sbcount() to use the same logic
    xfs_log_unmount_write() uses to determine when to write an unmount
    record. This ensures that lazy accounting is always synced before
    the log is cleaned. Refactor this logic into a new helper to
    distinguish between a writable filesystem and a writable log.
    Specifically, the log is writable unless the filesystem is mounted
    with the norecovery mount option, the underlying log device is
    read-only, or the filesystem is shutdown. Drop the freeze state
    check because the update is already allowed during the freezing
    process and no context calls this function on an already frozen fs.
    Also, retain the shutdown check in xfs_log_unmount_write() to catch
    the case where the preceding log force might have triggered a
    shutdown.
    Signed-off-by: NBrian Foster <bfoster@redhat.com>
    Reviewed-by: NGao Xiang <hsiangkao@redhat.com>
    Reviewed-by: NAllison Henderson <allison.henderson@oracle.com>
    Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: NBill O'Donnell <billodo@redhat.com>
    Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
    Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
    50d25484
xfs_log.c 105.9 KB