Skip to content

Commit

Permalink
btrfs: move struct io_ctl into ctree.h and rename it
Browse files Browse the repository at this point in the history
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: Chris Mason <[email protected]>
  • Loading branch information
masoncl committed Apr 10, 2015
1 parent 3bce876 commit 4c6d1d8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
11 changes: 11 additions & 0 deletions fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,17 @@ struct btrfs_caching_control {
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_key key;
struct btrfs_block_group_item item;
Expand Down
55 changes: 22 additions & 33 deletions fs/btrfs/free-space-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,18 +271,7 @@ static int readahead_cache(struct inode *inode)
return 0;
}

struct 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;
};

static int io_ctl_init(struct io_ctl *io_ctl, struct inode *inode,
static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
struct btrfs_root *root, int write)
{
int num_pages;
Expand All @@ -298,7 +287,7 @@ static int io_ctl_init(struct io_ctl *io_ctl, struct inode *inode,
(num_pages * sizeof(u32)) >= PAGE_CACHE_SIZE)
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);
if (!io_ctl->pages)
Expand All @@ -311,12 +300,12 @@ static int io_ctl_init(struct io_ctl *io_ctl, struct inode *inode,
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);
}

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) {
kunmap(io_ctl->page);
Expand All @@ -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);
io_ctl->page = io_ctl->pages[io_ctl->index++];
Expand All @@ -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);
}

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;

Expand All @@ -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)
{
struct page *page;
Expand Down Expand Up @@ -385,7 +374,7 @@ static int io_ctl_prepare_pages(struct io_ctl *io_ctl, struct inode *inode,
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;

Expand All @@ -408,7 +397,7 @@ static void io_ctl_set_generation(struct io_ctl *io_ctl, u64 generation)
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;

Expand Down Expand Up @@ -437,7 +426,7 @@ static int io_ctl_check_generation(struct io_ctl *io_ctl, u64 generation)
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 crc = ~(u32)0;
Expand All @@ -461,7 +450,7 @@ static void io_ctl_set_crc(struct io_ctl *io_ctl, int index)
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 crc = ~(u32)0;
Expand Down Expand Up @@ -494,7 +483,7 @@ static int io_ctl_check_crc(struct io_ctl *io_ctl, int index)
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)
{
struct btrfs_free_space_entry *entry;
Expand Down Expand Up @@ -524,7 +513,7 @@ static int io_ctl_add_entry(struct io_ctl *io_ctl, u64 offset, u64 bytes,
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)
return -ENOSPC;
Expand All @@ -547,7 +536,7 @@ static int io_ctl_add_bitmap(struct io_ctl *io_ctl, void *bitmap)
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
Expand All @@ -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 *e;
Expand All @@ -591,7 +580,7 @@ static int io_ctl_read_entry(struct io_ctl *io_ctl,
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)
{
int ret;
Expand Down Expand Up @@ -650,7 +639,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
{
struct btrfs_free_space_header *header;
struct extent_buffer *leaf;
struct io_ctl io_ctl;
struct btrfs_io_ctl io_ctl;
struct btrfs_key key;
struct btrfs_free_space *e, *n;
LIST_HEAD(bitmaps);
Expand Down Expand Up @@ -879,7 +868,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
}

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_block_group_cache *block_group,
int *entries, int *bitmaps,
Expand Down Expand Up @@ -1002,7 +991,7 @@ update_cache_item(struct btrfs_trans_handle *trans,
static noinline_for_stack int
write_pinned_extent_entries(struct btrfs_root *root,
struct btrfs_block_group_cache *block_group,
struct io_ctl *io_ctl,
struct btrfs_io_ctl *io_ctl,
int *entries)
{
u64 start, extent_start, extent_end, len;
Expand Down Expand Up @@ -1052,7 +1041,7 @@ write_pinned_extent_entries(struct btrfs_root *root,
}

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;
int ret;
Expand Down Expand Up @@ -1086,7 +1075,7 @@ static int flush_dirty_cache(struct inode *inode)

static void noinline_for_stack
cleanup_write_cache_enospc(struct inode *inode,
struct io_ctl *io_ctl,
struct btrfs_io_ctl *io_ctl,
struct extent_state **cached_state,
struct list_head *bitmap_list)
{
Expand Down Expand Up @@ -1123,7 +1112,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
struct btrfs_path *path, u64 offset)
{
struct extent_state *cached_state = NULL;
struct io_ctl io_ctl;
struct btrfs_io_ctl io_ctl;
LIST_HEAD(bitmap_list);
int entries = 0;
int bitmaps = 0;
Expand Down

0 comments on commit 4c6d1d8

Please sign in to comment.