Rename the extent_map code to extent_io

This mirrors the changes in the kernel code.
This commit is contained in:
Chris Mason 2008-03-04 11:16:54 -05:00 committed by David Woodhouse
parent 79599947bf
commit 80791984f6
6 changed files with 73 additions and 84 deletions

View File

@ -3,7 +3,7 @@ AM_CFLAGS = -Wall -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=
CFLAGS = -g -Werror
objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
root-tree.o dir-item.o hash.o file-item.o inode-item.o \
inode-map.o crc32c.o rbtree.o extent-cache.o extent_map.o \
inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o \
#
CHECKFLAGS=-D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \
-Wuninitialized -Wshadow -Wundef

20
ctree.h
View File

@ -23,7 +23,7 @@
#include "kerncompat.h"
#include "radix-tree.h"
#include "extent-cache.h"
#include "extent_map.h"
#include "extent_io.h"
struct btrfs_root;
struct btrfs_trans_handle;
@ -311,14 +311,12 @@ struct btrfs_fs_info {
struct btrfs_root *extent_root;
struct btrfs_root *tree_root;
struct extent_map_tree extent_cache;
struct extent_map_tree free_space_cache;
struct extent_map_tree block_group_cache;
struct extent_map_tree pending_tree;
struct extent_map_tree pinned_extents;
struct extent_map_tree del_pending;
struct extent_map_tree pending_del;
struct extent_map_tree extent_ins;
struct extent_io_tree extent_cache;
struct extent_io_tree free_space_cache;
struct extent_io_tree block_group_cache;
struct extent_io_tree pinned_extents;
struct extent_io_tree pending_del;
struct extent_io_tree extent_ins;
u64 generation;
u64 last_trans_committed;
@ -910,7 +908,7 @@ u32 btrfs_count_snapshots_in_path(struct btrfs_root *root,
u64 first_extent);
int btrfs_extent_post_op(struct btrfs_trans_handle *trans,
struct btrfs_root *root);
int btrfs_copy_pinned(struct btrfs_root *root, struct extent_map_tree *copy);
int btrfs_copy_pinned(struct btrfs_root *root, struct extent_io_tree *copy);
struct btrfs_block_group_cache *btrfs_lookup_block_group(struct
btrfs_fs_info *info,
u64 bytenr);
@ -955,7 +953,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
u64 owner_objectid, u64 owner_offset, int pin);
int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct extent_map_tree *unpin);
struct extent_io_tree *unpin);
int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
u64 bytenr, u64 num_bytes,

View File

@ -189,7 +189,7 @@ static int __commit_transaction(struct btrfs_trans_handle *trans,
u64 start;
u64 end;
struct extent_buffer *eb;
struct extent_map_tree *tree = &root->fs_info->extent_cache;
struct extent_io_tree *tree = &root->fs_info->extent_cache;
int ret;
while(1) {
@ -398,12 +398,12 @@ struct btrfs_root *open_ctree_fd(int fp, u64 sb_bytenr)
fs_info->extent_root = extent_root;
fs_info->extent_ops = NULL;
fs_info->priv_data = NULL;
extent_map_tree_init(&fs_info->extent_cache);
extent_map_tree_init(&fs_info->free_space_cache);
extent_map_tree_init(&fs_info->pending_tree);
extent_map_tree_init(&fs_info->pinned_extents);
extent_map_tree_init(&fs_info->del_pending);
extent_map_tree_init(&fs_info->block_group_cache);
extent_io_tree_init(&fs_info->extent_cache);
extent_io_tree_init(&fs_info->free_space_cache);
extent_io_tree_init(&fs_info->block_group_cache);
extent_io_tree_init(&fs_info->pinned_extents);
extent_io_tree_init(&fs_info->pending_del);
extent_io_tree_init(&fs_info->extent_ins);
mutex_init(&fs_info->fs_mutex);
@ -497,12 +497,12 @@ int close_ctree(struct btrfs_root *root)
free_extent_buffer(root->commit_root);
free_extent_buffer(root->fs_info->sb_buffer);
extent_map_tree_cleanup(&fs_info->extent_cache);
extent_map_tree_cleanup(&fs_info->free_space_cache);
extent_map_tree_cleanup(&fs_info->pending_tree);
extent_map_tree_cleanup(&fs_info->pinned_extents);
extent_map_tree_cleanup(&fs_info->del_pending);
extent_map_tree_cleanup(&fs_info->block_group_cache);
extent_io_tree_cleanup(&fs_info->extent_cache);
extent_io_tree_cleanup(&fs_info->free_space_cache);
extent_io_tree_cleanup(&fs_info->block_group_cache);
extent_io_tree_cleanup(&fs_info->pinned_extents);
extent_io_tree_cleanup(&fs_info->pending_del);
extent_io_tree_cleanup(&fs_info->extent_ins);
free(fs_info->tree_root);
free(fs_info->extent_root);

View File

@ -63,7 +63,7 @@ static int cache_block_group(struct btrfs_root *root,
int ret;
struct btrfs_key key;
struct extent_buffer *leaf;
struct extent_map_tree *free_space_cache;
struct extent_io_tree *free_space_cache;
int slot;
u64 last = 0;
u64 hole_size;
@ -158,7 +158,7 @@ struct btrfs_block_group_cache *btrfs_lookup_block_group(struct
btrfs_fs_info *info,
u64 bytenr)
{
struct extent_map_tree *block_group_cache;
struct extent_io_tree *block_group_cache;
struct btrfs_block_group_cache *block_group = NULL;
u64 ptr;
u64 start;
@ -277,7 +277,7 @@ struct btrfs_block_group_cache *btrfs_find_block_group(struct btrfs_root *root,
int data, int owner)
{
struct btrfs_block_group_cache *cache;
struct extent_map_tree *block_group_cache;
struct extent_io_tree *block_group_cache;
struct btrfs_block_group_cache *found_group = NULL;
struct btrfs_fs_info *info = root->fs_info;
u64 used;
@ -936,7 +936,7 @@ fail:
int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
struct btrfs_root *root)
{
struct extent_map_tree *block_group_cache;
struct extent_io_tree *block_group_cache;
struct btrfs_block_group_cache *cache;
int ret;
int err = 0;
@ -1092,12 +1092,12 @@ static int update_pinned_extents(struct btrfs_root *root,
return 0;
}
int btrfs_copy_pinned(struct btrfs_root *root, struct extent_map_tree *copy)
int btrfs_copy_pinned(struct btrfs_root *root, struct extent_io_tree *copy)
{
u64 last = 0;
u64 start;
u64 end;
struct extent_map_tree *pinned_extents = &root->fs_info->pinned_extents;
struct extent_io_tree *pinned_extents = &root->fs_info->pinned_extents;
int ret;
while(1) {
@ -1113,12 +1113,12 @@ int btrfs_copy_pinned(struct btrfs_root *root, struct extent_map_tree *copy)
int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct extent_map_tree *unpin)
struct extent_io_tree *unpin)
{
u64 start;
u64 end;
int ret;
struct extent_map_tree *free_space_cache;
struct extent_io_tree *free_space_cache;
free_space_cache = &root->fs_info->free_space_cache;
while(1) {
@ -1314,8 +1314,8 @@ static int del_pending_extents(struct btrfs_trans_handle *trans, struct
int err = 0;
u64 start;
u64 end;
struct extent_map_tree *pending_del;
struct extent_map_tree *pinned_extents;
struct extent_io_tree *pending_del;
struct extent_io_tree *pinned_extents;
pending_del = &extent_root->fs_info->pending_del;
pinned_extents = &extent_root->fs_info->pinned_extents;
@ -1755,15 +1755,6 @@ struct extent_buffer *__btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
return ERR_PTR(-ENOMEM);
}
btrfs_set_buffer_uptodate(buf);
/*
set_extent_dirty(&trans->transaction->dirty_pages, buf->start,
buf->start + buf->len - 1, GFP_NOFS);
set_extent_bits(&BTRFS_I(root->fs_info->btree_inode)->extent_tree,
buf->start, buf->start + buf->len - 1,
EXTENT_CSUM, GFP_NOFS);
buf->flags |= EXTENT_CSUM;
btrfs_set_buffer_defrag(buf);
*/
trans->blocks_used++;
return buf;
}
@ -2121,7 +2112,7 @@ int btrfs_read_block_groups(struct btrfs_root *root)
int bit;
struct btrfs_block_group_cache *cache;
struct btrfs_fs_info *info = root->fs_info;
struct extent_map_tree *block_group_cache;
struct extent_io_tree *block_group_cache;
struct btrfs_key key;
struct btrfs_key found_key;
struct extent_buffer *leaf;
@ -2220,7 +2211,7 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans,
int bit;
struct btrfs_root *extent_root;
struct btrfs_block_group_cache *cache;
struct extent_map_tree *block_group_cache;
struct extent_io_tree *block_group_cache;
extent_root = root->fs_info->extent_root;
block_group_cache = &root->fs_info->block_group_cache;

View File

@ -24,12 +24,12 @@
#include <fcntl.h>
#include <unistd.h>
#include "kerncompat.h"
#include "extent_map.h"
#include "extent_io.h"
#include "list.h"
u64 cache_max = 1024 * 1024 * 32;
void extent_map_tree_init(struct extent_map_tree *tree)
void extent_io_tree_init(struct extent_io_tree *tree)
{
cache_tree_init(&tree->state);
cache_tree_init(&tree->cache);
@ -58,7 +58,7 @@ static void free_extent_state(struct extent_state *state)
free(state);
}
void extent_map_tree_cleanup(struct extent_map_tree *tree)
void extent_io_tree_cleanup(struct extent_io_tree *tree)
{
struct extent_state *es;
struct extent_buffer *eb;
@ -95,7 +95,7 @@ static inline void update_extent_state(struct extent_state *state)
* extent in the tree. Extents with EXTENT_IO in their state field are
* not merged
*/
static int merge_state(struct extent_map_tree *tree,
static int merge_state(struct extent_io_tree *tree,
struct extent_state *state)
{
struct extent_state *other;
@ -135,7 +135,7 @@ static int merge_state(struct extent_map_tree *tree,
* insert an extent_state struct into the tree. 'bits' are set on the
* struct before it is inserted.
*/
static int insert_state(struct extent_map_tree *tree,
static int insert_state(struct extent_io_tree *tree,
struct extent_state *state, u64 start, u64 end,
int bits)
{
@ -157,7 +157,7 @@ static int insert_state(struct extent_map_tree *tree,
* struct 'prealloc' as the newly created second half. 'split' indicates an
* offset inside 'orig' where it should be split.
*/
static int split_state(struct extent_map_tree *tree, struct extent_state *orig,
static int split_state(struct extent_io_tree *tree, struct extent_state *orig,
struct extent_state *prealloc, u64 split)
{
int ret;
@ -176,7 +176,7 @@ static int split_state(struct extent_map_tree *tree, struct extent_state *orig,
/*
* clear some bits on a range in the tree.
*/
static int clear_state_bit(struct extent_map_tree *tree,
static int clear_state_bit(struct extent_io_tree *tree,
struct extent_state *state, int bits)
{
int ret = state->state & bits;
@ -194,7 +194,7 @@ static int clear_state_bit(struct extent_map_tree *tree,
/*
* set some bits on a range in the tree.
*/
int clear_extent_bits(struct extent_map_tree *tree, u64 start,
int clear_extent_bits(struct extent_io_tree *tree, u64 start,
u64 end, int bits, gfp_t mask)
{
struct extent_state *state;
@ -280,7 +280,7 @@ search_again:
/*
* set some bits on a range in the tree.
*/
int set_extent_bits(struct extent_map_tree *tree, u64 start,
int set_extent_bits(struct extent_io_tree *tree, u64 start,
u64 end, int bits, gfp_t mask)
{
struct extent_state *state;
@ -401,19 +401,19 @@ search_again:
goto again;
}
int set_extent_dirty(struct extent_map_tree *tree, u64 start, u64 end,
int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end,
gfp_t mask)
{
return set_extent_bits(tree, start, end, EXTENT_DIRTY, mask);
}
int clear_extent_dirty(struct extent_map_tree *tree, u64 start, u64 end,
int clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end,
gfp_t mask)
{
return clear_extent_bits(tree, start, end, EXTENT_DIRTY, mask);
}
int find_first_extent_bit(struct extent_map_tree *tree, u64 start,
int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
u64 *start_ret, u64 *end_ret, int bits)
{
struct cache_extent *node;
@ -444,7 +444,7 @@ out:
return ret;
}
int test_range_bit(struct extent_map_tree *tree, u64 start, u64 end,
int test_range_bit(struct extent_io_tree *tree, u64 start, u64 end,
int bits, int filled)
{
struct extent_state *state = NULL;
@ -482,7 +482,7 @@ int test_range_bit(struct extent_map_tree *tree, u64 start, u64 end,
return bitset;
}
int set_state_private(struct extent_map_tree *tree, u64 start, u64 private)
int set_state_private(struct extent_io_tree *tree, u64 start, u64 private)
{
struct cache_extent *node;
struct extent_state *state;
@ -503,7 +503,7 @@ out:
return ret;
}
int get_state_private(struct extent_map_tree *tree, u64 start, u64 *private)
int get_state_private(struct extent_io_tree *tree, u64 start, u64 *private)
{
struct cache_extent *node;
struct extent_state *state;
@ -524,7 +524,7 @@ out:
return ret;
}
static int free_some_buffers(struct extent_map_tree *tree)
static int free_some_buffers(struct extent_io_tree *tree)
{
u32 nrscan = 0;
struct extent_buffer *eb;
@ -545,7 +545,7 @@ static int free_some_buffers(struct extent_map_tree *tree)
return 0;
}
static struct extent_buffer *__alloc_extent_buffer(struct extent_map_tree *tree,
static struct extent_buffer *__alloc_extent_buffer(struct extent_io_tree *tree,
u64 bytenr, u32 blocksize)
{
struct extent_buffer *eb;
@ -584,7 +584,7 @@ void free_extent_buffer(struct extent_buffer *eb)
eb->refs--;
BUG_ON(eb->refs < 0);
if (eb->refs == 0) {
struct extent_map_tree *tree = eb->tree;
struct extent_io_tree *tree = eb->tree;
BUG_ON(eb->flags & EXTENT_DIRTY);
list_del_init(&eb->lru);
remove_cache_extent(&tree->cache, &eb->cache_node);
@ -594,7 +594,7 @@ void free_extent_buffer(struct extent_buffer *eb)
}
}
struct extent_buffer *find_extent_buffer(struct extent_map_tree *tree,
struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree,
u64 bytenr, u32 blocksize)
{
struct extent_buffer *eb = NULL;
@ -609,7 +609,7 @@ struct extent_buffer *find_extent_buffer(struct extent_map_tree *tree,
return eb;
}
struct extent_buffer *find_first_extent_buffer(struct extent_map_tree *tree,
struct extent_buffer *find_first_extent_buffer(struct extent_io_tree *tree,
u64 start)
{
struct extent_buffer *eb = NULL;
@ -624,7 +624,7 @@ struct extent_buffer *find_first_extent_buffer(struct extent_map_tree *tree,
return eb;
}
struct extent_buffer *alloc_extent_buffer(struct extent_map_tree *tree,
struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
u64 bytenr, u32 blocksize)
{
struct extent_buffer *eb;
@ -692,7 +692,7 @@ int extent_buffer_uptodate(struct extent_buffer *eb)
int set_extent_buffer_dirty(struct extent_buffer *eb)
{
struct extent_map_tree *tree = eb->tree;
struct extent_io_tree *tree = eb->tree;
if (!(eb->flags & EXTENT_DIRTY)) {
eb->flags |= EXTENT_DIRTY;
set_extent_dirty(tree, eb->start, eb->start + eb->len - 1, 0);
@ -703,7 +703,7 @@ int set_extent_buffer_dirty(struct extent_buffer *eb)
int clear_extent_buffer_dirty(struct extent_buffer *eb)
{
struct extent_map_tree *tree = eb->tree;
struct extent_io_tree *tree = eb->tree;
if (eb->flags & EXTENT_DIRTY) {
eb->flags &= ~EXTENT_DIRTY;
clear_extent_dirty(tree, eb->start, eb->start + eb->len - 1, 0);

View File

@ -34,7 +34,7 @@
#define EXTENT_CSUM (1 << 9)
#define EXTENT_IOBITS (EXTENT_LOCKED | EXTENT_WRITEBACK)
struct extent_map_tree {
struct extent_io_tree {
struct cache_tree state;
struct cache_tree cache;
struct list_head lru;
@ -55,7 +55,7 @@ struct extent_buffer {
u64 start;
u64 dev_bytenr;
u32 len;
struct extent_map_tree *tree;
struct extent_io_tree *tree;
struct list_head lru;
int refs;
int flags;
@ -68,29 +68,29 @@ static inline void extent_buffer_get(struct extent_buffer *eb)
eb->refs++;
}
void extent_map_tree_init(struct extent_map_tree *tree);
void extent_map_tree_cleanup(struct extent_map_tree *tree);
int set_extent_bits(struct extent_map_tree *tree, u64 start,
void extent_io_tree_init(struct extent_io_tree *tree);
void extent_io_tree_cleanup(struct extent_io_tree *tree);
int set_extent_bits(struct extent_io_tree *tree, u64 start,
u64 end, int bits, gfp_t mask);
int clear_extent_bits(struct extent_map_tree *tree, u64 start,
int clear_extent_bits(struct extent_io_tree *tree, u64 start,
u64 end, int bits, gfp_t mask);
int find_first_extent_bit(struct extent_map_tree *tree, u64 start,
int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
u64 *start_ret, u64 *end_ret, int bits);
int test_range_bit(struct extent_map_tree *tree, u64 start, u64 end,
int test_range_bit(struct extent_io_tree *tree, u64 start, u64 end,
int bits, int filled);
int set_extent_dirty(struct extent_map_tree *tree, u64 start,
int set_extent_dirty(struct extent_io_tree *tree, u64 start,
u64 end, gfp_t mask);
int clear_extent_dirty(struct extent_map_tree *tree, u64 start,
int clear_extent_dirty(struct extent_io_tree *tree, u64 start,
u64 end, gfp_t mask);
int extent_buffer_uptodate(struct extent_buffer *eb);
int set_extent_buffer_uptodate(struct extent_buffer *eb);
int set_state_private(struct extent_map_tree *tree, u64 start, u64 private);
int get_state_private(struct extent_map_tree *tree, u64 start, u64 *private);
struct extent_buffer *find_extent_buffer(struct extent_map_tree *tree,
int set_state_private(struct extent_io_tree *tree, u64 start, u64 private);
int get_state_private(struct extent_io_tree *tree, u64 start, u64 *private);
struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree,
u64 bytenr, u32 blocksize);
struct extent_buffer *find_first_extent_buffer(struct extent_map_tree *tree,
struct extent_buffer *find_first_extent_buffer(struct extent_io_tree *tree,
u64 start);
struct extent_buffer *alloc_extent_buffer(struct extent_map_tree *tree,
struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
u64 bytenr, u32 blocksize);
void free_extent_buffer(struct extent_buffer *eb);
int read_extent_from_disk(struct extent_buffer *eb);