@@ -885,7 +885,18 @@ static noinline int commit_cowonly_roots(struct
btrfs_trans_handle *trans,
int btrfs_add_dead_root(struct btrfs_root *root)
{
spin_lock(&root->fs_info->trans_lock);
+ if (!list_empty(&root->root_list)) {
+ struct btrfs_root *tmp;
+ list_for_each_entry(tmp, &root->fs_info->dead_roots, root_list)
+ if (tmp == root) {
+ printk(KERN_ERR "btrfs: Duplicate dead root entry.\n");
+ WARN_ON(1);
+ goto unlock;
+ }
+ }
+
list_add(&root->root_list, &root->fs_info->dead_roots);
+unlock:
spin_unlock(&root->fs_info->trans_lock);
return 0;