diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 98b6903e3938..cdca0f656594 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -590,10 +590,19 @@ again: } got_it: - btrfs_record_root_in_trans(h, root); - if (!current->journal_info) current->journal_info = h; + + /* + * btrfs_record_root_in_trans() needs to alloc new extents, and may + * call btrfs_join_transaction() while we're also starting a + * transaction. + * + * Thus it need to be called after current->journal_info initialized, + * or we can deadlock. + */ + btrfs_record_root_in_trans(h, root); + return h; join_fail: