Btrfs: Switch to libcrc32c to avoid problems with cryptomgr on highmem machines
[linux-2.6-block.git] / fs / btrfs / ctree.h
index 756ea9d0123b0e4978aaeac6ce20178bbb2f5da3..19a1d998fca7ceccfcc05c26c69300ed1c8d73bf 100644 (file)
@@ -1,9 +1,27 @@
+/*
+ * Copyright (C) 2007 Oracle.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License v2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ */
+
 #ifndef __BTRFS__
 #define __BTRFS__
 
 #include <linux/fs.h>
 #include <linux/buffer_head.h>
-#include <linux/kobject.h>
+#include <linux/workqueue.h>
 #include "bit-radix.h"
 
 struct btrfs_trans_handle;
@@ -16,11 +34,10 @@ extern struct kmem_cache *btrfs_path_cachep;
 #define BTRFS_MAGIC "_BtRfS_M"
 
 #define BTRFS_ROOT_TREE_OBJECTID 1ULL
-#define BTRFS_DEV_TREE_OBJECTID 2ULL
-#define BTRFS_EXTENT_TREE_OBJECTID 3ULL
-#define BTRFS_FS_TREE_OBJECTID 4ULL
-#define BTRFS_ROOT_TREE_DIR_OBJECTID 5ULL
-#define BTRFS_FIRST_FREE_OBJECTID 6ULL
+#define BTRFS_EXTENT_TREE_OBJECTID 2ULL
+#define BTRFS_FS_TREE_OBJECTID 3ULL
+#define BTRFS_ROOT_TREE_DIR_OBJECTID 4ULL
+#define BTRFS_FIRST_FREE_OBJECTID 5ULL
 
 /*
  * we can actually store much bigger names, but lets not confuse the rest
@@ -34,6 +51,16 @@ extern struct kmem_cache *btrfs_path_cachep;
 #define BTRFS_CRC32_SIZE 4
 #define BTRFS_EMPTY_DIR_SIZE 6
 
+#define BTRFS_FT_UNKNOWN       0
+#define BTRFS_FT_REG_FILE      1
+#define BTRFS_FT_DIR           2
+#define BTRFS_FT_CHRDEV                3
+#define BTRFS_FT_BLKDEV                4
+#define BTRFS_FT_FIFO          5
+#define BTRFS_FT_SOCK          6
+#define BTRFS_FT_SYMLINK       7
+#define BTRFS_FT_MAX           8
+
 /*
  * the key defines the order in the tree, and so it also defines (optimal)
  * block layout.  objectid corresonds to the inode number.  The flags
@@ -101,12 +128,6 @@ struct btrfs_super_block {
        __le64 total_blocks;
        __le64 blocks_used;
        __le64 root_dir_objectid;
-       __le64 last_device_id;
-       /* fields below here vary with the underlying disk */
-       __le64 device_block_start;
-       __le64 device_num_blocks;
-       __le64 device_root;
-       __le64 device_id;
 } __attribute__ ((__packed__));
 
 /*
@@ -241,18 +262,16 @@ struct btrfs_csum_item {
        u8 csum;
 } __attribute__ ((__packed__));
 
-struct btrfs_device_item {
-       __le16 pathlen;
-       __le64 device_id;
-} __attribute__ ((__packed__));
-
 /* tag for the radix tree of block groups in ram */
 #define BTRFS_BLOCK_GROUP_DIRTY 0
 #define BTRFS_BLOCK_GROUP_AVAIL 1
-#define BTRFS_BLOCK_GROUP_HINTS 8
 #define BTRFS_BLOCK_GROUP_SIZE (256 * 1024 * 1024)
+
+
+#define BTRFS_BLOCK_GROUP_DATA 1
 struct btrfs_block_group_item {
        __le64 used;
+       u8 flags;
 } __attribute__ ((__packed__));
 
 struct btrfs_block_group_cache {
@@ -267,15 +286,12 @@ struct btrfs_block_group_cache {
        int cached;
 };
 
-struct crypto_hash;
 struct btrfs_fs_info {
        struct btrfs_root *extent_root;
        struct btrfs_root *tree_root;
-       struct btrfs_root *dev_root;
        struct radix_tree_root fs_roots_radix;
        struct radix_tree_root pending_del_radix;
        struct radix_tree_root pinned_radix;
-       struct radix_tree_root dev_radix;
        struct radix_tree_root block_group_radix;
        struct radix_tree_root block_group_data_radix;
        struct radix_tree_root extent_map_radix;
@@ -294,10 +310,10 @@ struct btrfs_fs_info {
        struct mutex trans_mutex;
        struct mutex fs_mutex;
        struct list_head trans_list;
-       struct crypto_hash *hash_tfm;
-       spinlock_t hash_lock;
+       struct list_head dead_roots;
+       struct delayed_work trans_work;
        int do_barriers;
-       struct kobject kobj;
+       int closing;
 };
 
 /*
@@ -369,11 +385,6 @@ struct btrfs_root {
  */
 #define BTRFS_BLOCK_GROUP_ITEM_KEY 34
 
-/*
- * dev items list the devices that make up the FS
- */
-#define BTRFS_DEV_ITEM_KEY     35
-
 /*
  * string items are for debugging.  They just store a short string of
  * data in the FS
@@ -864,62 +875,6 @@ static inline void btrfs_set_super_root_dir(struct btrfs_super_block *s, u64
        s->root_dir_objectid = cpu_to_le64(val);
 }
 
-static inline u64 btrfs_super_last_device_id(struct btrfs_super_block *s)
-{
-       return le64_to_cpu(s->last_device_id);
-}
-
-static inline void btrfs_set_super_last_device_id(struct btrfs_super_block *s,
-                                                 u64 val)
-{
-       s->last_device_id = cpu_to_le64(val);
-}
-
-static inline u64 btrfs_super_device_id(struct btrfs_super_block *s)
-{
-       return le64_to_cpu(s->device_id);
-}
-
-static inline void btrfs_set_super_device_id(struct btrfs_super_block *s,
-                                                 u64 val)
-{
-       s->device_id = cpu_to_le64(val);
-}
-
-static inline u64 btrfs_super_device_block_start(struct btrfs_super_block *s)
-{
-       return le64_to_cpu(s->device_block_start);
-}
-
-static inline void btrfs_set_super_device_block_start(struct btrfs_super_block
-                                                     *s, u64 val)
-{
-       s->device_block_start = cpu_to_le64(val);
-}
-
-static inline u64 btrfs_super_device_num_blocks(struct btrfs_super_block *s)
-{
-       return le64_to_cpu(s->device_num_blocks);
-}
-
-static inline void btrfs_set_super_device_num_blocks(struct btrfs_super_block
-                                                    *s, u64 val)
-{
-       s->device_num_blocks = cpu_to_le64(val);
-}
-
-static inline u64 btrfs_super_device_root(struct btrfs_super_block *s)
-{
-       return le64_to_cpu(s->device_root);
-}
-
-static inline void btrfs_set_super_device_root(struct btrfs_super_block
-                                                     *s, u64 val)
-{
-       s->device_root = cpu_to_le64(val);
-}
-
-
 static inline u8 *btrfs_leaf_data(struct btrfs_leaf *l)
 {
        return (u8 *)l->items;
@@ -1015,28 +970,6 @@ static inline void btrfs_set_file_extent_num_blocks(struct
        e->num_blocks = cpu_to_le64(val);
 }
 
-static inline u16 btrfs_device_pathlen(struct btrfs_device_item *d)
-{
-       return le16_to_cpu(d->pathlen);
-}
-
-static inline void btrfs_set_device_pathlen(struct btrfs_device_item *d,
-                                               u16 val)
-{
-       d->pathlen = cpu_to_le16(val);
-}
-
-static inline u64 btrfs_device_id(struct btrfs_device_item *d)
-{
-       return le64_to_cpu(d->device_id);
-}
-
-static inline void btrfs_set_device_id(struct btrfs_device_item *d,
-                                               u64 val)
-{
-       d->device_id = cpu_to_le64(val);
-}
-
 static inline struct btrfs_root *btrfs_sb(struct super_block *sb)
 {
        return sb->s_fs_info;
@@ -1079,6 +1012,9 @@ static inline void btrfs_mark_buffer_dirty(struct buffer_head *bh)
        btrfs_item_offset((leaf)->items + (slot))))
 
 /* extent-tree.c */
+struct btrfs_block_group_cache *btrfs_lookup_block_group(struct
+                                                        btrfs_fs_info *info,
+                                                        u64 blocknr);
 struct btrfs_block_group_cache *btrfs_find_block_group(struct btrfs_root *root,
                                                 struct btrfs_block_group_cache
                                                 *hint, u64 search_start,
@@ -1201,5 +1137,30 @@ struct btrfs_csum_item *btrfs_lookup_csum(struct btrfs_trans_handle *trans,
 int btrfs_csum_truncate(struct btrfs_trans_handle *trans,
                        struct btrfs_root *root, struct btrfs_path *path,
                        u64 isize);
-/* super.c */
+/* inode.c */
+int btrfs_page_mkwrite(struct vm_area_struct *vma, struct page *page);
+int btrfs_readpage(struct file *file, struct page *page);
+void btrfs_delete_inode(struct inode *inode);
+void btrfs_read_locked_inode(struct inode *inode);
+int btrfs_write_inode(struct inode *inode, int wait);
+void btrfs_dirty_inode(struct inode *inode);
+struct inode *btrfs_alloc_inode(struct super_block *sb);
+void btrfs_destroy_inode(struct inode *inode);
+int btrfs_init_cachep(void);
+void btrfs_destroy_cachep(void);
+int btrfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
+               unsigned long arg);
+long btrfs_compat_ioctl(struct file *file, unsigned int cmd,
+                              unsigned long arg);
+struct inode *btrfs_iget_locked(struct super_block *s, u64 objectid,
+                               struct btrfs_root *root);
+int btrfs_commit_write(struct file *file, struct page *page,
+                      unsigned from, unsigned to);
+int btrfs_get_block(struct inode *inode, sector_t iblock,
+                   struct buffer_head *result, int create);
+/* file.c */
+extern struct file_operations btrfs_file_operations;
+int btrfs_drop_extents(struct btrfs_trans_handle *trans,
+                      struct btrfs_root *root, struct inode *inode,
+                      u64 start, u64 end, u64 *hint_block);
 #endif