Commit 57bbddd7 authored by Chris Mason's avatar Chris Mason

Merge branch 'cleanup/blocksize-diet-part2' of...

Merge branch 'cleanup/blocksize-diet-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus
parents d3541834 ce3e6984
...@@ -1371,8 +1371,7 @@ tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct btrfs_path *path, ...@@ -1371,8 +1371,7 @@ tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct btrfs_path *path,
if (tm->op == MOD_LOG_KEY_REMOVE_WHILE_FREEING) { if (tm->op == MOD_LOG_KEY_REMOVE_WHILE_FREEING) {
BUG_ON(tm->slot != 0); BUG_ON(tm->slot != 0);
eb_rewin = alloc_dummy_extent_buffer(eb->start, eb_rewin = alloc_dummy_extent_buffer(fs_info, eb->start);
fs_info->tree_root->nodesize);
if (!eb_rewin) { if (!eb_rewin) {
btrfs_tree_read_unlock_blocking(eb); btrfs_tree_read_unlock_blocking(eb);
free_extent_buffer(eb); free_extent_buffer(eb);
...@@ -1452,7 +1451,7 @@ get_old_root(struct btrfs_root *root, u64 time_seq) ...@@ -1452,7 +1451,7 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
} else if (old_root) { } else if (old_root) {
btrfs_tree_read_unlock(eb_root); btrfs_tree_read_unlock(eb_root);
free_extent_buffer(eb_root); free_extent_buffer(eb_root);
eb = alloc_dummy_extent_buffer(logical, root->nodesize); eb = alloc_dummy_extent_buffer(root->fs_info, logical);
} else { } else {
btrfs_set_lock_blocking_rw(eb_root, BTRFS_READ_LOCK); btrfs_set_lock_blocking_rw(eb_root, BTRFS_READ_LOCK);
eb = btrfs_clone_extent_buffer(eb_root); eb = btrfs_clone_extent_buffer(eb_root);
...@@ -2290,7 +2289,7 @@ static void reada_for_search(struct btrfs_root *root, ...@@ -2290,7 +2289,7 @@ static void reada_for_search(struct btrfs_root *root,
if ((search <= target && target - search <= 65536) || if ((search <= target && target - search <= 65536) ||
(search > target && search - target <= 65536)) { (search > target && search - target <= 65536)) {
gen = btrfs_node_ptr_generation(node, nr); gen = btrfs_node_ptr_generation(node, nr);
readahead_tree_block(root, search, blocksize); readahead_tree_block(root, search);
nread += blocksize; nread += blocksize;
} }
nscan++; nscan++;
...@@ -2309,7 +2308,6 @@ static noinline void reada_for_balance(struct btrfs_root *root, ...@@ -2309,7 +2308,6 @@ static noinline void reada_for_balance(struct btrfs_root *root,
u64 gen; u64 gen;
u64 block1 = 0; u64 block1 = 0;
u64 block2 = 0; u64 block2 = 0;
int blocksize;
parent = path->nodes[level + 1]; parent = path->nodes[level + 1];
if (!parent) if (!parent)
...@@ -2317,7 +2315,6 @@ static noinline void reada_for_balance(struct btrfs_root *root, ...@@ -2317,7 +2315,6 @@ static noinline void reada_for_balance(struct btrfs_root *root,
nritems = btrfs_header_nritems(parent); nritems = btrfs_header_nritems(parent);
slot = path->slots[level + 1]; slot = path->slots[level + 1];
blocksize = root->nodesize;
if (slot > 0) { if (slot > 0) {
block1 = btrfs_node_blockptr(parent, slot - 1); block1 = btrfs_node_blockptr(parent, slot - 1);
...@@ -2342,9 +2339,9 @@ static noinline void reada_for_balance(struct btrfs_root *root, ...@@ -2342,9 +2339,9 @@ static noinline void reada_for_balance(struct btrfs_root *root,
} }
if (block1) if (block1)
readahead_tree_block(root, block1, blocksize); readahead_tree_block(root, block1);
if (block2) if (block2)
readahead_tree_block(root, block2, blocksize); readahead_tree_block(root, block2);
} }
......
...@@ -1073,12 +1073,12 @@ static const struct address_space_operations btree_aops = { ...@@ -1073,12 +1073,12 @@ static const struct address_space_operations btree_aops = {
.set_page_dirty = btree_set_page_dirty, .set_page_dirty = btree_set_page_dirty,
}; };
void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize) void readahead_tree_block(struct btrfs_root *root, u64 bytenr)
{ {
struct extent_buffer *buf = NULL; struct extent_buffer *buf = NULL;
struct inode *btree_inode = root->fs_info->btree_inode; struct inode *btree_inode = root->fs_info->btree_inode;
buf = btrfs_find_create_tree_block(root, bytenr, blocksize); buf = btrfs_find_create_tree_block(root, bytenr);
if (!buf) if (!buf)
return; return;
read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree, read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree,
...@@ -1086,7 +1086,7 @@ void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize) ...@@ -1086,7 +1086,7 @@ void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize)
free_extent_buffer(buf); free_extent_buffer(buf);
} }
int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize, int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr,
int mirror_num, struct extent_buffer **eb) int mirror_num, struct extent_buffer **eb)
{ {
struct extent_buffer *buf = NULL; struct extent_buffer *buf = NULL;
...@@ -1094,7 +1094,7 @@ int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize, ...@@ -1094,7 +1094,7 @@ int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize,
struct extent_io_tree *io_tree = &BTRFS_I(btree_inode)->io_tree; struct extent_io_tree *io_tree = &BTRFS_I(btree_inode)->io_tree;
int ret; int ret;
buf = btrfs_find_create_tree_block(root, bytenr, blocksize); buf = btrfs_find_create_tree_block(root, bytenr);
if (!buf) if (!buf)
return 0; return 0;
...@@ -1125,12 +1125,11 @@ struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, ...@@ -1125,12 +1125,11 @@ struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root,
} }
struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
u64 bytenr, u32 blocksize) u64 bytenr)
{ {
if (btrfs_test_is_dummy_root(root)) if (btrfs_test_is_dummy_root(root))
return alloc_test_extent_buffer(root->fs_info, bytenr, return alloc_test_extent_buffer(root->fs_info, bytenr);
blocksize); return alloc_extent_buffer(root->fs_info, bytenr);
return alloc_extent_buffer(root->fs_info, bytenr, blocksize);
} }
...@@ -1152,7 +1151,7 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, ...@@ -1152,7 +1151,7 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
struct extent_buffer *buf = NULL; struct extent_buffer *buf = NULL;
int ret; int ret;
buf = btrfs_find_create_tree_block(root, bytenr, root->nodesize); buf = btrfs_find_create_tree_block(root, bytenr);
if (!buf) if (!buf)
return NULL; return NULL;
......
...@@ -46,11 +46,11 @@ struct btrfs_fs_devices; ...@@ -46,11 +46,11 @@ struct btrfs_fs_devices;
struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
u64 parent_transid); u64 parent_transid);
void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize); void readahead_tree_block(struct btrfs_root *root, u64 bytenr);
int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize, int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr,
int mirror_num, struct extent_buffer **eb); int mirror_num, struct extent_buffer **eb);
struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
u64 bytenr, u32 blocksize); u64 bytenr);
void clean_tree_block(struct btrfs_trans_handle *trans, void clean_tree_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct extent_buffer *buf); struct btrfs_root *root, struct extent_buffer *buf);
int open_ctree(struct super_block *sb, int open_ctree(struct super_block *sb,
......
...@@ -7149,11 +7149,11 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, ...@@ -7149,11 +7149,11 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
static struct extent_buffer * static struct extent_buffer *
btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root, btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root,
u64 bytenr, u32 blocksize, int level) u64 bytenr, int level)
{ {
struct extent_buffer *buf; struct extent_buffer *buf;
buf = btrfs_find_create_tree_block(root, bytenr, blocksize); buf = btrfs_find_create_tree_block(root, bytenr);
if (!buf) if (!buf)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
btrfs_set_header_generation(buf, trans->transid); btrfs_set_header_generation(buf, trans->transid);
...@@ -7272,7 +7272,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, ...@@ -7272,7 +7272,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
if (btrfs_test_is_dummy_root(root)) { if (btrfs_test_is_dummy_root(root)) {
buf = btrfs_init_new_buffer(trans, root, root->alloc_bytenr, buf = btrfs_init_new_buffer(trans, root, root->alloc_bytenr,
blocksize, level); level);
if (!IS_ERR(buf)) if (!IS_ERR(buf))
root->alloc_bytenr += blocksize; root->alloc_bytenr += blocksize;
return buf; return buf;
...@@ -7289,8 +7289,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, ...@@ -7289,8 +7289,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
return ERR_PTR(ret); return ERR_PTR(ret);
} }
buf = btrfs_init_new_buffer(trans, root, ins.objectid, buf = btrfs_init_new_buffer(trans, root, ins.objectid, level);
blocksize, level);
BUG_ON(IS_ERR(buf)); /* -ENOMEM */ BUG_ON(IS_ERR(buf)); /* -ENOMEM */
if (root_objectid == BTRFS_TREE_RELOC_OBJECTID) { if (root_objectid == BTRFS_TREE_RELOC_OBJECTID) {
...@@ -7419,7 +7418,7 @@ static noinline void reada_walk_down(struct btrfs_trans_handle *trans, ...@@ -7419,7 +7418,7 @@ static noinline void reada_walk_down(struct btrfs_trans_handle *trans,
continue; continue;
} }
reada: reada:
readahead_tree_block(root, bytenr, blocksize); readahead_tree_block(root, bytenr);
nread++; nread++;
} }
wc->reada_slot = slot; wc->reada_slot = slot;
...@@ -7760,7 +7759,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans, ...@@ -7760,7 +7759,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
next = btrfs_find_tree_block(root, bytenr); next = btrfs_find_tree_block(root, bytenr);
if (!next) { if (!next) {
next = btrfs_find_create_tree_block(root, bytenr, blocksize); next = btrfs_find_create_tree_block(root, bytenr);
if (!next) if (!next)
return -ENOMEM; return -ENOMEM;
btrfs_set_buffer_lockdep_class(root->root_key.objectid, next, btrfs_set_buffer_lockdep_class(root->root_key.objectid, next,
......
...@@ -4598,11 +4598,11 @@ static inline void btrfs_release_extent_buffer(struct extent_buffer *eb) ...@@ -4598,11 +4598,11 @@ static inline void btrfs_release_extent_buffer(struct extent_buffer *eb)
static struct extent_buffer * static struct extent_buffer *
__alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start, __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start,
unsigned long len, gfp_t mask) unsigned long len)
{ {
struct extent_buffer *eb = NULL; struct extent_buffer *eb = NULL;
eb = kmem_cache_zalloc(extent_buffer_cache, mask); eb = kmem_cache_zalloc(extent_buffer_cache, GFP_NOFS);
if (eb == NULL) if (eb == NULL)
return NULL; return NULL;
eb->start = start; eb->start = start;
...@@ -4643,7 +4643,7 @@ struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src) ...@@ -4643,7 +4643,7 @@ struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src)
struct extent_buffer *new; struct extent_buffer *new;
unsigned long num_pages = num_extent_pages(src->start, src->len); unsigned long num_pages = num_extent_pages(src->start, src->len);
new = __alloc_extent_buffer(NULL, src->start, src->len, GFP_NOFS); new = __alloc_extent_buffer(src->fs_info, src->start, src->len);
if (new == NULL) if (new == NULL)
return NULL; return NULL;
...@@ -4666,13 +4666,26 @@ struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src) ...@@ -4666,13 +4666,26 @@ struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src)
return new; return new;
} }
struct extent_buffer *alloc_dummy_extent_buffer(u64 start, unsigned long len) struct extent_buffer *alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,
u64 start)
{ {
struct extent_buffer *eb; struct extent_buffer *eb;
unsigned long num_pages = num_extent_pages(0, len); unsigned long len;
unsigned long num_pages;
unsigned long i; unsigned long i;
eb = __alloc_extent_buffer(NULL, start, len, GFP_NOFS); if (!fs_info) {
/*
* Called only from tests that don't always have a fs_info
* available, but we know that nodesize is 4096
*/
len = 4096;
} else {
len = fs_info->tree_root->nodesize;
}
num_pages = num_extent_pages(0, len);
eb = __alloc_extent_buffer(fs_info, start, len);
if (!eb) if (!eb)
return NULL; return NULL;
...@@ -4762,7 +4775,7 @@ struct extent_buffer *find_extent_buffer(struct btrfs_fs_info *fs_info, ...@@ -4762,7 +4775,7 @@ struct extent_buffer *find_extent_buffer(struct btrfs_fs_info *fs_info,
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
u64 start, unsigned long len) u64 start)
{ {
struct extent_buffer *eb, *exists = NULL; struct extent_buffer *eb, *exists = NULL;
int ret; int ret;
...@@ -4770,7 +4783,7 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, ...@@ -4770,7 +4783,7 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
eb = find_extent_buffer(fs_info, start); eb = find_extent_buffer(fs_info, start);
if (eb) if (eb)
return eb; return eb;
eb = alloc_dummy_extent_buffer(start, len); eb = alloc_dummy_extent_buffer(fs_info, start);
if (!eb) if (!eb)
return NULL; return NULL;
eb->fs_info = fs_info; eb->fs_info = fs_info;
...@@ -4808,8 +4821,9 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, ...@@ -4808,8 +4821,9 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
#endif #endif
struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
u64 start, unsigned long len) u64 start)
{ {
unsigned long len = fs_info->tree_root->nodesize;
unsigned long num_pages = num_extent_pages(start, len); unsigned long num_pages = num_extent_pages(start, len);
unsigned long i; unsigned long i;
unsigned long index = start >> PAGE_CACHE_SHIFT; unsigned long index = start >> PAGE_CACHE_SHIFT;
...@@ -4824,7 +4838,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, ...@@ -4824,7 +4838,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
if (eb) if (eb)
return eb; return eb;
eb = __alloc_extent_buffer(fs_info, start, len, GFP_NOFS); eb = __alloc_extent_buffer(fs_info, start, len);
if (!eb) if (!eb)
return NULL; return NULL;
......
...@@ -262,8 +262,9 @@ int get_state_private(struct extent_io_tree *tree, u64 start, u64 *private); ...@@ -262,8 +262,9 @@ int get_state_private(struct extent_io_tree *tree, u64 start, u64 *private);
void set_page_extent_mapped(struct page *page); void set_page_extent_mapped(struct page *page);
struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
u64 start, unsigned long len); u64 start);
struct extent_buffer *alloc_dummy_extent_buffer(u64 start, unsigned long len); struct extent_buffer *alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,
u64 start);
struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src); struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src);
struct extent_buffer *find_extent_buffer(struct btrfs_fs_info *fs_info, struct extent_buffer *find_extent_buffer(struct btrfs_fs_info *fs_info,
u64 start); u64 start);
...@@ -377,5 +378,5 @@ noinline u64 find_lock_delalloc_range(struct inode *inode, ...@@ -377,5 +378,5 @@ noinline u64 find_lock_delalloc_range(struct inode *inode,
u64 *end, u64 max_bytes); u64 *end, u64 max_bytes);
#endif #endif
struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
u64 start, unsigned long len); u64 start);
#endif #endif
...@@ -66,7 +66,6 @@ struct reada_extctl { ...@@ -66,7 +66,6 @@ struct reada_extctl {
struct reada_extent { struct reada_extent {
u64 logical; u64 logical;
struct btrfs_key top; struct btrfs_key top;
u32 blocksize;
int err; int err;
struct list_head extctl; struct list_head extctl;
int refcnt; int refcnt;
...@@ -349,7 +348,6 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root, ...@@ -349,7 +348,6 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
blocksize = root->nodesize; blocksize = root->nodesize;
re->logical = logical; re->logical = logical;
re->blocksize = blocksize;
re->top = *top; re->top = *top;
INIT_LIST_HEAD(&re->extctl); INIT_LIST_HEAD(&re->extctl);
spin_lock_init(&re->lock); spin_lock_init(&re->lock);
...@@ -660,7 +658,6 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info, ...@@ -660,7 +658,6 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
int mirror_num = 0; int mirror_num = 0;
struct extent_buffer *eb = NULL; struct extent_buffer *eb = NULL;
u64 logical; u64 logical;
u32 blocksize;
int ret; int ret;
int i; int i;
int need_kick = 0; int need_kick = 0;
...@@ -694,7 +691,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info, ...@@ -694,7 +691,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
spin_unlock(&fs_info->reada_lock); spin_unlock(&fs_info->reada_lock);
return 0; return 0;
} }
dev->reada_next = re->logical + re->blocksize; dev->reada_next = re->logical + fs_info->tree_root->nodesize;
re->refcnt++; re->refcnt++;
spin_unlock(&fs_info->reada_lock); spin_unlock(&fs_info->reada_lock);
...@@ -709,7 +706,6 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info, ...@@ -709,7 +706,6 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
} }
} }
logical = re->logical; logical = re->logical;
blocksize = re->blocksize;
spin_lock(&re->lock); spin_lock(&re->lock);
if (re->scheduled_for == NULL) { if (re->scheduled_for == NULL) {
...@@ -724,8 +720,8 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info, ...@@ -724,8 +720,8 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
return 0; return 0;
atomic_inc(&dev->reada_in_flight); atomic_inc(&dev->reada_in_flight);
ret = reada_tree_block_flagged(fs_info->extent_root, logical, blocksize, ret = reada_tree_block_flagged(fs_info->extent_root, logical,
mirror_num, &eb); mirror_num, &eb);
if (ret) if (ret)
__readahead_hook(fs_info->extent_root, NULL, logical, ret); __readahead_hook(fs_info->extent_root, NULL, logical, ret);
else if (eb) else if (eb)
...@@ -851,7 +847,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) ...@@ -851,7 +847,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
break; break;
printk(KERN_DEBUG printk(KERN_DEBUG
" re: logical %llu size %u empty %d for %lld", " re: logical %llu size %u empty %d for %lld",
re->logical, re->blocksize, re->logical, fs_info->tree_root->nodesize,
list_empty(&re->extctl), re->scheduled_for ? list_empty(&re->extctl), re->scheduled_for ?
re->scheduled_for->devid : -1); re->scheduled_for->devid : -1);
...@@ -886,7 +882,8 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) ...@@ -886,7 +882,8 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
} }
printk(KERN_DEBUG printk(KERN_DEBUG
"re: logical %llu size %u list empty %d for %lld", "re: logical %llu size %u list empty %d for %lld",
re->logical, re->blocksize, list_empty(&re->extctl), re->logical, fs_info->tree_root->nodesize,
list_empty(&re->extctl),
re->scheduled_for ? re->scheduled_for->devid : -1); re->scheduled_for ? re->scheduled_for->devid : -1);
for (i = 0; i < re->nzones; ++i) { for (i = 0; i < re->nzones; ++i) {
printk(KERN_CONT " zone %llu-%llu devs", printk(KERN_CONT " zone %llu-%llu devs",
......
...@@ -2855,9 +2855,10 @@ static void update_processed_blocks(struct reloc_control *rc, ...@@ -2855,9 +2855,10 @@ static void update_processed_blocks(struct reloc_control *rc,
} }
} }
static int tree_block_processed(u64 bytenr, u32 blocksize, static int tree_block_processed(u64 bytenr, struct reloc_control *rc)
struct reloc_control *rc)
{ {
u32 blocksize = rc->extent_root->nodesize;
if (test_range_bit(&rc->processed_blocks, bytenr, if (test_range_bit(&rc->processed_blocks, bytenr,
bytenr + blocksize - 1, EXTENT_DIRTY, 1, NULL)) bytenr + blocksize - 1, EXTENT_DIRTY, 1, NULL))
return 1; return 1;
...@@ -2965,8 +2966,7 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans, ...@@ -2965,8 +2966,7 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans,
while (rb_node) { while (rb_node) {
block = rb_entry(rb_node, struct tree_block, rb_node); block = rb_entry(rb_node, struct tree_block, rb_node);
if (!block->key_ready) if (!block->key_ready)
readahead_tree_block(rc->extent_root, block->bytenr, readahead_tree_block(rc->extent_root, block->bytenr);
block->key.objectid);
rb_node = rb_next(rb_node); rb_node = rb_next(rb_node);
} }
...@@ -3353,7 +3353,7 @@ static int __add_tree_block(struct reloc_control *rc, ...@@ -3353,7 +3353,7 @@ static int __add_tree_block(struct reloc_control *rc,
bool skinny = btrfs_fs_incompat(rc->extent_root->fs_info, bool skinny = btrfs_fs_incompat(rc->extent_root->fs_info,
SKINNY_METADATA); SKINNY_METADATA);
if (tree_block_processed(bytenr, blocksize, rc)) if (tree_block_processed(bytenr, rc))
return 0; return 0;
if (tree_search(blocks, bytenr)) if (tree_search(blocks, bytenr))
...@@ -3611,7 +3611,7 @@ static int find_data_references(struct reloc_control *rc, ...@@ -3611,7 +3611,7 @@ static int find_data_references(struct reloc_control *rc,
if (added) if (added)
goto next; goto next;
if (!tree_block_processed(leaf->start, leaf->len, rc)) { if (!tree_block_processed(leaf->start, rc)) {
block = kmalloc(sizeof(*block), GFP_NOFS); block = kmalloc(sizeof(*block), GFP_NOFS);
if (!block) { if (!block) {
err = -ENOMEM; err = -ENOMEM;
......
...@@ -53,7 +53,7 @@ static int test_btrfs_split_item(void) ...@@ -53,7 +53,7 @@ static int test_btrfs_split_item(void)
return -ENOMEM; return -ENOMEM;
} }
path->nodes[0] = eb = alloc_dummy_extent_buffer(0, 4096); path->nodes[0] = eb = alloc_dummy_extent_buffer(NULL, 4096);
if (!eb) { if (!eb) {
test_msg("Could not allocate dummy buffer\n"); test_msg("Could not allocate dummy buffer\n");
ret = -ENOMEM; ret = -ENOMEM;
......
...@@ -255,7 +255,7 @@ static noinline int test_btrfs_get_extent(void) ...@@ -255,7 +255,7 @@ static noinline int test_btrfs_get_extent(void)
goto out; goto out;
} }
root->node = alloc_dummy_extent_buffer(0, 4096); root->node = alloc_dummy_extent_buffer(NULL, 4096);
if (!root->node) { if (!root->node) {
test_msg("Couldn't allocate dummy buffer\n"); test_msg("Couldn't allocate dummy buffer\n");
goto out; goto out;
...@@ -843,7 +843,7 @@ static int test_hole_first(void) ...@@ -843,7 +843,7 @@ static int test_hole_first(void)
goto out; goto out;
} }
root->node = alloc_dummy_extent_buffer(0, 4096); root->node = alloc_dummy_extent_buffer(NULL, 4096);
if (!root->node) { if (!root->node) {
test_msg("Couldn't allocate dummy buffer\n"); test_msg("Couldn't allocate dummy buffer\n");
goto out; goto out;
......
...@@ -404,12 +404,22 @@ int btrfs_test_qgroups(void) ...@@ -404,12 +404,22 @@ int btrfs_test_qgroups(void)
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
/* We are using this root as our extent root */
root->fs_info->extent_root = root;
/*
* Some of the paths we test assume we have a filled out fs_info, so we
* just need to add the root in there so we don't panic.
*/
root->fs_info->tree_root = root;
root->fs_info->quota_root = root;
root->fs_info->quota_enabled = 1;
/* /*
* Can't use bytenr 0, some things freak out * Can't use bytenr 0, some things freak out
* *cough*backref walking code*cough* * *cough*backref walking code*cough*
*/ */
root->node = alloc_test_extent_buffer(root->fs_info, 4096, 4096); root->node = alloc_test_extent_buffer(root->fs_info, 4096);
if (!root->node) { if (!root->node) {
test_msg("Couldn't allocate dummy buffer\n"); test_msg("Couldn't allocate dummy buffer\n");
ret = -ENOMEM; ret = -ENOMEM;
...@@ -448,17 +458,6 @@ int btrfs_test_qgroups(void) ...@@ -448,17 +458,6 @@ int btrfs_test_qgroups(void)
goto out; goto out;
} }
/* We are using this root as our extent root */
root->fs_info->extent_root = root;
/*
* Some of the paths we test assume we have a filled out fs_info, so we
* just need to addt he root in there so we don't panic.
*/
root->fs_info->tree_root = root;
root->fs_info->quota_root = root;
root->fs_info->quota_enabled = 1;
test_msg("Running qgroup tests\n"); test_msg("Running qgroup tests\n");
ret = test_no_shared_qgroup(root); ret = test_no_shared_qgroup(root);
if (ret) if (ret)
......
...@@ -2165,7 +2165,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, ...@@ -2165,7 +2165,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
parent = path->nodes[*level]; parent = path->nodes[*level];
root_owner = btrfs_header_owner(parent); root_owner = btrfs_header_owner(parent);
next = btrfs_find_create_tree_block(root, bytenr, blocksize); next = btrfs_find_create_tree_block(root, bytenr);
if (!next) if (!next)
return -ENOMEM; return -ENOMEM;
......
...@@ -6247,8 +6247,13 @@ int btrfs_read_sys_array(struct btrfs_root *root) ...@@ -6247,8 +6247,13 @@ int btrfs_read_sys_array(struct btrfs_root *root)
u32 cur; u32 cur;
struct btrfs_key key; struct btrfs_key key;
sb = btrfs_find_create_tree_block(root, BTRFS_SUPER_INFO_OFFSET, ASSERT(BTRFS_SUPER_INFO_SIZE <= root->nodesize);
BTRFS_SUPER_INFO_SIZE); /*
* This will create extent buffer of nodesize, superblock size is
* fixed to BTRFS_SUPER_INFO_SIZE. If nodesize > sb size, this will
* overallocate but we can keep it as-is, only the first page is used.
*/
sb = btrfs_find_create_tree_block(root, BTRFS_SUPER_INFO_OFFSET);
if (!sb) if (!sb)
return -ENOMEM; return -ENOMEM;
btrfs_set_buffer_uptodate(sb); btrfs_set_buffer_uptodate(sb);
......
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