Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
[pandora-kernel.git] / fs / btrfs / root-tree.c
index 29b2d7c..6928bff 100644 (file)
@@ -473,3 +473,21 @@ again:
        btrfs_free_path(path);
        return 0;
 }
+
+/*
+ * Old btrfs forgets to init root_item->flags and root_item->byte_limit
+ * for subvolumes. To work around this problem, we steal a bit from
+ * root_item->inode_item->flags, and use it to indicate if those fields
+ * have been properly initialized.
+ */
+void btrfs_check_and_init_root_item(struct btrfs_root_item *root_item)
+{
+       u64 inode_flags = le64_to_cpu(root_item->inode.flags);
+
+       if (!(inode_flags & BTRFS_INODE_ROOT_ITEM_INIT)) {
+               inode_flags |= BTRFS_INODE_ROOT_ITEM_INIT;
+               root_item->inode.flags = cpu_to_le64(inode_flags);
+               root_item->flags = 0;
+               root_item->byte_limit = 0;
+       }
+}