--- x/fs/btrfs/disk-io.c +++ y/fs/btrfs/disk-io.c @@ -4315,9 +4315,6 @@ void __cold close_ctree(struct btrfs_fs_ if (BTRFS_FS_ERROR(fs_info)) btrfs_error_commit_super(fs_info); - kthread_stop(fs_info->transaction_kthread); - kthread_stop(fs_info->cleaner_kthread); - ASSERT(list_empty(&fs_info->delayed_iputs)); set_bit(BTRFS_FS_CLOSING_DONE, &fs_info->flags); @@ -4349,6 +4346,8 @@ void __cold close_ctree(struct btrfs_fs_ */ invalidate_inode_pages2(fs_info->btree_inode->i_mapping); btrfs_stop_all_workers(fs_info); + kthread_stop(fs_info->transaction_kthread); + kthread_stop(fs_info->cleaner_kthread); /* We shouldn't have any transaction open at this point */ warn_about_uncommitted_trans(fs_info);