• Filipe Manana's avatar
    btrfs: scrub: avoid create/commit empty transaction at finish_extent_writes_for_zoned() · 1f8aee29
    Filipe Manana authored
    At finish_extent_writes_for_zoned() we use btrfs_join_transaction() to
    catch any running transaction and then commit it. This will however create
    a new and empty transaction in case there's no running transaction anymore
    (got committed by the transaction kthread or other task for example) or
    there's a running transaction finishing its commit and with a state >=
    TRANS_STATE_UNBLOCKED. In the former case we don't need to do anything
    while in the second case we just need to wait for the transaction to
    complete its commit.
    
    So improve this by using btrfs_attach_transaction_barrier() instead, which
    does not create a new transaction if there's none running, and if there's
    a current transaction that is committing, it will wait for it to fully
    commit and not create a new transaction. This helps avoiding creating and
    committing empty transactions, saving IO, time and unnecessary rotation of
    the backup roots in the super block.
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    1f8aee29
scrub.c 89.9 KB