Commit 4c6d1d85 authored by Chris Mason's avatar Chris Mason

btrfs: move struct io_ctl into ctree.h and rename it

We'll need to put the io_ctl into the block_group cache struct, so
name it struct btrfs_io_ctl and move it into ctree.h
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent 3bce876f
...@@ -1256,6 +1256,17 @@ struct btrfs_caching_control { ...@@ -1256,6 +1256,17 @@ struct btrfs_caching_control {
atomic_t count; atomic_t count;
}; };
struct btrfs_io_ctl {
void *cur, *orig;
struct page *page;
struct page **pages;
struct btrfs_root *root;
unsigned long size;
int index;
int num_pages;
unsigned check_crcs:1;
};
struct btrfs_block_group_cache { struct btrfs_block_group_cache {
struct btrfs_key key; struct btrfs_key key;
struct btrfs_block_group_item item; struct btrfs_block_group_item item;
......
...@@ -271,18 +271,7 @@ static int readahead_cache(struct inode *inode) ...@@ -271,18 +271,7 @@ static int readahead_cache(struct inode *inode)
return 0; return 0;
} }
struct io_ctl { static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
void *cur, *orig;
struct page *page;
struct page **pages;
struct btrfs_root *root;
unsigned long size;
int index;
int num_pages;
unsigned check_crcs:1;
};
static int io_ctl_init(struct io_ctl *io_ctl, struct inode *inode,
struct btrfs_root *root, int write) struct btrfs_root *root, int write)
{ {
int num_pages; int num_pages;
...@@ -298,7 +287,7 @@ static int io_ctl_init(struct io_ctl *io_ctl, struct inode *inode, ...@@ -298,7 +287,7 @@ static int io_ctl_init(struct io_ctl *io_ctl, struct inode *inode,
(num_pages * sizeof(u32)) >= PAGE_CACHE_SIZE) (num_pages * sizeof(u32)) >= PAGE_CACHE_SIZE)
return -ENOSPC; return -ENOSPC;
memset(io_ctl, 0, sizeof(struct io_ctl)); memset(io_ctl, 0, sizeof(struct btrfs_io_ctl));
io_ctl->pages = kcalloc(num_pages, sizeof(struct page *), GFP_NOFS); io_ctl->pages = kcalloc(num_pages, sizeof(struct page *), GFP_NOFS);
if (!io_ctl->pages) if (!io_ctl->pages)
...@@ -311,12 +300,12 @@ static int io_ctl_init(struct io_ctl *io_ctl, struct inode *inode, ...@@ -311,12 +300,12 @@ static int io_ctl_init(struct io_ctl *io_ctl, struct inode *inode,
return 0; return 0;
} }
static void io_ctl_free(struct io_ctl *io_ctl) static void io_ctl_free(struct btrfs_io_ctl *io_ctl)
{ {
kfree(io_ctl->pages); kfree(io_ctl->pages);
} }
static void io_ctl_unmap_page(struct io_ctl *io_ctl) static void io_ctl_unmap_page(struct btrfs_io_ctl *io_ctl)
{ {
if (io_ctl->cur) { if (io_ctl->cur) {
kunmap(io_ctl->page); kunmap(io_ctl->page);
...@@ -325,7 +314,7 @@ static void io_ctl_unmap_page(struct io_ctl *io_ctl) ...@@ -325,7 +314,7 @@ static void io_ctl_unmap_page(struct io_ctl *io_ctl)
} }
} }
static void io_ctl_map_page(struct io_ctl *io_ctl, int clear) static void io_ctl_map_page(struct btrfs_io_ctl *io_ctl, int clear)
{ {
ASSERT(io_ctl->index < io_ctl->num_pages); ASSERT(io_ctl->index < io_ctl->num_pages);
io_ctl->page = io_ctl->pages[io_ctl->index++]; io_ctl->page = io_ctl->pages[io_ctl->index++];
...@@ -336,7 +325,7 @@ static void io_ctl_map_page(struct io_ctl *io_ctl, int clear) ...@@ -336,7 +325,7 @@ static void io_ctl_map_page(struct io_ctl *io_ctl, int clear)
memset(io_ctl->cur, 0, PAGE_CACHE_SIZE); memset(io_ctl->cur, 0, PAGE_CACHE_SIZE);
} }
static void io_ctl_drop_pages(struct io_ctl *io_ctl) static void io_ctl_drop_pages(struct btrfs_io_ctl *io_ctl)
{ {
int i; int i;
...@@ -351,7 +340,7 @@ static void io_ctl_drop_pages(struct io_ctl *io_ctl) ...@@ -351,7 +340,7 @@ static void io_ctl_drop_pages(struct io_ctl *io_ctl)
} }
} }
static int io_ctl_prepare_pages(struct io_ctl *io_ctl, struct inode *inode, static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, struct inode *inode,
int uptodate) int uptodate)
{ {
struct page *page; struct page *page;
...@@ -385,7 +374,7 @@ static int io_ctl_prepare_pages(struct io_ctl *io_ctl, struct inode *inode, ...@@ -385,7 +374,7 @@ static int io_ctl_prepare_pages(struct io_ctl *io_ctl, struct inode *inode,
return 0; return 0;
} }
static void io_ctl_set_generation(struct io_ctl *io_ctl, u64 generation) static void io_ctl_set_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
{ {
__le64 *val; __le64 *val;
...@@ -408,7 +397,7 @@ static void io_ctl_set_generation(struct io_ctl *io_ctl, u64 generation) ...@@ -408,7 +397,7 @@ static void io_ctl_set_generation(struct io_ctl *io_ctl, u64 generation)
io_ctl->cur += sizeof(u64); io_ctl->cur += sizeof(u64);
} }
static int io_ctl_check_generation(struct io_ctl *io_ctl, u64 generation) static int io_ctl_check_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
{ {
__le64 *gen; __le64 *gen;
...@@ -437,7 +426,7 @@ static int io_ctl_check_generation(struct io_ctl *io_ctl, u64 generation) ...@@ -437,7 +426,7 @@ static int io_ctl_check_generation(struct io_ctl *io_ctl, u64 generation)
return 0; return 0;
} }
static void io_ctl_set_crc(struct io_ctl *io_ctl, int index) static void io_ctl_set_crc(struct btrfs_io_ctl *io_ctl, int index)
{ {
u32 *tmp; u32 *tmp;
u32 crc = ~(u32)0; u32 crc = ~(u32)0;
...@@ -461,7 +450,7 @@ static void io_ctl_set_crc(struct io_ctl *io_ctl, int index) ...@@ -461,7 +450,7 @@ static void io_ctl_set_crc(struct io_ctl *io_ctl, int index)
kunmap(io_ctl->pages[0]); kunmap(io_ctl->pages[0]);
} }
static int io_ctl_check_crc(struct io_ctl *io_ctl, int index) static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index)
{ {
u32 *tmp, val; u32 *tmp, val;
u32 crc = ~(u32)0; u32 crc = ~(u32)0;
...@@ -494,7 +483,7 @@ static int io_ctl_check_crc(struct io_ctl *io_ctl, int index) ...@@ -494,7 +483,7 @@ static int io_ctl_check_crc(struct io_ctl *io_ctl, int index)
return 0; return 0;
} }
static int io_ctl_add_entry(struct io_ctl *io_ctl, u64 offset, u64 bytes, static int io_ctl_add_entry(struct btrfs_io_ctl *io_ctl, u64 offset, u64 bytes,
void *bitmap) void *bitmap)
{ {
struct btrfs_free_space_entry *entry; struct btrfs_free_space_entry *entry;
...@@ -524,7 +513,7 @@ static int io_ctl_add_entry(struct io_ctl *io_ctl, u64 offset, u64 bytes, ...@@ -524,7 +513,7 @@ static int io_ctl_add_entry(struct io_ctl *io_ctl, u64 offset, u64 bytes,
return 0; return 0;
} }
static int io_ctl_add_bitmap(struct io_ctl *io_ctl, void *bitmap) static int io_ctl_add_bitmap(struct btrfs_io_ctl *io_ctl, void *bitmap)
{ {
if (!io_ctl->cur) if (!io_ctl->cur)
return -ENOSPC; return -ENOSPC;
...@@ -547,7 +536,7 @@ static int io_ctl_add_bitmap(struct io_ctl *io_ctl, void *bitmap) ...@@ -547,7 +536,7 @@ static int io_ctl_add_bitmap(struct io_ctl *io_ctl, void *bitmap)
return 0; return 0;
} }
static void io_ctl_zero_remaining_pages(struct io_ctl *io_ctl) static void io_ctl_zero_remaining_pages(struct btrfs_io_ctl *io_ctl)
{ {
/* /*
* If we're not on the boundary we know we've modified the page and we * If we're not on the boundary we know we've modified the page and we
...@@ -564,7 +553,7 @@ static void io_ctl_zero_remaining_pages(struct io_ctl *io_ctl) ...@@ -564,7 +553,7 @@ static void io_ctl_zero_remaining_pages(struct io_ctl *io_ctl)
} }
} }
static int io_ctl_read_entry(struct io_ctl *io_ctl, static int io_ctl_read_entry(struct btrfs_io_ctl *io_ctl,
struct btrfs_free_space *entry, u8 *type) struct btrfs_free_space *entry, u8 *type)
{ {
struct btrfs_free_space_entry *e; struct btrfs_free_space_entry *e;
...@@ -591,7 +580,7 @@ static int io_ctl_read_entry(struct io_ctl *io_ctl, ...@@ -591,7 +580,7 @@ static int io_ctl_read_entry(struct io_ctl *io_ctl,
return 0; return 0;
} }
static int io_ctl_read_bitmap(struct io_ctl *io_ctl, static int io_ctl_read_bitmap(struct btrfs_io_ctl *io_ctl,
struct btrfs_free_space *entry) struct btrfs_free_space *entry)
{ {
int ret; int ret;
...@@ -650,7 +639,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode, ...@@ -650,7 +639,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
{ {
struct btrfs_free_space_header *header; struct btrfs_free_space_header *header;
struct extent_buffer *leaf; struct extent_buffer *leaf;
struct io_ctl io_ctl; struct btrfs_io_ctl io_ctl;
struct btrfs_key key; struct btrfs_key key;
struct btrfs_free_space *e, *n; struct btrfs_free_space *e, *n;
LIST_HEAD(bitmaps); LIST_HEAD(bitmaps);
...@@ -879,7 +868,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, ...@@ -879,7 +868,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
} }
static noinline_for_stack static noinline_for_stack
int write_cache_extent_entries(struct io_ctl *io_ctl, int write_cache_extent_entries(struct btrfs_io_ctl *io_ctl,
struct btrfs_free_space_ctl *ctl, struct btrfs_free_space_ctl *ctl,
struct btrfs_block_group_cache *block_group, struct btrfs_block_group_cache *block_group,
int *entries, int *bitmaps, int *entries, int *bitmaps,
...@@ -1002,7 +991,7 @@ update_cache_item(struct btrfs_trans_handle *trans, ...@@ -1002,7 +991,7 @@ update_cache_item(struct btrfs_trans_handle *trans,
static noinline_for_stack int static noinline_for_stack int
write_pinned_extent_entries(struct btrfs_root *root, write_pinned_extent_entries(struct btrfs_root *root,
struct btrfs_block_group_cache *block_group, struct btrfs_block_group_cache *block_group,
struct io_ctl *io_ctl, struct btrfs_io_ctl *io_ctl,
int *entries) int *entries)
{ {
u64 start, extent_start, extent_end, len; u64 start, extent_start, extent_end, len;
...@@ -1052,7 +1041,7 @@ write_pinned_extent_entries(struct btrfs_root *root, ...@@ -1052,7 +1041,7 @@ write_pinned_extent_entries(struct btrfs_root *root,
} }
static noinline_for_stack int static noinline_for_stack int
write_bitmap_entries(struct io_ctl *io_ctl, struct list_head *bitmap_list) write_bitmap_entries(struct btrfs_io_ctl *io_ctl, struct list_head *bitmap_list)
{ {
struct list_head *pos, *n; struct list_head *pos, *n;
int ret; int ret;
...@@ -1086,7 +1075,7 @@ static int flush_dirty_cache(struct inode *inode) ...@@ -1086,7 +1075,7 @@ static int flush_dirty_cache(struct inode *inode)
static void noinline_for_stack static void noinline_for_stack
cleanup_write_cache_enospc(struct inode *inode, cleanup_write_cache_enospc(struct inode *inode,
struct io_ctl *io_ctl, struct btrfs_io_ctl *io_ctl,
struct extent_state **cached_state, struct extent_state **cached_state,
struct list_head *bitmap_list) struct list_head *bitmap_list)
{ {
...@@ -1123,7 +1112,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, ...@@ -1123,7 +1112,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
struct btrfs_path *path, u64 offset) struct btrfs_path *path, u64 offset)
{ {
struct extent_state *cached_state = NULL; struct extent_state *cached_state = NULL;
struct io_ctl io_ctl; struct btrfs_io_ctl io_ctl;
LIST_HEAD(bitmap_list); LIST_HEAD(bitmap_list);
int entries = 0; int entries = 0;
int bitmaps = 0; int bitmaps = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment