jbd2: make sure jh have b_transaction set in refile/unfile_buffer
authorLukas Czerner <lczerner@redhat.com>
Wed, 17 Jun 2020 09:25:49 +0000 (11:25 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Sep 2020 09:29:29 +0000 (11:29 +0200)
commit55be43c8b123b14fcffaa81a7d9a0a4bda28022a
tree5c9d9ab7ea30d5f40d1e686f0c026a2f267eed39
parent9b04463ab4753797df4d7d8433c35955edfd505f
jbd2: make sure jh have b_transaction set in refile/unfile_buffer

[ Upstream commit 24dc9864914eb5813173cfa53313fcd02e4aea7d ]

Callers of __jbd2_journal_unfile_buffer() and
__jbd2_journal_refile_buffer() assume that the b_transaction is set. In
fact if it's not, we can end up with journal_head refcounting errors
leading to crash much later that might be very hard to track down. Add
asserts to make sure that is the case.

We also make sure that b_next_transaction is NULL in
__jbd2_journal_unfile_buffer() since the callers expect that as well and
we should not get into that stage in this state anyway, leading to
problems later on if we do.

Tested with fstests.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20200617092549.6712-1-lczerner@redhat.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/jbd2/transaction.c