Commit ffb7c2e9 authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

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: 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>
parent adbd914d
...@@ -3545,11 +3545,15 @@ static int try_flush_qgroup(struct btrfs_root *root) ...@@ -3545,11 +3545,15 @@ static int try_flush_qgroup(struct btrfs_root *root)
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
int ret; int ret;
/* Can't hold an open transaction or we run the risk of deadlocking */ /*
ASSERT(current->journal_info == NULL || * Can't hold an open transaction or we run the risk of deadlocking,
current->journal_info == BTRFS_SEND_TRANS_STUB); * and can't either be under the context of a send operation (where
if (WARN_ON(current->journal_info && * current->journal_info is set to BTRFS_SEND_TRANS_STUB), as that
current->journal_info != BTRFS_SEND_TRANS_STUB)) * would result in a crash when starting a transaction and does not
* make sense either (send is a read-only operation).
*/
ASSERT(current->journal_info == NULL);
if (WARN_ON(current->journal_info))
return 0; return 0;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment