#ifndef __BTRFS__
#define __BTRFS__
-#include <linux/radix-tree.h>
#include <linux/fs.h>
+#include "bit-radix.h"
struct btrfs_trans_handle;
struct btrfs_transaction;
#define BTRFS_MAGIC "_BtRfS_M"
-#define BTRFS_ROOT_TREE_OBJECTID 1
-#define BTRFS_EXTENT_TREE_OBJECTID 2
-#define BTRFS_INODE_MAP_OBJECTID 3
-#define BTRFS_FS_TREE_OBJECTID 4
+#define BTRFS_ROOT_TREE_OBJECTID 1ULL
+#define BTRFS_EXTENT_TREE_OBJECTID 2ULL
+#define BTRFS_INODE_MAP_OBJECTID 3ULL
+#define BTRFS_FS_TREE_OBJECTID 4ULL
+#define BTRFS_FIRST_FREE_OBJECTID 5ULL
/*
* we can actually store much bigger names, but lets not confuse the rest
__le32 ham;
__le16 nritems;
__le16 flags;
- /* generation flags to be added */
+ u8 level;
} __attribute__ ((__packed__));
#define BTRFS_MAX_LEVEL 8
__le64 disk_blocknr;
__le64 disk_num_blocks;
/*
- * the logical offset in file bytes (no csums)
+ * the logical offset in file blocks (no csums)
* this extent record is for. This allows a file extent to point
* into the middle of an existing extent on disk, sharing it
* between two snapshots (useful if some bytes in the middle of the
struct btrfs_root *inode_root;
struct btrfs_key current_insert;
struct btrfs_key last_insert;
+ struct radix_tree_root pending_del_radix;
struct radix_tree_root pinned_radix;
u64 last_inode_alloc;
u64 last_inode_alloc_dirid;
struct buffer_head *sb_buffer;
struct super_block *sb;
struct mutex trans_mutex;
+ struct mutex fs_mutex;
};
/*
static inline int btrfs_header_level(struct btrfs_header *h)
{
- return btrfs_header_flags(h) & (BTRFS_MAX_LEVEL - 1);
+ return h->level;
}
static inline void btrfs_set_header_level(struct btrfs_header *h, int level)
{
- u16 flags;
BUG_ON(level > BTRFS_MAX_LEVEL);
- flags = btrfs_header_flags(h) & ~(BTRFS_MAX_LEVEL - 1);
- btrfs_set_header_flags(h, flags | level);
+ h->level = level;
}
static inline int btrfs_is_leaf(struct btrfs_node *n)
((type *)(btrfs_leaf_data(leaf) + \
btrfs_item_offset((leaf)->items + (slot))))
+/* extent-item.c */
struct buffer_head *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root);
+int btrfs_alloc_extent(struct btrfs_trans_handle *trans, struct btrfs_root
+ *root, u64 num_blocks, u64 search_start, u64
+ search_end, u64 owner, struct btrfs_key *ins);
int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
struct buffer_head *buf);
int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
*root, u64 blocknr, u64 num_blocks, int pin);
+int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, struct
+ btrfs_root *root);
+/* ctree.c */
int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root
*root, struct btrfs_key *key, struct btrfs_path *p, int
ins_len, int cow);
int btrfs_leaf_free_space(struct btrfs_root *root, struct btrfs_leaf *leaf);
int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root
*root, struct buffer_head *snap);
-int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, struct
- btrfs_root *root);
+/* root-item.c */
int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
struct btrfs_key *key);
int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
*item);
int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct
btrfs_root_item *item, struct btrfs_key *key);
+/* dir-item.c */
int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
*root, const char *name, int name_len, u64 dir, u64
objectid, u8 type);
const char *name, int name_len, int mod);
int btrfs_match_dir_item_name(struct btrfs_root *root, struct btrfs_path *path,
const char *name, int name_len);
+/* inode-map.c */
int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
struct btrfs_root *fs_root,
u64 dirid, u64 *objectid);
int btrfs_lookup_inode_map(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_path *path,
u64 objectid, int mod);
+/* inode-item.c */
int btrfs_insert_inode(struct btrfs_trans_handle *trans, struct btrfs_root
*root, u64 objectid, struct btrfs_inode_item
*inode_item);
int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
*root, struct btrfs_path *path, u64 objectid, int mod);
+
+/* file-item.c */
+int btrfs_alloc_file_extent(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ u64 objectid, u64 offset,
+ u64 num_blocks, u64 hint_block,
+ u64 *result);
+int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ struct btrfs_path *path, u64 objectid,
+ u64 blocknr, u64 num_blocks, int mod);
#endif