@@ -4340,6 +4340,16 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info)
*/
btrfs_flush_workqueue(fs_info->delalloc_workers);
+ /*
+ * We can also have ordered extents getting their last reference dropped
+ * from the endio_workers workqueue because for data bios we keep a
+ * reference on an ordered extent which gets dropped when running
+ * btrfs_bio_end_io() in that workqueue, and that final drop results in
+ * adding a delayed iput for the inode.
+ */
+ if (fs_info->endio_workers)
+ flush_workqueue(fs_info->endio_workers);
+
/*
* After we parked the cleaner kthread, ordered extents may have
* completed and created new delayed iputs. If one of the async reclaim