From: Filipe Manana Date: Tue, 12 Sep 2023 12:04:31 +0000 (+0100) Subject: btrfs: mark transaction id check as unlikely at btrfs_mark_buffer_dirty() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=4ebe8d478879c84a9e0c4f655cd8652fdbe239ac;p=people%2Fpauldu%2Flinux.git btrfs: mark transaction id check as unlikely at btrfs_mark_buffer_dirty() At btrfs_mark_buffer_dirty(), having a transaction id mismatch is never expected to happen and it usually means there's a bug or some memory corruption due to a bitflip for example. So mark the condition as unlikely to optimize code generation as well as to make it obvious for human readers that it is a very unexpected condition. Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index d906368a2d3f..163f37ad1b27 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4403,7 +4403,7 @@ void btrfs_mark_buffer_dirty(struct btrfs_trans_handle *trans, /* This is an active transaction (its state < TRANS_STATE_UNBLOCKED). */ ASSERT(trans->transid == fs_info->generation); btrfs_assert_tree_write_locked(buf); - if (transid != fs_info->generation) { + if (unlikely(transid != fs_info->generation)) { btrfs_abort_transaction(trans, -EUCLEAN); btrfs_crit(fs_info, "dirty buffer transid mismatch, logical %llu found transid %llu running transid %llu",