• Brian Foster's avatar
    xfs: free uncommitted transactions during log recovery · 39775431
    Brian Foster authored
    Log recovery allocates in-core transaction and member item data
    structures on-demand as it processes the on-disk log. Transactions
    are allocated on first encounter on-disk and stored in a hash table
    structure where they are easily accessible for subsequent lookups.
    Transaction items are also allocated on demand and are attached to
    the associated transactions.
    
    When a commit record is encountered in the log, the transaction is
    committed to the fs and the in-core structures are freed. If a
    filesystem crashes or shuts down before all in-core log buffers are
    flushed to the log, however, not all transactions may have commit
    records in the log. As expected, the modifications in such an
    incomplete transaction are not replayed to the fs. The in-core data
    structures for the partial transaction are never freed, however,
    resulting in a memory leak.
    
    Update xlog_do_recovery_pass() to first correctly initialize the
    hash table array so empty lists can be distinguished from populated
    lists on function exit. Update xlog_recover_free_trans() to always
    remove the transaction from the list prior to freeing the associated
    memory. Finally, walk the hash table of transaction lists as the
    last step before it goes out of scope and free any transactions that
    may remain on the lists. This prevents a memory leak of partial
    transactions in the log.
    Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    39775431
xfs_log_recover.c 160 KB