Commit 2ff7e61e authored by Jeff Mahoney's avatar Jeff Mahoney Committed by David Sterba

btrfs: take an fs_info directly when the root is not used otherwise

There are loads of functions in btrfs that accept a root parameter
but only use it to obtain an fs_info pointer.  Let's convert those to
just accept an fs_info pointer directly.
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent afdb5718
...@@ -788,8 +788,7 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info, ...@@ -788,8 +788,7 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info,
if (ref->key_for_search.type) if (ref->key_for_search.type)
continue; continue;
BUG_ON(!ref->wanted_disk_byte); BUG_ON(!ref->wanted_disk_byte);
eb = read_tree_block(fs_info->tree_root, ref->wanted_disk_byte, eb = read_tree_block(fs_info, ref->wanted_disk_byte, 0);
0);
if (IS_ERR(eb)) { if (IS_ERR(eb)) {
return PTR_ERR(eb); return PTR_ERR(eb);
} else if (!extent_buffer_uptodate(eb)) { } else if (!extent_buffer_uptodate(eb)) {
...@@ -1405,8 +1404,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, ...@@ -1405,8 +1404,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
ref->level == 0) { ref->level == 0) {
struct extent_buffer *eb; struct extent_buffer *eb;
eb = read_tree_block(fs_info->extent_root, eb = read_tree_block(fs_info, ref->parent, 0);
ref->parent, 0);
if (IS_ERR(eb)) { if (IS_ERR(eb)) {
ret = PTR_ERR(eb); ret = PTR_ERR(eb);
goto out; goto out;
......
...@@ -2904,14 +2904,13 @@ int btrfsic_submit_bio_wait(struct bio *bio) ...@@ -2904,14 +2904,13 @@ int btrfsic_submit_bio_wait(struct bio *bio)
return submit_bio_wait(bio); return submit_bio_wait(bio);
} }
int btrfsic_mount(struct btrfs_root *root, int btrfsic_mount(struct btrfs_fs_info *fs_info,
struct btrfs_fs_devices *fs_devices, struct btrfs_fs_devices *fs_devices,
int including_extent_data, u32 print_mask) int including_extent_data, u32 print_mask)
{ {
int ret; int ret;
struct btrfsic_state *state; struct btrfsic_state *state;
struct list_head *dev_head = &fs_devices->devices; struct list_head *dev_head = &fs_devices->devices;
struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_device *device; struct btrfs_device *device;
if (fs_info->nodesize & ((u64)PAGE_SIZE - 1)) { if (fs_info->nodesize & ((u64)PAGE_SIZE - 1)) {
...@@ -2939,7 +2938,7 @@ int btrfsic_mount(struct btrfs_root *root, ...@@ -2939,7 +2938,7 @@ int btrfsic_mount(struct btrfs_root *root,
btrfsic_is_initialized = 1; btrfsic_is_initialized = 1;
} }
mutex_lock(&btrfsic_mutex); mutex_lock(&btrfsic_mutex);
state->fs_info = root->fs_info; state->fs_info = fs_info;
state->print_mask = print_mask; state->print_mask = print_mask;
state->include_extent_data = including_extent_data; state->include_extent_data = including_extent_data;
state->csum_size = 0; state->csum_size = 0;
...@@ -2977,7 +2976,7 @@ int btrfsic_mount(struct btrfs_root *root, ...@@ -2977,7 +2976,7 @@ int btrfsic_mount(struct btrfs_root *root,
ret = btrfsic_process_superblock(state, fs_devices); ret = btrfsic_process_superblock(state, fs_devices);
if (0 != ret) { if (0 != ret) {
mutex_unlock(&btrfsic_mutex); mutex_unlock(&btrfsic_mutex);
btrfsic_unmount(root, fs_devices); btrfsic_unmount(fs_devices);
return ret; return ret;
} }
...@@ -2990,8 +2989,7 @@ int btrfsic_mount(struct btrfs_root *root, ...@@ -2990,8 +2989,7 @@ int btrfsic_mount(struct btrfs_root *root,
return 0; return 0;
} }
void btrfsic_unmount(struct btrfs_root *root, void btrfsic_unmount(struct btrfs_fs_devices *fs_devices)
struct btrfs_fs_devices *fs_devices)
{ {
struct btrfsic_block *b_all, *tmp_all; struct btrfsic_block *b_all, *tmp_all;
struct btrfsic_state *state; struct btrfsic_state *state;
......
...@@ -29,10 +29,9 @@ int btrfsic_submit_bio_wait(struct bio *bio); ...@@ -29,10 +29,9 @@ int btrfsic_submit_bio_wait(struct bio *bio);
#define btrfsic_submit_bio_wait submit_bio_wait #define btrfsic_submit_bio_wait submit_bio_wait
#endif #endif
int btrfsic_mount(struct btrfs_root *root, int btrfsic_mount(struct btrfs_fs_info *fs_info,
struct btrfs_fs_devices *fs_devices, struct btrfs_fs_devices *fs_devices,
int including_extent_data, u32 print_mask); int including_extent_data, u32 print_mask);
void btrfsic_unmount(struct btrfs_root *root, void btrfsic_unmount(struct btrfs_fs_devices *fs_devices);
struct btrfs_fs_devices *fs_devices);
#endif #endif
...@@ -85,10 +85,9 @@ static int btrfs_decompress_bio(int type, struct page **pages_in, ...@@ -85,10 +85,9 @@ static int btrfs_decompress_bio(int type, struct page **pages_in,
u64 disk_start, struct bio *orig_bio, u64 disk_start, struct bio *orig_bio,
size_t srclen); size_t srclen);
static inline int compressed_bio_size(struct btrfs_root *root, static inline int compressed_bio_size(struct btrfs_fs_info *fs_info,
unsigned long disk_size) unsigned long disk_size)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
u16 csum_size = btrfs_super_csum_size(fs_info->super_copy); u16 csum_size = btrfs_super_csum_size(fs_info->super_copy);
return sizeof(struct compressed_bio) + return sizeof(struct compressed_bio) +
...@@ -331,7 +330,6 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -331,7 +330,6 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
struct bio *bio = NULL; struct bio *bio = NULL;
struct btrfs_root *root = BTRFS_I(inode)->root;
struct compressed_bio *cb; struct compressed_bio *cb;
unsigned long bytes_left; unsigned long bytes_left;
struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
...@@ -343,7 +341,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -343,7 +341,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
int skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM; int skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
WARN_ON(start & ((u64)PAGE_SIZE - 1)); WARN_ON(start & ((u64)PAGE_SIZE - 1));
cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS); cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS);
if (!cb) if (!cb)
return -ENOMEM; return -ENOMEM;
atomic_set(&cb->pending_bios, 0); atomic_set(&cb->pending_bios, 0);
...@@ -398,12 +396,11 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -398,12 +396,11 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
if (!skip_sum) { if (!skip_sum) {
ret = btrfs_csum_one_bio(root, inode, bio, ret = btrfs_csum_one_bio(inode, bio, start, 1);
start, 1);
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
} }
ret = btrfs_map_bio(root, bio, 0, 1); ret = btrfs_map_bio(fs_info, bio, 0, 1);
if (ret) { if (ret) {
bio->bi_error = ret; bio->bi_error = ret;
bio_endio(bio); bio_endio(bio);
...@@ -433,11 +430,11 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -433,11 +430,11 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
if (!skip_sum) { if (!skip_sum) {
ret = btrfs_csum_one_bio(root, inode, bio, start, 1); ret = btrfs_csum_one_bio(inode, bio, start, 1);
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
} }
ret = btrfs_map_bio(root, bio, 0, 1); ret = btrfs_map_bio(fs_info, bio, 0, 1);
if (ret) { if (ret) {
bio->bi_error = ret; bio->bi_error = ret;
bio_endio(bio); bio_endio(bio);
...@@ -581,7 +578,6 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, ...@@ -581,7 +578,6 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
struct extent_io_tree *tree; struct extent_io_tree *tree;
struct extent_map_tree *em_tree; struct extent_map_tree *em_tree;
struct compressed_bio *cb; struct compressed_bio *cb;
struct btrfs_root *root = BTRFS_I(inode)->root;
unsigned long compressed_len; unsigned long compressed_len;
unsigned long nr_pages; unsigned long nr_pages;
unsigned long pg_index; unsigned long pg_index;
...@@ -609,7 +605,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, ...@@ -609,7 +605,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
return -EIO; return -EIO;
compressed_len = em->block_len; compressed_len = em->block_len;
cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS); cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS);
if (!cb) if (!cb)
goto out; goto out;
...@@ -694,14 +690,14 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, ...@@ -694,14 +690,14 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
atomic_inc(&cb->pending_bios); atomic_inc(&cb->pending_bios);
if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) { if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
ret = btrfs_lookup_bio_sums(root, inode, ret = btrfs_lookup_bio_sums(inode, comp_bio,
comp_bio, sums); sums);
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
} }
sums += DIV_ROUND_UP(comp_bio->bi_iter.bi_size, sums += DIV_ROUND_UP(comp_bio->bi_iter.bi_size,
fs_info->sectorsize); fs_info->sectorsize);
ret = btrfs_map_bio(root, comp_bio, mirror_num, 0); ret = btrfs_map_bio(fs_info, comp_bio, mirror_num, 0);
if (ret) { if (ret) {
comp_bio->bi_error = ret; comp_bio->bi_error = ret;
bio_endio(comp_bio); bio_endio(comp_bio);
...@@ -726,11 +722,11 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, ...@@ -726,11 +722,11 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) { if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
ret = btrfs_lookup_bio_sums(root, inode, comp_bio, sums); ret = btrfs_lookup_bio_sums(inode, comp_bio, sums);
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
} }
ret = btrfs_map_bio(root, comp_bio, mirror_num, 0); ret = btrfs_map_bio(fs_info, comp_bio, mirror_num, 0);
if (ret) { if (ret) {
comp_bio->bi_error = ret; comp_bio->bi_error = ret;
bio_endio(comp_bio); bio_endio(comp_bio);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -99,23 +99,24 @@ static inline void btrfs_init_delayed_root( ...@@ -99,23 +99,24 @@ static inline void btrfs_init_delayed_root(
} }
int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans, int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans,
struct btrfs_root *root, const char *name, struct btrfs_fs_info *fs_info,
int name_len, struct inode *dir, const char *name, int name_len,
struct inode *dir,
struct btrfs_disk_key *disk_key, u8 type, struct btrfs_disk_key *disk_key, u8 type,
u64 index); u64 index);
int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans, int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct inode *dir, struct btrfs_fs_info *fs_info,
u64 index); struct inode *dir, u64 index);
int btrfs_inode_delayed_dir_index_count(struct inode *inode); int btrfs_inode_delayed_dir_index_count(struct inode *inode);
int btrfs_run_delayed_items(struct btrfs_trans_handle *trans, int btrfs_run_delayed_items(struct btrfs_trans_handle *trans,
struct btrfs_root *root); struct btrfs_fs_info *fs_info);
int btrfs_run_delayed_items_nr(struct btrfs_trans_handle *trans, int btrfs_run_delayed_items_nr(struct btrfs_trans_handle *trans,
struct btrfs_root *root, int nr); struct btrfs_fs_info *fs_info, int nr);
void btrfs_balance_delayed_items(struct btrfs_root *root); void btrfs_balance_delayed_items(struct btrfs_fs_info *fs_info);
int btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans, int btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans,
struct inode *inode); struct inode *inode);
......
...@@ -304,11 +304,11 @@ void btrfs_after_dev_replace_commit(struct btrfs_fs_info *fs_info) ...@@ -304,11 +304,11 @@ void btrfs_after_dev_replace_commit(struct btrfs_fs_info *fs_info)
dev_replace->cursor_left_last_write_of_item; dev_replace->cursor_left_last_write_of_item;
} }
int btrfs_dev_replace_start(struct btrfs_root *root, char *tgtdev_name, int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, char *tgtdev_name,
u64 srcdevid, char *srcdev_name, int read_src) u64 srcdevid, char *srcdev_name, int read_src)
{ {
struct btrfs_root *root = fs_info->dev_root;
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
int ret; int ret;
struct btrfs_device *tgt_device = NULL; struct btrfs_device *tgt_device = NULL;
...@@ -316,14 +316,14 @@ int btrfs_dev_replace_start(struct btrfs_root *root, char *tgtdev_name, ...@@ -316,14 +316,14 @@ int btrfs_dev_replace_start(struct btrfs_root *root, char *tgtdev_name,
/* the disk copy procedure reuses the scrub code */ /* the disk copy procedure reuses the scrub code */
mutex_lock(&fs_info->volume_mutex); mutex_lock(&fs_info->volume_mutex);
ret = btrfs_find_device_by_devspec(root, srcdevid, ret = btrfs_find_device_by_devspec(fs_info, srcdevid,
srcdev_name, &src_device); srcdev_name, &src_device);
if (ret) { if (ret) {
mutex_unlock(&fs_info->volume_mutex); mutex_unlock(&fs_info->volume_mutex);
return ret; return ret;
} }
ret = btrfs_init_dev_replace_tgtdev(root, tgtdev_name, ret = btrfs_init_dev_replace_tgtdev(fs_info, tgtdev_name,
src_device, &tgt_device); src_device, &tgt_device);
mutex_unlock(&fs_info->volume_mutex); mutex_unlock(&fs_info->volume_mutex);
if (ret) if (ret)
...@@ -422,7 +422,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root, char *tgtdev_name, ...@@ -422,7 +422,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root, char *tgtdev_name,
return ret; return ret;
} }
int btrfs_dev_replace_by_ioctl(struct btrfs_root *root, int btrfs_dev_replace_by_ioctl(struct btrfs_fs_info *fs_info,
struct btrfs_ioctl_dev_replace_args *args) struct btrfs_ioctl_dev_replace_args *args)
{ {
int ret; int ret;
...@@ -439,7 +439,7 @@ int btrfs_dev_replace_by_ioctl(struct btrfs_root *root, ...@@ -439,7 +439,7 @@ int btrfs_dev_replace_by_ioctl(struct btrfs_root *root,
args->start.tgtdev_name[0] == '\0') args->start.tgtdev_name[0] == '\0')
return -EINVAL; return -EINVAL;
ret = btrfs_dev_replace_start(root, args->start.tgtdev_name, ret = btrfs_dev_replace_start(fs_info, args->start.tgtdev_name,
args->start.srcdevid, args->start.srcdevid,
args->start.srcdev_name, args->start.srcdev_name,
args->start.cont_reading_from_srcdev_mode); args->start.cont_reading_from_srcdev_mode);
......
...@@ -25,9 +25,9 @@ int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info); ...@@ -25,9 +25,9 @@ int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info);
int btrfs_run_dev_replace(struct btrfs_trans_handle *trans, int btrfs_run_dev_replace(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info); struct btrfs_fs_info *fs_info);
void btrfs_after_dev_replace_commit(struct btrfs_fs_info *fs_info); void btrfs_after_dev_replace_commit(struct btrfs_fs_info *fs_info);
int btrfs_dev_replace_by_ioctl(struct btrfs_root *root, int btrfs_dev_replace_by_ioctl(struct btrfs_fs_info *fs_info,
struct btrfs_ioctl_dev_replace_args *args); struct btrfs_ioctl_dev_replace_args *args);
int btrfs_dev_replace_start(struct btrfs_root *root, char *tgtdev_name, int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, char *tgtdev_name,
u64 srcdevid, char *srcdev_name, int read_src); u64 srcdevid, char *srcdev_name, int read_src);
void btrfs_dev_replace_status(struct btrfs_fs_info *fs_info, void btrfs_dev_replace_status(struct btrfs_fs_info *fs_info,
struct btrfs_ioctl_dev_replace_args *args); struct btrfs_ioctl_dev_replace_args *args);
......
...@@ -38,6 +38,7 @@ static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle ...@@ -38,6 +38,7 @@ static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle
const char *name, const char *name,
int name_len) int name_len)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
int ret; int ret;
char *ptr; char *ptr;
struct btrfs_item *item; struct btrfs_item *item;
...@@ -46,10 +47,10 @@ static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle ...@@ -46,10 +47,10 @@ static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle
ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size); ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size);
if (ret == -EEXIST) { if (ret == -EEXIST) {
struct btrfs_dir_item *di; struct btrfs_dir_item *di;
di = btrfs_match_dir_item_name(root, path, name, name_len); di = btrfs_match_dir_item_name(fs_info, path, name, name_len);
if (di) if (di)
return ERR_PTR(-EEXIST); return ERR_PTR(-EEXIST);
btrfs_extend_item(root, path, data_size); btrfs_extend_item(fs_info, path, data_size);
} else if (ret < 0) } else if (ret < 0)
return ERR_PTR(ret); return ERR_PTR(ret);
WARN_ON(ret > 0); WARN_ON(ret > 0);
...@@ -172,8 +173,9 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root ...@@ -172,8 +173,9 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
} }
btrfs_release_path(path); btrfs_release_path(path);
ret2 = btrfs_insert_delayed_dir_index(trans, root, name, name_len, dir, ret2 = btrfs_insert_delayed_dir_index(trans, root->fs_info, name,
&disk_key, type, index); name_len, dir, &disk_key, type,
index);
out_free: out_free:
btrfs_free_path(path); btrfs_free_path(path);
if (ret) if (ret)
...@@ -210,7 +212,7 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, ...@@ -210,7 +212,7 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
if (ret > 0) if (ret > 0)
return NULL; return NULL;
return btrfs_match_dir_item_name(root, path, name, name_len); return btrfs_match_dir_item_name(root->fs_info, path, name, name_len);
} }
int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir, int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir,
...@@ -246,7 +248,7 @@ int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir, ...@@ -246,7 +248,7 @@ int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir,
} }
/* we found an item, look for our name in the item */ /* we found an item, look for our name in the item */
di = btrfs_match_dir_item_name(root, path, name, name_len); di = btrfs_match_dir_item_name(root->fs_info, path, name, name_len);
if (di) { if (di) {
/* our exact name was found */ /* our exact name was found */
ret = -EEXIST; ret = -EEXIST;
...@@ -301,7 +303,7 @@ btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans, ...@@ -301,7 +303,7 @@ btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,
return ERR_PTR(ret); return ERR_PTR(ret);
if (ret > 0) if (ret > 0)
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
return btrfs_match_dir_item_name(root, path, name, name_len); return btrfs_match_dir_item_name(root->fs_info, path, name, name_len);
} }
struct btrfs_dir_item * struct btrfs_dir_item *
...@@ -342,7 +344,8 @@ btrfs_search_dir_index_item(struct btrfs_root *root, ...@@ -342,7 +344,8 @@ btrfs_search_dir_index_item(struct btrfs_root *root,
if (key.objectid != dirid || key.type != BTRFS_DIR_INDEX_KEY) if (key.objectid != dirid || key.type != BTRFS_DIR_INDEX_KEY)
break; break;
di = btrfs_match_dir_item_name(root, path, name, name_len); di = btrfs_match_dir_item_name(root->fs_info, path,
name, name_len);
if (di) if (di)
return di; return di;
...@@ -371,7 +374,7 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans, ...@@ -371,7 +374,7 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,
if (ret > 0) if (ret > 0)
return NULL; return NULL;
return btrfs_match_dir_item_name(root, path, name, name_len); return btrfs_match_dir_item_name(root->fs_info, path, name, name_len);
} }
/* /*
...@@ -379,7 +382,7 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans, ...@@ -379,7 +382,7 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,
* this walks through all the entries in a dir item and finds one * this walks through all the entries in a dir item and finds one
* for a specific name. * for a specific name.
*/ */
struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root, struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_fs_info *fs_info,
struct btrfs_path *path, struct btrfs_path *path,
const char *name, int name_len) const char *name, int name_len)
{ {
...@@ -392,7 +395,7 @@ struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root, ...@@ -392,7 +395,7 @@ struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root,
leaf = path->nodes[0]; leaf = path->nodes[0];
dir_item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dir_item); dir_item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dir_item);
if (verify_dir_item(root, leaf, dir_item)) if (verify_dir_item(fs_info, leaf, dir_item))
return NULL; return NULL;
total_len = btrfs_item_size_nr(leaf, path->slots[0]); total_len = btrfs_item_size_nr(leaf, path->slots[0]);
...@@ -442,16 +445,16 @@ int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans, ...@@ -442,16 +445,16 @@ int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans,
start = btrfs_item_ptr_offset(leaf, path->slots[0]); start = btrfs_item_ptr_offset(leaf, path->slots[0]);
memmove_extent_buffer(leaf, ptr, ptr + sub_item_len, memmove_extent_buffer(leaf, ptr, ptr + sub_item_len,
item_len - (ptr + sub_item_len - start)); item_len - (ptr + sub_item_len - start));
btrfs_truncate_item(root, path, item_len - sub_item_len, 1); btrfs_truncate_item(root->fs_info, path,
item_len - sub_item_len, 1);
} }
return ret; return ret;
} }
int verify_dir_item(struct btrfs_root *root, int verify_dir_item(struct btrfs_fs_info *fs_info,
struct extent_buffer *leaf, struct extent_buffer *leaf,
struct btrfs_dir_item *dir_item) struct btrfs_dir_item *dir_item)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
u16 namelen = BTRFS_NAME_LEN; u16 namelen = BTRFS_NAME_LEN;
u8 type = btrfs_dir_type(leaf, dir_item); u8 type = btrfs_dir_type(leaf, dir_item);
......
This diff is collapsed.
...@@ -44,12 +44,13 @@ static inline u64 btrfs_sb_offset(int mirror) ...@@ -44,12 +44,13 @@ static inline u64 btrfs_sb_offset(int mirror)
struct btrfs_device; struct btrfs_device;
struct btrfs_fs_devices; struct btrfs_fs_devices;
struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, struct extent_buffer *read_tree_block(struct btrfs_fs_info *fs_info,
u64 parent_transid); u64 bytenr, u64 parent_transid);
void readahead_tree_block(struct btrfs_root *root, u64 bytenr); void readahead_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr);
int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, int reada_tree_block_flagged(struct btrfs_fs_info *fs_info, 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_fs_info *fs_info,
u64 bytenr); u64 bytenr);
void clean_tree_block(struct btrfs_trans_handle *trans, void clean_tree_block(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info, struct extent_buffer *buf); struct btrfs_fs_info *fs_info, struct extent_buffer *buf);
...@@ -58,7 +59,7 @@ int open_ctree(struct super_block *sb, ...@@ -58,7 +59,7 @@ int open_ctree(struct super_block *sb,
char *options); char *options);
void close_ctree(struct btrfs_fs_info *fs_info); void close_ctree(struct btrfs_fs_info *fs_info);
int write_ctree_super(struct btrfs_trans_handle *trans, int write_ctree_super(struct btrfs_trans_handle *trans,
struct btrfs_root *root, int max_mirrors); struct btrfs_fs_info *fs_info, int max_mirrors);
struct buffer_head *btrfs_read_dev_super(struct block_device *bdev); struct buffer_head *btrfs_read_dev_super(struct block_device *bdev);
int btrfs_read_dev_one_super(struct block_device *bdev, int copy_num, int btrfs_read_dev_one_super(struct block_device *bdev, int copy_num,
struct buffer_head **bh_ret); struct buffer_head **bh_ret);
...@@ -83,8 +84,8 @@ btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info, ...@@ -83,8 +84,8 @@ btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info,
} }
int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info); int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info);
void btrfs_btree_balance_dirty(struct btrfs_root *root); void btrfs_btree_balance_dirty(struct btrfs_fs_info *fs_info);
void btrfs_btree_balance_dirty_nodelay(struct btrfs_root *root); void btrfs_btree_balance_dirty_nodelay(struct btrfs_fs_info *fs_info);
void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info, void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,
struct btrfs_root *root); struct btrfs_root *root);
void btrfs_free_fs_root(struct btrfs_root *root); void btrfs_free_fs_root(struct btrfs_root *root);
...@@ -134,9 +135,9 @@ int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans, ...@@ -134,9 +135,9 @@ int btrfs_init_log_root_tree(struct btrfs_trans_handle *trans,
int btrfs_add_log_tree(struct btrfs_trans_handle *trans, int btrfs_add_log_tree(struct btrfs_trans_handle *trans,
struct btrfs_root *root); struct btrfs_root *root);
void btrfs_cleanup_dirty_bgs(struct btrfs_transaction *trans, void btrfs_cleanup_dirty_bgs(struct btrfs_transaction *trans,
struct btrfs_root *root); struct btrfs_fs_info *fs_info);
void btrfs_cleanup_one_transaction(struct btrfs_transaction *trans, void btrfs_cleanup_one_transaction(struct btrfs_transaction *trans,
struct btrfs_root *root); struct btrfs_fs_info *fs_info);
struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info, struct btrfs_fs_info *fs_info,
u64 objectid); u64 objectid);
......
This diff is collapsed.
...@@ -2067,10 +2067,9 @@ int repair_io_failure(struct inode *inode, u64 start, u64 length, u64 logical, ...@@ -2067,10 +2067,9 @@ int repair_io_failure(struct inode *inode, u64 start, u64 length, u64 logical,
return 0; return 0;
} }
int repair_eb_io_failure(struct btrfs_root *root, struct extent_buffer *eb, int repair_eb_io_failure(struct btrfs_fs_info *fs_info,
int mirror_num) struct extent_buffer *eb, int mirror_num)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
u64 start = eb->start; u64 start = eb->start;
unsigned long i, num_pages = num_extent_pages(eb->start, eb->len); unsigned long i, num_pages = num_extent_pages(eb->start, eb->len);
int ret = 0; int ret = 0;
...@@ -3753,8 +3752,7 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb, ...@@ -3753,8 +3752,7 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb,
* header 0 1 2 .. N ... data_N .. data_2 data_1 data_0 * header 0 1 2 .. N ... data_N .. data_2 data_1 data_0
*/ */
start = btrfs_item_nr_offset(nritems); start = btrfs_item_nr_offset(nritems);
end = btrfs_leaf_data(eb) + end = btrfs_leaf_data(eb) + leaf_data_end(fs_info, eb);
leaf_data_end(fs_info->tree_root, eb);
memzero_extent_buffer(eb, start, end - start); memzero_extent_buffer(eb, start, end - start);
} }
......
...@@ -457,8 +457,8 @@ int repair_io_failure(struct inode *inode, u64 start, u64 length, u64 logical, ...@@ -457,8 +457,8 @@ int repair_io_failure(struct inode *inode, u64 start, u64 length, u64 logical,
int clean_io_failure(struct inode *inode, u64 start, struct page *page, int clean_io_failure(struct inode *inode, u64 start, struct page *page,
unsigned int pg_offset); unsigned int pg_offset);
void end_extent_writepage(struct page *page, int err, u64 start, u64 end); void end_extent_writepage(struct page *page, int err, u64 start, u64 end);
int repair_eb_io_failure(struct btrfs_root *root, struct extent_buffer *eb, int repair_eb_io_failure(struct btrfs_fs_info *fs_info,
int mirror_num); struct extent_buffer *eb, int mirror_num);
/* /*
* When IO fails, either with EIO or csum verification fails, we * When IO fails, either with EIO or csum verification fails, we
......
...@@ -160,8 +160,7 @@ static void btrfs_io_bio_endio_readpage(struct btrfs_io_bio *bio, int err) ...@@ -160,8 +160,7 @@ static void btrfs_io_bio_endio_readpage(struct btrfs_io_bio *bio, int err)
kfree(bio->csum_allocated); kfree(bio->csum_allocated);
} }
static int __btrfs_lookup_bio_sums(struct btrfs_root *root, static int __btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
struct inode *inode, struct bio *bio,
u64 logical_offset, u32 *dst, int dio) u64 logical_offset, u32 *dst, int dio)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
...@@ -304,16 +303,14 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root, ...@@ -304,16 +303,14 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root,
return 0; return 0;
} }
int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode, int btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio, u32 *dst)
struct bio *bio, u32 *dst)
{ {
return __btrfs_lookup_bio_sums(root, inode, bio, 0, dst, 0); return __btrfs_lookup_bio_sums(inode, bio, 0, dst, 0);
} }
int btrfs_lookup_bio_sums_dio(struct btrfs_root *root, struct inode *inode, int btrfs_lookup_bio_sums_dio(struct inode *inode, struct bio *bio, u64 offset)
struct bio *bio, u64 offset)
{ {
return __btrfs_lookup_bio_sums(root, inode, bio, offset, NULL, 1); return __btrfs_lookup_bio_sums(inode, bio, offset, NULL, 1);
} }
int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end, int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
...@@ -436,8 +433,8 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end, ...@@ -436,8 +433,8 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
return ret; return ret;
} }
int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode, int btrfs_csum_one_bio(struct inode *inode, struct bio *bio,
struct bio *bio, u64 file_start, int contig) u64 file_start, int contig)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
struct btrfs_ordered_sum *sums; struct btrfs_ordered_sum *sums;
...@@ -543,12 +540,11 @@ int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode, ...@@ -543,12 +540,11 @@ int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode,
* This calls btrfs_truncate_item with the correct args based on the * This calls btrfs_truncate_item with the correct args based on the
* overlap, and fixes up the key as required. * overlap, and fixes up the key as required.
*/ */
static noinline void truncate_one_csum(struct btrfs_root *root, static noinline void truncate_one_csum(struct btrfs_fs_info *fs_info,
struct btrfs_path *path, struct btrfs_path *path,
struct btrfs_key *key, struct btrfs_key *key,
u64 bytenr, u64 len) u64 bytenr, u64 len)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
struct extent_buffer *leaf; struct extent_buffer *leaf;
u16 csum_size = btrfs_super_csum_size(fs_info->super_copy); u16 csum_size = btrfs_super_csum_size(fs_info->super_copy);
u64 csum_end; u64 csum_end;
...@@ -569,7 +565,7 @@ static noinline void truncate_one_csum(struct btrfs_root *root, ...@@ -569,7 +565,7 @@ static noinline void truncate_one_csum(struct btrfs_root *root,
*/ */
u32 new_size = (bytenr - key->offset) >> blocksize_bits; u32 new_size = (bytenr - key->offset) >> blocksize_bits;
new_size *= csum_size; new_size *= csum_size;
btrfs_truncate_item(root, path, new_size, 1); btrfs_truncate_item(fs_info, path, new_size, 1);
} else if (key->offset >= bytenr && csum_end > end_byte && } else if (key->offset >= bytenr && csum_end > end_byte &&
end_byte > key->offset) { end_byte > key->offset) {
/* /*
...@@ -581,7 +577,7 @@ static noinline void truncate_one_csum(struct btrfs_root *root, ...@@ -581,7 +577,7 @@ static noinline void truncate_one_csum(struct btrfs_root *root,
u32 new_size = (csum_end - end_byte) >> blocksize_bits; u32 new_size = (csum_end - end_byte) >> blocksize_bits;
new_size *= csum_size; new_size *= csum_size;
btrfs_truncate_item(root, path, new_size, 0); btrfs_truncate_item(fs_info, path, new_size, 0);
key->offset = end_byte; key->offset = end_byte;
btrfs_set_item_key_safe(fs_info, path, key); btrfs_set_item_key_safe(fs_info, path, key);
...@@ -698,7 +694,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans, ...@@ -698,7 +694,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
key.offset = end_byte - 1; key.offset = end_byte - 1;
} else { } else {
truncate_one_csum(root, path, &key, bytenr, len); truncate_one_csum(fs_info, path, &key, bytenr, len);
if (key.offset < bytenr) if (key.offset < bytenr)
break; break;
} }
...@@ -824,11 +820,11 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, ...@@ -824,11 +820,11 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
u32 diff; u32 diff;
u32 free_space; u32 free_space;
if (btrfs_leaf_free_space(root, leaf) < if (btrfs_leaf_free_space(fs_info, leaf) <
sizeof(struct btrfs_item) + csum_size * 2) sizeof(struct btrfs_item) + csum_size * 2)
goto insert; goto insert;
free_space = btrfs_leaf_free_space(root, leaf) - free_space = btrfs_leaf_free_space(fs_info, leaf) -
sizeof(struct btrfs_item) - csum_size; sizeof(struct btrfs_item) - csum_size;
tmp = sums->len - total_bytes; tmp = sums->len - total_bytes;
tmp >>= fs_info->sb->s_blocksize_bits; tmp >>= fs_info->sb->s_blocksize_bits;
...@@ -844,7 +840,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, ...@@ -844,7 +840,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
diff /= csum_size; diff /= csum_size;
diff *= csum_size; diff *= csum_size;
btrfs_extend_item(root, path, diff); btrfs_extend_item(fs_info, path, diff);
ret = 0; ret = 0;
goto csum; goto csum;
} }
......
...@@ -129,10 +129,8 @@ static int __btrfs_add_inode_defrag(struct inode *inode, ...@@ -129,10 +129,8 @@ static int __btrfs_add_inode_defrag(struct inode *inode,
return 0; return 0;
} }
static inline int __need_auto_defrag(struct btrfs_root *root) static inline int __need_auto_defrag(struct btrfs_fs_info *fs_info)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
if (!btrfs_test_opt(fs_info, AUTO_DEFRAG)) if (!btrfs_test_opt(fs_info, AUTO_DEFRAG))
return 0; return 0;
...@@ -155,7 +153,7 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, ...@@ -155,7 +153,7 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
u64 transid; u64 transid;
int ret; int ret;
if (!__need_auto_defrag(root)) if (!__need_auto_defrag(fs_info))
return 0; return 0;
if (test_bit(BTRFS_INODE_IN_DEFRAG, &BTRFS_I(inode)->runtime_flags)) if (test_bit(BTRFS_INODE_IN_DEFRAG, &BTRFS_I(inode)->runtime_flags))
...@@ -200,10 +198,9 @@ static void btrfs_requeue_inode_defrag(struct inode *inode, ...@@ -200,10 +198,9 @@ static void btrfs_requeue_inode_defrag(struct inode *inode,
struct inode_defrag *defrag) struct inode_defrag *defrag)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
struct btrfs_root *root = BTRFS_I(inode)->root;
int ret; int ret;
if (!__need_auto_defrag(root)) if (!__need_auto_defrag(fs_info))
goto out; goto out;
/* /*
...@@ -376,7 +373,7 @@ int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info) ...@@ -376,7 +373,7 @@ int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info)
&fs_info->fs_state)) &fs_info->fs_state))
break; break;
if (!__need_auto_defrag(fs_info->tree_root)) if (!__need_auto_defrag(fs_info))
break; break;
/* find an inode to defrag */ /* find an inode to defrag */
...@@ -488,9 +485,8 @@ static void btrfs_drop_pages(struct page **pages, size_t num_pages) ...@@ -488,9 +485,8 @@ static void btrfs_drop_pages(struct page **pages, size_t num_pages)
* this also makes the decision about creating an inline extent vs * this also makes the decision about creating an inline extent vs
* doing real data extents, marking pages dirty and delalloc as required. * doing real data extents, marking pages dirty and delalloc as required.
*/ */
int btrfs_dirty_pages(struct btrfs_root *root, struct inode *inode, int btrfs_dirty_pages(struct inode *inode, struct page **pages,
struct page **pages, size_t num_pages, size_t num_pages, loff_t pos, size_t write_bytes,
loff_t pos, size_t write_bytes,
struct extent_state **cached) struct extent_state **cached)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
...@@ -860,7 +856,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -860,7 +856,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
btrfs_mark_buffer_dirty(leaf); btrfs_mark_buffer_dirty(leaf);
if (update_refs && disk_bytenr > 0) { if (update_refs && disk_bytenr > 0) {
ret = btrfs_inc_extent_ref(trans, root, ret = btrfs_inc_extent_ref(trans, fs_info,
disk_bytenr, num_bytes, 0, disk_bytenr, num_bytes, 0,
root->root_key.objectid, root->root_key.objectid,
new_key.objectid, new_key.objectid,
...@@ -944,7 +940,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -944,7 +940,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
extent_end = ALIGN(extent_end, extent_end = ALIGN(extent_end,
fs_info->sectorsize); fs_info->sectorsize);
} else if (update_refs && disk_bytenr > 0) { } else if (update_refs && disk_bytenr > 0) {
ret = btrfs_free_extent(trans, root, ret = btrfs_free_extent(trans, fs_info,
disk_bytenr, num_bytes, 0, disk_bytenr, num_bytes, 0,
root->root_key.objectid, root->root_key.objectid,
key.objectid, key.offset - key.objectid, key.offset -
...@@ -1001,7 +997,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -1001,7 +997,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
if (!ret && replace_extent && leafs_visited == 1 && if (!ret && replace_extent && leafs_visited == 1 &&
(path->locks[0] == BTRFS_WRITE_LOCK_BLOCKING || (path->locks[0] == BTRFS_WRITE_LOCK_BLOCKING ||
path->locks[0] == BTRFS_WRITE_LOCK) && path->locks[0] == BTRFS_WRITE_LOCK) &&
btrfs_leaf_free_space(root, leaf) >= btrfs_leaf_free_space(fs_info, leaf) >=
sizeof(struct btrfs_item) + extent_item_size) { sizeof(struct btrfs_item) + extent_item_size) {
key.objectid = ino; key.objectid = ino;
...@@ -1238,8 +1234,8 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -1238,8 +1234,8 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
extent_end - split); extent_end - split);
btrfs_mark_buffer_dirty(leaf); btrfs_mark_buffer_dirty(leaf);
ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0, ret = btrfs_inc_extent_ref(trans, fs_info, bytenr, num_bytes,
root->root_key.objectid, 0, root->root_key.objectid,
ino, orig_offset); ino, orig_offset);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
...@@ -1272,7 +1268,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -1272,7 +1268,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
extent_end = other_end; extent_end = other_end;
del_slot = path->slots[0] + 1; del_slot = path->slots[0] + 1;
del_nr++; del_nr++;
ret = btrfs_free_extent(trans, root, bytenr, num_bytes, ret = btrfs_free_extent(trans, fs_info, bytenr, num_bytes,
0, root->root_key.objectid, 0, root->root_key.objectid,
ino, orig_offset); ino, orig_offset);
if (ret) { if (ret) {
...@@ -1292,7 +1288,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -1292,7 +1288,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
key.offset = other_start; key.offset = other_start;
del_slot = path->slots[0]; del_slot = path->slots[0];
del_nr++; del_nr++;
ret = btrfs_free_extent(trans, root, bytenr, num_bytes, ret = btrfs_free_extent(trans, fs_info, bytenr, num_bytes,
0, root->root_key.objectid, 0, root->root_key.objectid,
ino, orig_offset); ino, orig_offset);
if (ret) { if (ret) {
...@@ -1698,9 +1694,8 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, ...@@ -1698,9 +1694,8 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
fs_info->sectorsize); fs_info->sectorsize);
if (copied > 0) if (copied > 0)
ret = btrfs_dirty_pages(root, inode, pages, ret = btrfs_dirty_pages(inode, pages, dirty_pages,
dirty_pages, pos, copied, pos, copied, NULL);
NULL);
if (need_unlock) if (need_unlock)
unlock_extent_cached(&BTRFS_I(inode)->io_tree, unlock_extent_cached(&BTRFS_I(inode)->io_tree,
lockstart, lockend, &cached_state, lockstart, lockend, &cached_state,
...@@ -1732,7 +1727,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, ...@@ -1732,7 +1727,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
balance_dirty_pages_ratelimited(inode->i_mapping); balance_dirty_pages_ratelimited(inode->i_mapping);
if (dirty_pages < (fs_info->nodesize >> PAGE_SHIFT) + 1) if (dirty_pages < (fs_info->nodesize >> PAGE_SHIFT) + 1)
btrfs_btree_balance_dirty(root); btrfs_btree_balance_dirty(fs_info);
pos += copied; pos += copied;
num_written += copied; num_written += copied;
...@@ -2519,7 +2514,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) ...@@ -2519,7 +2514,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
goto out; goto out;
} }
rsv = btrfs_alloc_block_rsv(root, BTRFS_BLOCK_RSV_TEMP); rsv = btrfs_alloc_block_rsv(fs_info, BTRFS_BLOCK_RSV_TEMP);
if (!rsv) { if (!rsv) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_free; goto out_free;
...@@ -2580,7 +2575,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) ...@@ -2580,7 +2575,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
} }
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root); btrfs_btree_balance_dirty(fs_info);
trans = btrfs_start_transaction(root, rsv_count); trans = btrfs_start_transaction(root, rsv_count);
if (IS_ERR(trans)) { if (IS_ERR(trans)) {
...@@ -2648,10 +2643,10 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) ...@@ -2648,10 +2643,10 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
updated_inode = true; updated_inode = true;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root); btrfs_btree_balance_dirty(fs_info);
out_free: out_free:
btrfs_free_path(path); btrfs_free_path(path);
btrfs_free_block_rsv(root, rsv); btrfs_free_block_rsv(fs_info, rsv);
out: out:
unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart, lockend, unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart, lockend,
&cached_state, GFP_NOFS); &cached_state, GFP_NOFS);
......
...@@ -208,10 +208,9 @@ int create_free_space_inode(struct btrfs_root *root, ...@@ -208,10 +208,9 @@ int create_free_space_inode(struct btrfs_root *root,
block_group->key.objectid); block_group->key.objectid);
} }
int btrfs_check_trunc_cache_free_space(struct btrfs_root *root, int btrfs_check_trunc_cache_free_space(struct btrfs_fs_info *fs_info,
struct btrfs_block_rsv *rsv) struct btrfs_block_rsv *rsv)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
u64 needed_bytes; u64 needed_bytes;
int ret; int ret;
...@@ -1036,12 +1035,11 @@ update_cache_item(struct btrfs_trans_handle *trans, ...@@ -1036,12 +1035,11 @@ 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_fs_info *fs_info,
struct btrfs_block_group_cache *block_group, struct btrfs_block_group_cache *block_group,
struct btrfs_io_ctl *io_ctl, struct btrfs_io_ctl *io_ctl,
int *entries) int *entries)
{ {
struct btrfs_fs_info *fs_info;
u64 start, extent_start, extent_end, len; u64 start, extent_start, extent_end, len;
struct extent_io_tree *unpin = NULL; struct extent_io_tree *unpin = NULL;
int ret; int ret;
...@@ -1049,8 +1047,6 @@ write_pinned_extent_entries(struct btrfs_root *root, ...@@ -1049,8 +1047,6 @@ write_pinned_extent_entries(struct btrfs_root *root,
if (!block_group) if (!block_group)
return 0; return 0;
fs_info = block_group->fs_info;
/* /*
* We want to add any pinned extents to our free space cache * We want to add any pinned extents to our free space cache
* so we don't leak the space * so we don't leak the space
...@@ -1243,6 +1239,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, ...@@ -1243,6 +1239,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
struct btrfs_trans_handle *trans, struct btrfs_trans_handle *trans,
struct btrfs_path *path, u64 offset) struct btrfs_path *path, u64 offset)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
struct extent_state *cached_state = NULL; struct extent_state *cached_state = NULL;
LIST_HEAD(bitmap_list); LIST_HEAD(bitmap_list);
int entries = 0; int entries = 0;
...@@ -1300,7 +1297,8 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, ...@@ -1300,7 +1297,8 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
* If this changes while we are working we'll get added back to * If this changes while we are working we'll get added back to
* the dirty list and redo it. No locking needed * the dirty list and redo it. No locking needed
*/ */
ret = write_pinned_extent_entries(root, block_group, io_ctl, &entries); ret = write_pinned_extent_entries(fs_info, block_group,
io_ctl, &entries);
if (ret) if (ret)
goto out_nospc_locked; goto out_nospc_locked;
...@@ -1319,8 +1317,8 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, ...@@ -1319,8 +1317,8 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
io_ctl_zero_remaining_pages(io_ctl); io_ctl_zero_remaining_pages(io_ctl);
/* Everything is written out, now we dirty the pages in the file. */ /* Everything is written out, now we dirty the pages in the file. */
ret = btrfs_dirty_pages(root, inode, io_ctl->pages, io_ctl->num_pages, ret = btrfs_dirty_pages(inode, io_ctl->pages, io_ctl->num_pages, 0,
0, i_size_read(inode), &cached_state); i_size_read(inode), &cached_state);
if (ret) if (ret)
goto out_nospc; goto out_nospc;
...@@ -1994,7 +1992,7 @@ static bool use_bitmap(struct btrfs_free_space_ctl *ctl, ...@@ -1994,7 +1992,7 @@ static bool use_bitmap(struct btrfs_free_space_ctl *ctl,
bool forced = false; bool forced = false;
#ifdef CONFIG_BTRFS_DEBUG #ifdef CONFIG_BTRFS_DEBUG
if (btrfs_should_fragment_free_space(fs_info->extent_root, block_group)) if (btrfs_should_fragment_free_space(block_group))
forced = true; forced = true;
#endif #endif
...@@ -3034,13 +3032,12 @@ setup_cluster_bitmap(struct btrfs_block_group_cache *block_group, ...@@ -3034,13 +3032,12 @@ setup_cluster_bitmap(struct btrfs_block_group_cache *block_group,
* returns zero and sets up cluster if things worked out, otherwise * returns zero and sets up cluster if things worked out, otherwise
* it returns -enospc * it returns -enospc
*/ */
int btrfs_find_space_cluster(struct btrfs_root *root, int btrfs_find_space_cluster(struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group, struct btrfs_block_group_cache *block_group,
struct btrfs_free_cluster *cluster, struct btrfs_free_cluster *cluster,
u64 offset, u64 bytes, u64 empty_size) u64 offset, u64 bytes, u64 empty_size)
{ {
struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;
struct btrfs_fs_info *fs_info = block_group->fs_info;
struct btrfs_free_space *entry, *tmp; struct btrfs_free_space *entry, *tmp;
LIST_HEAD(bitmaps); LIST_HEAD(bitmaps);
u64 min_bytes; u64 min_bytes;
...@@ -3148,8 +3145,7 @@ static int do_trimming(struct btrfs_block_group_cache *block_group, ...@@ -3148,8 +3145,7 @@ static int do_trimming(struct btrfs_block_group_cache *block_group,
spin_unlock(&block_group->lock); spin_unlock(&block_group->lock);
spin_unlock(&space_info->lock); spin_unlock(&space_info->lock);
ret = btrfs_discard_extent(fs_info->extent_root, ret = btrfs_discard_extent(fs_info, start, bytes, &trimmed);
start, bytes, &trimmed);
if (!ret) if (!ret)
*total_trimmed += trimmed; *total_trimmed += trimmed;
......
...@@ -59,7 +59,7 @@ int create_free_space_inode(struct btrfs_root *root, ...@@ -59,7 +59,7 @@ int create_free_space_inode(struct btrfs_root *root,
struct btrfs_block_group_cache *block_group, struct btrfs_block_group_cache *block_group,
struct btrfs_path *path); struct btrfs_path *path);
int btrfs_check_trunc_cache_free_space(struct btrfs_root *root, int btrfs_check_trunc_cache_free_space(struct btrfs_fs_info *fs_info,
struct btrfs_block_rsv *rsv); struct btrfs_block_rsv *rsv);
int btrfs_truncate_free_space_cache(struct btrfs_root *root, int btrfs_truncate_free_space_cache(struct btrfs_root *root,
struct btrfs_trans_handle *trans, struct btrfs_trans_handle *trans,
...@@ -109,7 +109,7 @@ u64 btrfs_find_space_for_alloc(struct btrfs_block_group_cache *block_group, ...@@ -109,7 +109,7 @@ u64 btrfs_find_space_for_alloc(struct btrfs_block_group_cache *block_group,
u64 btrfs_find_ino_for_alloc(struct btrfs_root *fs_root); u64 btrfs_find_ino_for_alloc(struct btrfs_root *fs_root);
void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group, void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group,
u64 bytes); u64 bytes);
int btrfs_find_space_cluster(struct btrfs_root *root, int btrfs_find_space_cluster(struct btrfs_fs_info *fs_info,
struct btrfs_block_group_cache *block_group, struct btrfs_block_group_cache *block_group,
struct btrfs_free_cluster *cluster, struct btrfs_free_cluster *cluster,
u64 offset, u64 bytes, u64 empty_size); u64 offset, u64 bytes, u64 empty_size);
......
...@@ -182,7 +182,7 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans, ...@@ -182,7 +182,7 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans,
memmove_extent_buffer(leaf, ptr, ptr + del_len, memmove_extent_buffer(leaf, ptr, ptr + del_len,
item_size - (ptr + del_len - item_start)); item_size - (ptr + del_len - item_start));
btrfs_truncate_item(root, path, item_size - del_len, 1); btrfs_truncate_item(root->fs_info, path, item_size - del_len, 1);
out: out:
btrfs_free_path(path); btrfs_free_path(path);
...@@ -245,7 +245,7 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans, ...@@ -245,7 +245,7 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
item_start = btrfs_item_ptr_offset(leaf, path->slots[0]); item_start = btrfs_item_ptr_offset(leaf, path->slots[0]);
memmove_extent_buffer(leaf, ptr, ptr + sub_item_len, memmove_extent_buffer(leaf, ptr, ptr + sub_item_len,
item_size - (ptr + sub_item_len - item_start)); item_size - (ptr + sub_item_len - item_start));
btrfs_truncate_item(root, path, item_size - sub_item_len, 1); btrfs_truncate_item(root->fs_info, path, item_size - sub_item_len, 1);
out: out:
btrfs_free_path(path); btrfs_free_path(path);
...@@ -297,7 +297,7 @@ static int btrfs_insert_inode_extref(struct btrfs_trans_handle *trans, ...@@ -297,7 +297,7 @@ static int btrfs_insert_inode_extref(struct btrfs_trans_handle *trans,
name, name_len, NULL)) name, name_len, NULL))
goto out; goto out;
btrfs_extend_item(root, path, ins_len); btrfs_extend_item(root->fs_info, path, ins_len);
ret = 0; ret = 0;
} }
if (ret < 0) if (ret < 0)
...@@ -355,7 +355,7 @@ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans, ...@@ -355,7 +355,7 @@ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
goto out; goto out;
old_size = btrfs_item_size_nr(path->nodes[0], path->slots[0]); old_size = btrfs_item_size_nr(path->nodes[0], path->slots[0]);
btrfs_extend_item(root, path, ins_len); btrfs_extend_item(fs_info, path, ins_len);
ref = btrfs_item_ptr(path->nodes[0], path->slots[0], ref = btrfs_item_ptr(path->nodes[0], path->slots[0],
struct btrfs_inode_ref); struct btrfs_inode_ref);
ref = (struct btrfs_inode_ref *)((unsigned long)ref + old_size); ref = (struct btrfs_inode_ref *)((unsigned long)ref + old_size);
......
...@@ -509,7 +509,8 @@ int btrfs_save_ino_cache(struct btrfs_root *root, ...@@ -509,7 +509,8 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
out_release: out_release:
trace_btrfs_space_reservation(fs_info, "ino_cache", trans->transid, trace_btrfs_space_reservation(fs_info, "ino_cache", trans->transid,
trans->bytes_reserved, 0); trans->bytes_reserved, 0);
btrfs_block_rsv_release(root, trans->block_rsv, trans->bytes_reserved); btrfs_block_rsv_release(fs_info, trans->block_rsv,
trans->bytes_reserved);
out: out:
trans->block_rsv = rsv; trans->block_rsv = rsv;
trans->bytes_reserved = num_bytes; trans->bytes_reserved = num_bytes;
......
This diff is collapsed.
This diff is collapsed.
...@@ -161,9 +161,8 @@ static void print_uuid_item(struct extent_buffer *l, unsigned long offset, ...@@ -161,9 +161,8 @@ static void print_uuid_item(struct extent_buffer *l, unsigned long offset,
} }
} }
void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l) void btrfs_print_leaf(struct btrfs_fs_info *fs_info, struct extent_buffer *l)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
int i; int i;
u32 type, nr; u32 type, nr;
struct btrfs_item *item; struct btrfs_item *item;
...@@ -184,7 +183,8 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l) ...@@ -184,7 +183,8 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
nr = btrfs_header_nritems(l); nr = btrfs_header_nritems(l);
btrfs_info(fs_info, "leaf %llu total ptrs %d free space %d", btrfs_info(fs_info, "leaf %llu total ptrs %d free space %d",
btrfs_header_bytenr(l), nr, btrfs_leaf_free_space(root, l)); btrfs_header_bytenr(l), nr,
btrfs_leaf_free_space(fs_info, l));
for (i = 0 ; i < nr ; i++) { for (i = 0 ; i < nr ; i++) {
item = btrfs_item_nr(i); item = btrfs_item_nr(i);
btrfs_item_key_to_cpu(l, &key, i); btrfs_item_key_to_cpu(l, &key, i);
...@@ -315,9 +315,8 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l) ...@@ -315,9 +315,8 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
} }
} }
void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c) void btrfs_print_tree(struct btrfs_fs_info *fs_info, struct extent_buffer *c)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
int i; u32 nr; int i; u32 nr;
struct btrfs_key key; struct btrfs_key key;
int level; int level;
...@@ -327,7 +326,7 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c) ...@@ -327,7 +326,7 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c)
nr = btrfs_header_nritems(c); nr = btrfs_header_nritems(c);
level = btrfs_header_level(c); level = btrfs_header_level(c);
if (level == 0) { if (level == 0) {
btrfs_print_leaf(root, c); btrfs_print_leaf(fs_info, c);
return; return;
} }
btrfs_info(fs_info, btrfs_info(fs_info,
...@@ -341,7 +340,7 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c) ...@@ -341,7 +340,7 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c)
btrfs_node_blockptr(c, i)); btrfs_node_blockptr(c, i));
} }
for (i = 0; i < nr; i++) { for (i = 0; i < nr; i++) {
struct extent_buffer *next = read_tree_block(root, struct extent_buffer *next = read_tree_block(fs_info,
btrfs_node_blockptr(c, i), btrfs_node_blockptr(c, i),
btrfs_node_ptr_generation(c, i)); btrfs_node_ptr_generation(c, i));
if (IS_ERR(next)) { if (IS_ERR(next)) {
...@@ -357,7 +356,7 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c) ...@@ -357,7 +356,7 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c)
if (btrfs_header_level(next) != if (btrfs_header_level(next) !=
level - 1) level - 1)
BUG(); BUG();
btrfs_print_tree(root, next); btrfs_print_tree(fs_info, next);
free_extent_buffer(next); free_extent_buffer(next);
} }
} }
...@@ -18,6 +18,6 @@ ...@@ -18,6 +18,6 @@
#ifndef __PRINT_TREE_ #ifndef __PRINT_TREE_
#define __PRINT_TREE_ #define __PRINT_TREE_
void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l); void btrfs_print_leaf(struct btrfs_fs_info *fs_info, struct extent_buffer *l);
void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c); void btrfs_print_tree(struct btrfs_fs_info *fs_info, struct extent_buffer *c);
#endif #endif
...@@ -301,6 +301,7 @@ static int inherit_props(struct btrfs_trans_handle *trans, ...@@ -301,6 +301,7 @@ static int inherit_props(struct btrfs_trans_handle *trans,
struct inode *parent) struct inode *parent)
{ {
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_fs_info *fs_info = root->fs_info;
int ret; int ret;
int i; int i;
...@@ -320,14 +321,14 @@ static int inherit_props(struct btrfs_trans_handle *trans, ...@@ -320,14 +321,14 @@ static int inherit_props(struct btrfs_trans_handle *trans,
if (!value) if (!value)
continue; continue;
num_bytes = btrfs_calc_trans_metadata_size(root->fs_info, 1); num_bytes = btrfs_calc_trans_metadata_size(fs_info, 1);
ret = btrfs_block_rsv_add(root, trans->block_rsv, ret = btrfs_block_rsv_add(root, trans->block_rsv,
num_bytes, BTRFS_RESERVE_NO_FLUSH); num_bytes, BTRFS_RESERVE_NO_FLUSH);
if (ret) if (ret)
goto out; goto out;
ret = __btrfs_set_prop(trans, inode, h->xattr_name, ret = __btrfs_set_prop(trans, inode, h->xattr_name,
value, strlen(value), 0); value, strlen(value), 0);
btrfs_block_rsv_release(root, trans->block_rsv, num_bytes); btrfs_block_rsv_release(fs_info, trans->block_rsv, num_bytes);
if (ret) if (ret)
goto out; goto out;
} }
......
...@@ -1509,8 +1509,7 @@ int btrfs_qgroup_trace_extent(struct btrfs_trans_handle *trans, ...@@ -1509,8 +1509,7 @@ int btrfs_qgroup_trace_extent(struct btrfs_trans_handle *trans,
record->old_roots = NULL; record->old_roots = NULL;
spin_lock(&delayed_refs->lock); spin_lock(&delayed_refs->lock);
ret = btrfs_qgroup_trace_extent_nolock(fs_info, delayed_refs, ret = btrfs_qgroup_trace_extent_nolock(fs_info, delayed_refs, record);
record);
spin_unlock(&delayed_refs->lock); spin_unlock(&delayed_refs->lock);
if (ret > 0) if (ret > 0)
kfree(record); kfree(record);
...@@ -1518,10 +1517,9 @@ int btrfs_qgroup_trace_extent(struct btrfs_trans_handle *trans, ...@@ -1518,10 +1517,9 @@ int btrfs_qgroup_trace_extent(struct btrfs_trans_handle *trans,
} }
int btrfs_qgroup_trace_leaf_items(struct btrfs_trans_handle *trans, int btrfs_qgroup_trace_leaf_items(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_fs_info *fs_info,
struct extent_buffer *eb) struct extent_buffer *eb)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
int nr = btrfs_header_nritems(eb); int nr = btrfs_header_nritems(eb);
int i, extent_type, ret; int i, extent_type, ret;
struct btrfs_key key; struct btrfs_key key;
...@@ -1645,7 +1643,7 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans, ...@@ -1645,7 +1643,7 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans,
} }
if (root_level == 0) { if (root_level == 0) {
ret = btrfs_qgroup_trace_leaf_items(trans, root, root_eb); ret = btrfs_qgroup_trace_leaf_items(trans, fs_info, root_eb);
goto out; goto out;
} }
...@@ -1683,7 +1681,7 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans, ...@@ -1683,7 +1681,7 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans,
child_bytenr = btrfs_node_blockptr(eb, parent_slot); child_bytenr = btrfs_node_blockptr(eb, parent_slot);
child_gen = btrfs_node_ptr_generation(eb, parent_slot); child_gen = btrfs_node_ptr_generation(eb, parent_slot);
eb = read_tree_block(root, child_bytenr, child_gen); eb = read_tree_block(fs_info, child_bytenr, child_gen);
if (IS_ERR(eb)) { if (IS_ERR(eb)) {
ret = PTR_ERR(eb); ret = PTR_ERR(eb);
goto out; goto out;
...@@ -1709,7 +1707,7 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans, ...@@ -1709,7 +1707,7 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans,
} }
if (level == 0) { if (level == 0) {
ret = btrfs_qgroup_trace_leaf_items(trans, root, ret = btrfs_qgroup_trace_leaf_items(trans,fs_info,
path->nodes[level]); path->nodes[level]);
if (ret) if (ret)
goto out; goto out;
......
...@@ -129,7 +129,7 @@ int btrfs_qgroup_trace_extent(struct btrfs_trans_handle *trans, ...@@ -129,7 +129,7 @@ int btrfs_qgroup_trace_extent(struct btrfs_trans_handle *trans,
* Return <0 for error(ENOMEM) * Return <0 for error(ENOMEM)
*/ */
int btrfs_qgroup_trace_leaf_items(struct btrfs_trans_handle *trans, int btrfs_qgroup_trace_leaf_items(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_fs_info *fs_info,
struct extent_buffer *eb); struct extent_buffer *eb);
/* /*
* Inform qgroup to trace a whole subtree, including all its child tree * Inform qgroup to trace a whole subtree, including all its child tree
......
...@@ -969,8 +969,9 @@ static unsigned long rbio_nr_pages(unsigned long stripe_len, int nr_stripes) ...@@ -969,8 +969,9 @@ static unsigned long rbio_nr_pages(unsigned long stripe_len, int nr_stripes)
* allocation and initial setup for the btrfs_raid_bio. Not * allocation and initial setup for the btrfs_raid_bio. Not
* this does not allocate any pages for rbio->pages. * this does not allocate any pages for rbio->pages.
*/ */
static struct btrfs_raid_bio *alloc_rbio(struct btrfs_root *root, static struct btrfs_raid_bio *alloc_rbio(struct btrfs_fs_info *fs_info,
struct btrfs_bio *bbio, u64 stripe_len) struct btrfs_bio *bbio,
u64 stripe_len)
{ {
struct btrfs_raid_bio *rbio; struct btrfs_raid_bio *rbio;
int nr_data = 0; int nr_data = 0;
...@@ -991,7 +992,7 @@ static struct btrfs_raid_bio *alloc_rbio(struct btrfs_root *root, ...@@ -991,7 +992,7 @@ static struct btrfs_raid_bio *alloc_rbio(struct btrfs_root *root,
INIT_LIST_HEAD(&rbio->stripe_cache); INIT_LIST_HEAD(&rbio->stripe_cache);
INIT_LIST_HEAD(&rbio->hash_list); INIT_LIST_HEAD(&rbio->hash_list);
rbio->bbio = bbio; rbio->bbio = bbio;
rbio->fs_info = root->fs_info; rbio->fs_info = fs_info;
rbio->stripe_len = stripe_len; rbio->stripe_len = stripe_len;
rbio->nr_pages = num_pages; rbio->nr_pages = num_pages;
rbio->real_stripes = real_stripes; rbio->real_stripes = real_stripes;
...@@ -1734,16 +1735,15 @@ static void btrfs_raid_unplug(struct blk_plug_cb *cb, bool from_schedule) ...@@ -1734,16 +1735,15 @@ static void btrfs_raid_unplug(struct blk_plug_cb *cb, bool from_schedule)
/* /*
* our main entry point for writes from the rest of the FS. * our main entry point for writes from the rest of the FS.
*/ */
int raid56_parity_write(struct btrfs_root *root, struct bio *bio, int raid56_parity_write(struct btrfs_fs_info *fs_info, struct bio *bio,
struct btrfs_bio *bbio, u64 stripe_len) struct btrfs_bio *bbio, u64 stripe_len)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_raid_bio *rbio; struct btrfs_raid_bio *rbio;
struct btrfs_plug_cb *plug = NULL; struct btrfs_plug_cb *plug = NULL;
struct blk_plug_cb *cb; struct blk_plug_cb *cb;
int ret; int ret;
rbio = alloc_rbio(root, bbio, stripe_len); rbio = alloc_rbio(fs_info, bbio, stripe_len);
if (IS_ERR(rbio)) { if (IS_ERR(rbio)) {
btrfs_put_bbio(bbio); btrfs_put_bbio(bbio);
return PTR_ERR(rbio); return PTR_ERR(rbio);
...@@ -2113,15 +2113,14 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio) ...@@ -2113,15 +2113,14 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio)
* so we assume the bio they send down corresponds to a failed part * so we assume the bio they send down corresponds to a failed part
* of the drive. * of the drive.
*/ */
int raid56_parity_recover(struct btrfs_root *root, struct bio *bio, int raid56_parity_recover(struct btrfs_fs_info *fs_info, struct bio *bio,
struct btrfs_bio *bbio, u64 stripe_len, struct btrfs_bio *bbio, u64 stripe_len,
int mirror_num, int generic_io) int mirror_num, int generic_io)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_raid_bio *rbio; struct btrfs_raid_bio *rbio;
int ret; int ret;
rbio = alloc_rbio(root, bbio, stripe_len); rbio = alloc_rbio(fs_info, bbio, stripe_len);
if (IS_ERR(rbio)) { if (IS_ERR(rbio)) {
if (generic_io) if (generic_io)
btrfs_put_bbio(bbio); btrfs_put_bbio(bbio);
...@@ -2203,16 +2202,15 @@ static void read_rebuild_work(struct btrfs_work *work) ...@@ -2203,16 +2202,15 @@ static void read_rebuild_work(struct btrfs_work *work)
*/ */
struct btrfs_raid_bio * struct btrfs_raid_bio *
raid56_parity_alloc_scrub_rbio(struct btrfs_root *root, struct bio *bio, raid56_parity_alloc_scrub_rbio(struct btrfs_fs_info *fs_info, struct bio *bio,
struct btrfs_bio *bbio, u64 stripe_len, struct btrfs_bio *bbio, u64 stripe_len,
struct btrfs_device *scrub_dev, struct btrfs_device *scrub_dev,
unsigned long *dbitmap, int stripe_nsectors) unsigned long *dbitmap, int stripe_nsectors)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_raid_bio *rbio; struct btrfs_raid_bio *rbio;
int i; int i;
rbio = alloc_rbio(root, bbio, stripe_len); rbio = alloc_rbio(fs_info, bbio, stripe_len);
if (IS_ERR(rbio)) if (IS_ERR(rbio))
return NULL; return NULL;
bio_list_add(&rbio->bio_list, bio); bio_list_add(&rbio->bio_list, bio);
...@@ -2653,12 +2651,12 @@ void raid56_parity_submit_scrub_rbio(struct btrfs_raid_bio *rbio) ...@@ -2653,12 +2651,12 @@ void raid56_parity_submit_scrub_rbio(struct btrfs_raid_bio *rbio)
/* The following code is used for dev replace of a missing RAID 5/6 device. */ /* The following code is used for dev replace of a missing RAID 5/6 device. */
struct btrfs_raid_bio * struct btrfs_raid_bio *
raid56_alloc_missing_rbio(struct btrfs_root *root, struct bio *bio, raid56_alloc_missing_rbio(struct btrfs_fs_info *fs_info, struct bio *bio,
struct btrfs_bio *bbio, u64 length) struct btrfs_bio *bbio, u64 length)
{ {
struct btrfs_raid_bio *rbio; struct btrfs_raid_bio *rbio;
rbio = alloc_rbio(root, bbio, length); rbio = alloc_rbio(fs_info, bbio, length);
if (IS_ERR(rbio)) if (IS_ERR(rbio))
return NULL; return NULL;
......
...@@ -42,24 +42,24 @@ static inline int nr_data_stripes(struct map_lookup *map) ...@@ -42,24 +42,24 @@ static inline int nr_data_stripes(struct map_lookup *map)
struct btrfs_raid_bio; struct btrfs_raid_bio;
struct btrfs_device; struct btrfs_device;
int raid56_parity_recover(struct btrfs_root *root, struct bio *bio, int raid56_parity_recover(struct btrfs_fs_info *fs_info, struct bio *bio,
struct btrfs_bio *bbio, u64 stripe_len, struct btrfs_bio *bbio, u64 stripe_len,
int mirror_num, int generic_io); int mirror_num, int generic_io);
int raid56_parity_write(struct btrfs_root *root, struct bio *bio, int raid56_parity_write(struct btrfs_fs_info *fs_info, struct bio *bio,
struct btrfs_bio *bbio, u64 stripe_len); struct btrfs_bio *bbio, u64 stripe_len);
void raid56_add_scrub_pages(struct btrfs_raid_bio *rbio, struct page *page, void raid56_add_scrub_pages(struct btrfs_raid_bio *rbio, struct page *page,
u64 logical); u64 logical);
struct btrfs_raid_bio * struct btrfs_raid_bio *
raid56_parity_alloc_scrub_rbio(struct btrfs_root *root, struct bio *bio, raid56_parity_alloc_scrub_rbio(struct btrfs_fs_info *fs_info, struct bio *bio,
struct btrfs_bio *bbio, u64 stripe_len, struct btrfs_bio *bbio, u64 stripe_len,
struct btrfs_device *scrub_dev, struct btrfs_device *scrub_dev,
unsigned long *dbitmap, int stripe_nsectors); unsigned long *dbitmap, int stripe_nsectors);
void raid56_parity_submit_scrub_rbio(struct btrfs_raid_bio *rbio); void raid56_parity_submit_scrub_rbio(struct btrfs_raid_bio *rbio);
struct btrfs_raid_bio * struct btrfs_raid_bio *
raid56_alloc_missing_rbio(struct btrfs_root *root, struct bio *bio, raid56_alloc_missing_rbio(struct btrfs_fs_info *fs_info, struct bio *bio,
struct btrfs_bio *bbio, u64 length); struct btrfs_bio *bbio, u64 length);
void raid56_submit_missing_rbio(struct btrfs_raid_bio *rbio); void raid56_submit_missing_rbio(struct btrfs_raid_bio *rbio);
......
...@@ -303,14 +303,13 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info, ...@@ -303,14 +303,13 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,
return zone; return zone;
} }
static struct reada_extent *reada_find_extent(struct btrfs_root *root, static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,
u64 logical, u64 logical,
struct btrfs_key *top) struct btrfs_key *top)
{ {
int ret; int ret;
struct reada_extent *re = NULL; struct reada_extent *re = NULL;
struct reada_extent *re_exist = NULL; struct reada_extent *re_exist = NULL;
struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_bio *bbio = NULL; struct btrfs_bio *bbio = NULL;
struct btrfs_device *dev; struct btrfs_device *dev;
struct btrfs_device *prev_dev; struct btrfs_device *prev_dev;
...@@ -549,7 +548,7 @@ static int reada_add_block(struct reada_control *rc, u64 logical, ...@@ -549,7 +548,7 @@ static int reada_add_block(struct reada_control *rc, u64 logical,
struct reada_extctl *rec; struct reada_extctl *rec;
/* takes one ref */ /* takes one ref */
re = reada_find_extent(fs_info->tree_root, logical, top); re = reada_find_extent(fs_info, logical, top);
if (!re) if (!re)
return -1; return -1;
...@@ -705,8 +704,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info, ...@@ -705,8 +704,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
logical = re->logical; logical = re->logical;
atomic_inc(&dev->reada_in_flight); atomic_inc(&dev->reada_in_flight);
ret = reada_tree_block_flagged(fs_info->extent_root, logical, ret = reada_tree_block_flagged(fs_info, logical, mirror_num, &eb);
mirror_num, &eb);
if (ret) if (ret)
__readahead_hook(fs_info, re, NULL, ret); __readahead_hook(fs_info, re, NULL, ret);
else if (eb) else if (eb)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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