Btrfs: prevent loops in the directory tree when creating snapshots
For a directory tree:
/mnt/subvolA/subvolB
btrfsctl -s /mnt/subvolA/subvolB /mnt
Will create a directory loop with subvolA under subvolB. This
commit uses the forward refs for each subvol and snapshot to error out
before creating the loop.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 8d7866b..e18250a 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1129,7 +1129,7 @@
kfree(root);
return ERR_PTR(ret);
}
-
+#if 0
ret = btrfs_sysfs_add_root(root);
if (ret) {
free_extent_buffer(root->node);
@@ -1137,6 +1137,7 @@
kfree(root);
return ERR_PTR(ret);
}
+#endif
root->in_sysfs = 1;
return root;
}
@@ -1963,8 +1964,10 @@
down_write(&root->anon_super.s_umount);
kill_anon_super(&root->anon_super);
}
+#if 0
if (root->in_sysfs)
btrfs_sysfs_del_root(root);
+#endif
if (root->node)
free_extent_buffer(root->node);
if (root->commit_root)