#include <linux/fs.h>
#include <linux/buffer_head.h>
#include <linux/workqueue.h>
+#include <linux/completion.h>
#include "bit-radix.h"
struct btrfs_trans_handle;
struct btrfs_path {
struct buffer_head *nodes[BTRFS_MAX_LEVEL];
int slots[BTRFS_MAX_LEVEL];
+ int reada;
+ int lowest_level;
};
/*
struct radix_tree_root block_group_radix;
struct radix_tree_root block_group_data_radix;
struct radix_tree_root extent_map_radix;
-
- u64 extent_tree_insert[BTRFS_MAX_LEVEL * 3];
- int extent_tree_insert_nr;
- u64 extent_tree_prealloc[BTRFS_MAX_LEVEL * 3];
- int extent_tree_prealloc_nr;
-
+ struct radix_tree_root extent_ins_radix;
u64 generation;
+ u64 last_trans_committed;
struct btrfs_transaction *running_transaction;
struct btrfs_super_block *disk_super;
struct btrfs_super_block super_copy;
struct list_head trans_list;
struct list_head dead_roots;
struct delayed_work trans_work;
+ struct kobject super_kobj;
+ struct completion kobj_unregister;
int do_barriers;
int closing;
};
struct btrfs_key root_key;
struct btrfs_fs_info *fs_info;
struct inode *inode;
+ struct kobject root_kobj;
+ struct completion kobj_unregister;
+ struct rw_semaphore snap_sem;
u64 objectid;
u64 last_trans;
u32 blocksize;
- int ref_cows;
u32 type;
u64 highest_inode;
u64 last_inode_alloc;
+ int ref_cows;
+ struct btrfs_key defrag_progress;
+ int defrag_running;
+ int defrag_level;
+ char *name;
};
/* the lower bits in the key flags defines the item type */
item->flags = cpu_to_le32(val);
}
+static inline void btrfs_set_root_blocks_used(struct btrfs_root_item *item,
+ u64 val)
+{
+ item->blocks_used = cpu_to_le64(val);
+}
+
+static inline u64 btrfs_root_blocks_used(struct btrfs_root_item *item)
+{
+ return le64_to_cpu(item->blocks_used);
+}
+
+static inline void btrfs_set_root_block_limit(struct btrfs_root_item *item,
+ u64 val)
+{
+ item->block_limit = cpu_to_le64(val);
+}
+
+static inline u64 btrfs_root_block_limit(struct btrfs_root_item *item)
+{
+ return le64_to_cpu(item->block_limit);
+}
+
static inline u64 btrfs_super_blocknr(struct btrfs_super_block *s)
{
return le64_to_cpu(s->blocknr);
memmove(dst, src, nr);
}
-static inline void btrfs_mark_buffer_dirty(struct buffer_head *bh)
+static inline int btrfs_set_root_name(struct btrfs_root *root,
+ const char *name, int len)
{
- WARN_ON(!atomic_read(&bh->b_count));
- mark_buffer_dirty(bh);
+ /* if we already have a name just free it */
+ if (root->name)
+ kfree(root->name);
+
+ root->name = kmalloc(len+1, GFP_KERNEL);
+ if (!root->name)
+ return -ENOMEM;
+
+ memcpy(root->name, name, len);
+ root->name[len] ='\0';
+
+ return 0;
}
/* helper function to cast into the data area of the leaf. */
((type *)(btrfs_leaf_data(leaf) + \
btrfs_item_offset((leaf)->items + (slot))))
+/* mount option defines and helpers */
+#define BTRFS_MOUNT_SUBVOL 0x000001
+#define btrfs_clear_opt(o, opt) o &= ~BTRFS_MOUNT_##opt
+#define btrfs_set_opt(o, opt) o |= BTRFS_MOUNT_##opt
+#define btrfs_test_opt(sb, opt) (BTRFS_SB(sb)->s_mount_opt & \
+ BTRFS_MOUNT_##opt)
/* extent-tree.c */
+int btrfs_extent_post_op(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root);
+int btrfs_copy_pinned(struct btrfs_root *root, struct radix_tree_root *copy);
struct btrfs_block_group_cache *btrfs_lookup_block_group(struct
btrfs_fs_info *info,
u64 blocknr);
int btrfs_inc_root_ref(struct btrfs_trans_handle *trans,
struct btrfs_root *root);
struct buffer_head *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
- struct btrfs_root *root, u64 hint);
+ struct btrfs_root *root, u64 hint,
+ u64 empty_size);
int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 owner,
- u64 num_blocks, u64 search_start,
+ u64 num_blocks, u64 empty_size, u64 search_start,
u64 search_end, struct btrfs_key *ins, int data);
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);
+int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ struct radix_tree_root *unpin_radix);
int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
u64 blocknr, u64 num_blocks);
int btrfs_free_block_groups(struct btrfs_fs_info *info);
int btrfs_read_block_groups(struct btrfs_root *root);
/* ctree.c */
+int btrfs_cow_block(struct btrfs_trans_handle *trans, struct btrfs_root
+ *root, struct buffer_head *buf, struct buffer_head
+ *parent, int parent_slot, struct buffer_head
+ **cow_ret);
int btrfs_extend_item(struct btrfs_trans_handle *trans, struct btrfs_root
*root, struct btrfs_path *path, u32 data_size);
int btrfs_truncate_item(struct btrfs_trans_handle *trans,
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_realloc_node(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root, struct buffer_head *parent,
+ int cache_only, u64 *last_ret);
void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p);
struct btrfs_path *btrfs_alloc_path(void);
void btrfs_free_path(struct btrfs_path *p);
int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path);
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);
+ *root);
/* root-item.c */
int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
struct btrfs_key *key);
*item);
int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct
btrfs_root_item *item, struct btrfs_key *key);
-int btrfs_find_dead_roots(struct btrfs_root *root);
+int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid,
+ struct btrfs_root *latest_root);
/* 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,
unsigned from, unsigned to);
int btrfs_get_block(struct inode *inode, sector_t iblock,
struct buffer_head *result, int create);
+struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
+ size_t page_offset, u64 start, u64 end,
+ int create);
+int btrfs_update_inode(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root,
+ struct inode *inode);
/* file.c */
+int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end);
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);
+/* tree-defrag.c */
+int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root, int cache_only);
+
+/* sysfs.c */
+int btrfs_init_sysfs(void);
+void btrfs_exit_sysfs(void);
+int btrfs_sysfs_add_super(struct btrfs_fs_info *fs);
+int btrfs_sysfs_add_root(struct btrfs_root *root);
+void btrfs_sysfs_del_root(struct btrfs_root *root);
+void btrfs_sysfs_del_super(struct btrfs_fs_info *root);
+
#endif