• Brian Foster's avatar
    xfs: release bli from transaction properly on fs shutdown · 6c0ecde2
    Brian Foster authored
    commit 79e641ce upstream.
    
    If a filesystem shutdown occurs with a buffer log item in the CIL
    and a log force occurs, the ->iop_unpin() handler is generally
    expected to tear down the bli properly. This entails freeing the bli
    memory and releasing the associated hold on the buffer so it can be
    released and the filesystem unmounted.
    
    If this sequence occurs while ->bli_refcount is elevated (i.e.,
    another transaction is open and attempting to modify the buffer),
    however, ->iop_unpin() may not be responsible for releasing the bli.
    Instead, the transaction may release the final ->bli_refcount
    reference and thus xfs_trans_brelse() is responsible for tearing
    down the bli.
    
    While xfs_trans_brelse() does drop the reference count, it only
    attempts to release the bli if it is clean (i.e., not in the
    CIL/AIL). If the filesystem is shutdown and the bli is sitting dirty
    in the CIL as noted above, this ends up skipping the last
    opportunity to release the bli. In turn, this leaves the hold on the
    buffer and causes an unmount hang. This can be reproduced by running
    generic/388 in repetition.
    
    Update xfs_trans_brelse() to handle this shutdown corner case
    correctly. If the final bli reference is dropped and the filesystem
    is shutdown, remove the bli from the AIL (if necessary) and release
    the bli to drop the buffer hold and ensure an unmount does not hang.
    Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarCarlos Maiolino <cmaiolino@redhat.com>
    Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    6c0ecde2
xfs_trans_buf.c 22.3 KB