Skip to content

Commit ffb7c2e

Browse files
fdmananakdave
authored andcommitted
btrfs: do not consider send context as valid when trying to flush qgroups
At qgroup.c:try_flush_qgroup() we are asserting that current->journal_info is either NULL or has the value BTRFS_SEND_TRANS_STUB. However allowing for BTRFS_SEND_TRANS_STUB makes no sense because: 1) It is misleading, because send operations are read-only and do not ever need to reserve qgroup space; 2) We already assert that current->journal_info != BTRFS_SEND_TRANS_STUB at transaction.c:start_transaction(); 3) On a kernel without CONFIG_BTRFS_ASSERT=y set, it would result in a crash if try_flush_qgroup() is ever called in a send context, because at transaction.c:start_transaction we cast current->journal_info into a struct btrfs_trans_handle pointer and then dereference it. So just do allow a send context at try_flush_qgroup() and update the comment about it. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent adbd914 commit ffb7c2e

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

fs/btrfs/qgroup.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,11 +3545,15 @@ static int try_flush_qgroup(struct btrfs_root *root)
35453545
struct btrfs_trans_handle *trans;
35463546
int ret;
35473547

3548-
/* Can't hold an open transaction or we run the risk of deadlocking */
3549-
ASSERT(current->journal_info == NULL ||
3550-
current->journal_info == BTRFS_SEND_TRANS_STUB);
3551-
if (WARN_ON(current->journal_info &&
3552-
current->journal_info != BTRFS_SEND_TRANS_STUB))
3548+
/*
3549+
* Can't hold an open transaction or we run the risk of deadlocking,
3550+
* and can't either be under the context of a send operation (where
3551+
* current->journal_info is set to BTRFS_SEND_TRANS_STUB), as that
3552+
* would result in a crash when starting a transaction and does not
3553+
* make sense either (send is a read-only operation).
3554+
*/
3555+
ASSERT(current->journal_info == NULL);
3556+
if (WARN_ON(current->journal_info))
35533557
return 0;
35543558

35553559
/*

0 commit comments

Comments
 (0)