@@ -3630,6 +3630,12 @@ void close_ctree(struct btrfs_root *root)
fs_info->closing = 1;
smp_mb();
+ /*
+ * Remove btrfs sysfs interfaces first, since it can start new
+ * transaction.
+ */
+ btrfs_sysfs_remove_one(fs_info);
+
/* wait for the uuid_scan task to finish */
down(&fs_info->uuid_tree_rescan_sem);
/* avoid complains from lockdep et al., set sem back to initial state */
@@ -3673,8 +3679,6 @@ void close_ctree(struct btrfs_root *root)
percpu_counter_sum(&fs_info->delalloc_bytes));
}
- btrfs_sysfs_remove_one(fs_info);
-
btrfs_free_fs_roots(fs_info);
btrfs_put_block_group_cache(fs_info);