misc-4.10: root->fs_info patchset
Subsystems (2)
cover misc-4.10: root->fs_info patchset
From: Jeff Mahoney <[email protected]>
Hi all -
Here's the latest version of my root->fs_info patchset. It's against Dave's misc-4.10 branch.
-Jeff
---
Jeff Mahoney (18):
btrfs: call functions that overwrite their root parameter with fs_info
btrfs: call functions that always use the same root with fs_info
instead
btrfs: btrfs_init_new_device should use fs_info->dev_root
btrfs: alloc_reserved_file_extent trace point should use extent_root
btrfs: struct btrfsic_state->root should be an fs_info
btrfs: struct reada_control.root -> reada_control.fs_info
btrfs: root->fs_info cleanup, use fs_info->dev_root everywhere
btrfs: root->fs_info cleanup, io_ctl_init
btrfs: pull node/sector/stripe sizes out of root and into fs_info
btrfs: root->fs_info cleanup, btrfs_calc_{trans,trunc}_metadata_size
btrfs: root->fs_info cleanup, lock/unlock_chunks
btrfs: root->fs_info cleanup, update_block_group{,flags}
btrfs: root->fs_info cleanup, add fs_info convenience variables
btrfs: root->fs_info cleanup, access fs_info->delayed_root directly
btrfs: convert extent-tree tracepoints to use fs_info
btrfs: simplify btrfs_wait_cache_io prototype
btrfs: take an fs_info directly when the root is not used otherwise
btrfs: split btrfs_wait_marked_extents into normal and tree log
functions
fs/btrfs/backref.c | 8 +- fs/btrfs/check-integrity.c | 73 +- fs/btrfs/check-integrity.h | 5 +- fs/btrfs/compression.c | 54 +- fs/btrfs/ctree.c | 468 ++++++------ fs/btrfs/ctree.h | 216 +++--- fs/btrfs/delayed-inode.c | 134 ++-- fs/btrfs/delayed-inode.h | 19 +- fs/btrfs/dev-replace.c | 58 +- fs/btrfs/dev-replace.h | 4 +- fs/btrfs/dir-item.c | 45 +- fs/btrfs/disk-io.c | 538 +++++++------- fs/btrfs/disk-io.h | 30 +- fs/btrfs/export.c | 10 +- fs/btrfs/extent-tree.c | 1269 ++++++++++++++++---------------- fs/btrfs/extent_io.c | 61 +- fs/btrfs/extent_io.h | 8 +- fs/btrfs/file-item.c | 152 ++-- fs/btrfs/file.c | 194 ++--- fs/btrfs/free-space-cache.c | 154 ++-- fs/btrfs/free-space-cache.h | 12 +- fs/btrfs/free-space-tree.c | 36 +- fs/btrfs/inode-item.c | 11 +- fs/btrfs/inode-map.c | 22 +- fs/btrfs/inode.c | 691 +++++++++-------- fs/btrfs/ioctl.c | 518 +++++++------ fs/btrfs/ordered-data.c | 38 +- fs/btrfs/ordered-data.h | 4 +- fs/btrfs/print-tree.c | 19 +- fs/btrfs/print-tree.h | 4 +- fs/btrfs/props.c | 5 +- fs/btrfs/qgroup.c | 56 +- fs/btrfs/qgroup.h | 2 +- fs/btrfs/raid56.c | 62 +- fs/btrfs/raid56.h | 8 +- fs/btrfs/reada.c | 34 +- fs/btrfs/relocation.c | 229 +++--- fs/btrfs/root-tree.c | 26 +- fs/btrfs/scrub.c | 157 ++-- fs/btrfs/send.c | 29 +- fs/btrfs/super.c | 130 ++-- fs/btrfs/tests/btrfs-tests.c | 13 +- fs/btrfs/tests/btrfs-tests.h | 4 +- fs/btrfs/tests/extent-buffer-tests.c | 7 +- fs/btrfs/tests/extent-io-tests.c | 5 +- fs/btrfs/tests/free-space-tests.c | 18 +- fs/btrfs/tests/free-space-tree-tests.c | 9 +- fs/btrfs/tests/inode-tests.c | 16 +- fs/btrfs/tests/qgroup-tests.c | 11 +- fs/btrfs/transaction.c | 562 +++++++------- fs/btrfs/transaction.h | 11 +- fs/btrfs/tree-log.c | 191 ++--- fs/btrfs/uuid-tree.c | 21 +- fs/btrfs/volumes.c | 753 +++++++++---------- fs/btrfs/volumes.h | 43 +- fs/btrfs/xattr.c | 19 +- include/trace/events/btrfs.h | 65 +- 57 files changed, 3745 insertions(+), 3596 deletions(-)
Signature · 1 line
2.7.1
PATCH 1/18 btrfs: call functions that overwrite their root parameter with fs_info
From: Jeff Mahoney <[email protected]>
There are 11 functions that accept a root parameter and immediately overwrite it. We can pass those an fs_info pointer instead.
--- fs/btrfs/ctree.h | 4 ++-- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/extent-tree.c | 17 +++++++------- fs/btrfs/file-item.c | 5 ++--- fs/btrfs/free-space-cache.c | 5 ++--- fs/btrfs/free-space-cache.h | 2 +- fs/btrfs/transaction.c | 9 ++++---- fs/btrfs/tree-log.c | 6 ++--- fs/btrfs/volumes.c | 55 +++++++++++++++++++++------------------------ fs/btrfs/volumes.h | 4 ++-- 10 files changed, 52 insertions(+), 59 deletions(-)
fs/btrfs/ctree.h +2 -2
@@ -2639,7 +2639,7 @@ int btrfs_setup_space_cache(struct btrfs_trans_handle *trans, struct btrfs_root *root);int btrfs_extent_readonly (struct btrfs_root *root,u64 bytenr);int btrfs_free_block_groups (struct btrfs_fs_info *info); -int btrfs_read_block_groups (struct btrfs_root *root); +int btrfs_read_block_groups (struct btrfs_fs_info *info);int btrfs_can_relocate (struct btrfs_root *root,u64 bytenr); int btrfs_make_block_group(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 bytes_used,
@@ -3055,7 +3055,7 @@ int btrfs_find_name_in_ext_backref(struct btrfs_path *path,/* file-item.c */ struct btrfs_dio_private ;int btrfs_del_csums (struct btrfs_trans_handle *trans, -struct btrfs_root *root,u64 bytenr,u64 len); +struct btrfs_fs_info *fs_info,u64 bytenr,u64 len);int btrfs_lookup_bio_sums (struct btrfs_root *root,struct inode *inode,struct bio *bio,u32 *dst); int btrfs_lookup_bio_sums_dio(struct btrfs_root *root, struct inode *inode,
fs/btrfs/disk-io.c +2 -2
@@ -2937,7 +2937,7 @@ int open_ctree(struct super_block *sb,read_extent_buffer (chunk_root->node, fs_info->chunk_tree_uuid,btrfs_header_chunk_tree_uuid (chunk_root->node),BTRFS_UUID_SIZE ); - ret =btrfs_read_chunk_tree (chunk_root); + ret =btrfs_read_chunk_tree (fs_info);if (ret) {btrfs_err (fs_info,"failed to read chunk tree: %d" , ret); goto fail_tree_roots;
@@ -3038,7 +3038,7 @@ int open_ctree(struct super_block *sb, goto fail_sysfs; } - ret =btrfs_read_block_groups (fs_info->extent_root); + ret =btrfs_read_block_groups (fs_info);if (ret) {btrfs_err (fs_info,"failed to read block groups: %d" , ret); goto fail_sysfs;
fs/btrfs/extent-tree.c +9 -8
@@ -2414,7 +2414,7 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans,btrfs_pin_extent (root, node->bytenr, node->num_bytes,1 );if (head->is_data) { - ret =btrfs_del_csums (trans, root, + ret =btrfs_del_csums (trans, root->fs_info, node->bytenr, node->num_bytes); }
@@ -3622,7 +3622,8 @@ int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans,if (cache->disk_cache_state ==BTRFS_DC_SETUP ) { cache->io_ctl.inode =NULL ; - ret =btrfs_write_out_cache (root, trans, cache, path); + ret =btrfs_write_out_cache (root->fs_info, trans, + cache, path);if (ret ==0 && cache->io_ctl.inode) { num_started++; should_put =0 ;
@@ -3774,7 +3775,8 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,if (!ret && cache->disk_cache_state ==BTRFS_DC_SETUP ) { cache->io_ctl.inode =NULL ; - ret =btrfs_write_out_cache (root, trans, cache, path); + ret =btrfs_write_out_cache (root->fs_info, trans, + cache, path);if (ret ==0 && cache->io_ctl.inode) { num_started++; should_put =0 ;
@@ -7068,7 +7070,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,btrfs_release_path (path);if (is_data) { - ret =btrfs_del_csums (trans, root, bytenr, num_bytes); + ret =btrfs_del_csums (trans, info, bytenr, num_bytes);if (ret) {btrfs_abort_transaction (trans, ret); goto out;
@@ -9925,12 +9927,12 @@ btrfs_create_block_group_cache(struct btrfs_root *root, u64 start, u64 size)return cache; } -int btrfs_read_block_groups (struct btrfs_root *root) +int btrfs_read_block_groups (struct btrfs_fs_info *info) { +struct btrfs_root *root = info->extent_root;struct btrfs_path *path;int ret;struct btrfs_block_group_cache *cache; -struct btrfs_fs_info *info = root->fs_info;struct btrfs_space_info *space_info;struct btrfs_key key;struct btrfs_key found_key;
@@ -9943,7 +9945,6 @@ int btrfs_read_block_groups(struct btrfs_root *root) feature =btrfs_super_incompat_flags (info->super_copy); mixed = !!(feature &BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS ); - root = info->extent_root; key.objectid =0 ; key.offset =0 ; key.type =BTRFS_BLOCK_GROUP_ITEM_KEY ;
@@ -10733,7 +10734,7 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)* Btrfs_remove_chunk will abort the transaction if things go * horribly wrong. */ - ret =btrfs_remove_chunk (trans, root, + ret =btrfs_remove_chunk (trans, fs_info, block_group->key.objectid);if (ret) {
fs/btrfs/file-item.c +2 -3
@@ -590,8 +590,9 @@ static noinline void truncate_one_csum(struct btrfs_root *root,* range of bytes. */ int btrfs_del_csums (struct btrfs_trans_handle *trans, -struct btrfs_root *root,u64 bytenr,u64 len) +struct btrfs_fs_info *fs_info,u64 bytenr,u64 len) { +struct btrfs_root *root = fs_info->csum_root;struct btrfs_path *path;struct btrfs_key key;u64 end_byte = bytenr + len;
@@ -601,8 +602,6 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,u16 csum_size =btrfs_super_csum_size (root->fs_info->super_copy);int blocksize_bits = root->fs_info->sb->s_blocksize_bits; - root = root->fs_info->csum_root; - path =btrfs_alloc_path ();if (!path)return -ENOMEM ;
fs/btrfs/free-space-cache.c +2 -3
@@ -1350,17 +1350,16 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, goto out; } -int btrfs_write_out_cache (struct btrfs_root *root, +int btrfs_write_out_cache (struct btrfs_fs_info *fs_info,struct btrfs_trans_handle *trans,struct btrfs_block_group_cache *block_group,struct btrfs_path *path) { +struct btrfs_root *root = fs_info->tree_root;struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;struct inode *inode;int ret =0 ; - root = root->fs_info->tree_root; -spin_lock (&block_group->lock);if (block_group->disk_cache_state <BTRFS_DC_SETUP ) {spin_unlock (&block_group->lock);
fs/btrfs/free-space-cache.h +1 -1
@@ -72,7 +72,7 @@ int btrfs_wait_cache_io(struct btrfs_root *root,struct btrfs_block_group_cache *block_group, struct btrfs_io_ctl *io_ctl, struct btrfs_path *path, u64 offset); -int btrfs_write_out_cache (struct btrfs_root *root, +int btrfs_write_out_cache (struct btrfs_fs_info *fs_info,struct btrfs_trans_handle *trans,struct btrfs_block_group_cache *block_group,struct btrfs_path *path);
fs/btrfs/transaction.c +4 -5
@@ -1219,10 +1219,9 @@ void btrfs_add_dead_root(struct btrfs_root *root)* update all the cowonly tree roots on disk */ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans, -struct btrfs_root *root) +struct btrfs_fs_info *fs_info) {struct btrfs_root *gang[8 ]; -struct btrfs_fs_info *fs_info = root->fs_info;int i;int ret;int err =0 ;
@@ -1236,7 +1235,7 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans,if (ret ==0 )break ;for (i =0 ; i < ret; i++) { - root = gang[i]; +struct btrfs_root *root = gang[i];radix_tree_tag_clear (&fs_info->fs_roots_radix, (unsigned long )root->root_key.objectid,BTRFS_ROOT_TRANS_TAG );
@@ -1343,7 +1342,7 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans,*/ mutex_lock (&fs_info->tree_log_mutex); - ret =commit_fs_roots (trans, src); + ret =commit_fs_roots (trans, fs_info);if (ret) goto out; ret =btrfs_qgroup_prepare_account_extents (trans, fs_info);
@@ -2132,7 +2131,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,*/ mutex_lock (&root->fs_info->tree_log_mutex); - ret =commit_fs_roots (trans, root); + ret =commit_fs_roots (trans, root->fs_info);if (ret) {mutex_unlock (&root->fs_info->tree_log_mutex);mutex_unlock (&root->fs_info->reloc_mutex);
fs/btrfs/tree-log.c +3 -3
@@ -797,9 +797,9 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans, list);if (!ret) ret =btrfs_del_csums (trans, - root->fs_info->csum_root, - sums->bytenr, - sums->len); + root->fs_info, + sums->bytenr, + sums->len);if (!ret) ret = btrfs_csum_file_blocks(trans, root->fs_info->csum_root,
fs/btrfs/volumes.c +25 -30
191 lines not on this page · raw message
fs/btrfs/volumes.h +2 -2
@@ -407,7 +407,7 @@ int btrfs_rmap_block(struct btrfs_fs_info *fs_info, u64 chunk_start, u64 physical, u64 devid, u64 **logical, int *naddrs, int *stripe_len);int btrfs_read_sys_array (struct btrfs_root *root); -int btrfs_read_chunk_tree (struct btrfs_root *root); +int btrfs_read_chunk_tree (struct btrfs_fs_info *fs_info);int btrfs_alloc_chunk (struct btrfs_trans_handle *trans,struct btrfs_root *extent_root,u64 type);void btrfs_mapping_init (struct btrfs_mapping_tree *tree);
@@ -483,7 +483,7 @@ int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans,struct btrfs_root *extent_root, u64 chunk_offset, u64 chunk_size);int btrfs_remove_chunk (struct btrfs_trans_handle *trans, -struct btrfs_root *root,u64 chunk_offset); +struct btrfs_fs_info *fs_info,u64 chunk_offset);static inline int btrfs_dev_stats_dirty (struct btrfs_device *dev) {
Signature · 1 line
2.7.1
Re: [PATCH 01/18] btrfs: call functions that overwrite their root parameter with fs_info
Quoted 19 lines · On Fri, Dec 02, 2016 at 12:07:21AM -0500, [email protected] wrote:
From: Jeff Mahoney <[email protected]>
There are 11 functions that accept a root parameter and immediately overwrite it. We can pass those an
fs_infopointer instead.Signed-off-by Jeff Mahoney <[email protected]>--- fs/btrfs/ctree.h | 4 ++-- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/extent-tree.c | 17 +++++++------- fs/btrfs/file-item.c | 5 ++--- fs/btrfs/free-space-cache.c | 5 ++--- fs/btrfs/free-space-cache.h | 2 +- fs/btrfs/transaction.c | 9 ++++---- fs/btrfs/tree-log.c | 6 ++--- fs/btrfs/volumes.c | 55 +++++++++++++++++++++------------------------ fs/btrfs/volumes.h | 4 ++-- 10 files changed, 52 insertions(+), 59 deletions(-)
[snip]
Quoted 9 lines
int btrfs_remove_chunk(struct
btrfs_trans_handle*trans,fs/btrfs/volumes.c +2
-1- struct btrfs_root *root, u64 chunk_offset) + struct btrfs_fs_info *fs_info, u64 chunk_offset) { +struct btrfs_root *root = fs_info->chunk_root;struct extent_map_tree *em_tree;struct extent_map *em;struct btrfs_root *extent_root = root->fs_info->extent_root;
fs/btrfs/volumes.c int btrfs_remove_chunk(struct btrfs_trans_handle *trans, · line 2814
Quoted 6 lines
fs/btrfs/volumes.c +1
-2@@ -2812,8 +2811,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices;/* Just in case */ - root = root->fs_info->chunk_root; - em_tree = &root->fs_info->mapping_tree.map_tree; + em_tree = &fs_info->mapping_tree.map_tree;
I think this "Just in case" comment was referring to the reassignment of the root, so it's just confusing now.
Re: [PATCH 01/18] btrfs: call functions that overwrite their root parameter with fs_info
Quoted 34 lines · Omar Sandoval
Quoted 19 lines · On Fri, Dec 02, 2016 at 12:07:21AM -0500, [email protected] wrote:
From: Jeff Mahoney <[email protected]>
There are 11 functions that accept a root parameter and immediately overwrite it. We can pass those an
fs_infopointer instead.Signed-off-by Jeff Mahoney <[email protected]>--- fs/btrfs/ctree.h | 4 ++-- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/extent-tree.c | 17 +++++++------- fs/btrfs/file-item.c | 5 ++--- fs/btrfs/free-space-cache.c | 5 ++--- fs/btrfs/free-space-cache.h | 2 +- fs/btrfs/transaction.c | 9 ++++---- fs/btrfs/tree-log.c | 6 ++--- fs/btrfs/volumes.c | 55 +++++++++++++++++++++------------------------ fs/btrfs/volumes.h | 4 ++-- 10 files changed, 52 insertions(+), 59 deletions(-)[snip]
Quoted 11 lines
int btrfs_remove_chunk(struct
btrfs_trans_handle*trans,fs/btrfs/volumes.c +2
-1- struct btrfs_root *root, u64 chunk_offset) + struct btrfs_fs_info *fs_info, u64 chunk_offset) { +struct btrfs_root *root = fs_info->chunk_root;struct extent_map_tree *em_tree;struct extent_map *em;struct btrfs_root *extent_root = root->fs_info->extent_root;@@ -2812,8 +2811,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices;
Quoted 7 lines
fs/btrfs/volumes.c int btrfs_remove_chunk(struct btrfs_trans_handle *trans, · line 2814
Quoted 4 lines
fs/btrfs/volumes.c +1
-2/* Just in case */ - root = root->fs_info->chunk_root; - em_tree = &root->fs_info->mapping_tree.map_tree; + em_tree = &fs_info->mapping_tree.map_tree;I think this "Just in case" comment was referring to the reassignment of the root, so it's just confusing now.
Agreed. Thanks for the review.
-Jeff
Signature · 2 lines
Jeff Mahoney SUSE Labs
PATCH 2/18 btrfs: call functions that always use the same root with fs_info instead
In reply to [email protected]From: Jeff Mahoney <[email protected]>
There are many functions that are always called with the same root argument. Rather than passing the same root every time, we can pass an fs_info pointer instead and have the function get the root pointer itself.
--- fs/btrfs/ctree.h | 16 +++++++-------- fs/btrfs/disk-io.c | 44 +++++++++++++++++++++-------------------- fs/btrfs/disk-io.h | 4 ++-- fs/btrfs/extent-tree.c | 20 ++++++++++--------- fs/btrfs/inode.c | 6 +++--- fs/btrfs/ioctl.c | 18 ++++++++--------- fs/btrfs/relocation.c | 4 ++-- fs/btrfs/root-tree.c | 9 ++++++--- fs/btrfs/super.c | 13 ++++++------ fs/btrfs/transaction.c | 6 +++--- fs/btrfs/uuid-tree.c | 10 ++++++---- fs/btrfs/volumes.c | 47 ++++++++++++++++++++++++-------------------- fs/btrfs/volumes.h | 4 ++-- include/trace/events/btrfs.h | 16 +++++++-------- 14 files changed, 115 insertions(+), 102 deletions(-)
fs/btrfs/ctree.h +8 -8
@@ -2640,7 +2640,7 @@ int btrfs_setup_space_cache(struct btrfs_trans_handle *trans,int btrfs_extent_readonly (struct btrfs_root *root,u64 bytenr);int btrfs_free_block_groups (struct btrfs_fs_info *info);int btrfs_read_block_groups (struct btrfs_fs_info *info); -int btrfs_can_relocate (struct btrfs_root *root,u64 bytenr); +int btrfs_can_relocate (struct btrfs_fs_info *fs_info,u64 bytenr); int btrfs_make_block_group(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 bytes_used, u64 type, u64 chunk_objectid, u64 chunk_offset,
@@ -2649,7 +2649,7 @@ struct btrfs_trans_handle *btrfs_start_trans_remove_block_group(struct btrfs_fs_info *fs_info, const u64 chunk_offset);int btrfs_remove_block_group (struct btrfs_trans_handle *trans, -struct btrfs_root *root,u64 group_start, +struct btrfs_fs_info *fs_info,u64 group_start,struct extent_map *em);void btrfs_delete_unused_bgs (struct btrfs_fs_info *fs_info);void btrfs_get_block_group_trimming (struct btrfs_block_group_cache *cache);
@@ -2935,11 +2935,11 @@ int btrfs_old_root_level(struct btrfs_root *root, u64 time_seq);/* root-item.c */ int btrfs_add_root_ref (struct btrfs_trans_handle *trans, -struct btrfs_root *tree_root, +struct btrfs_fs_info *fs_info,u64 root_id,u64 ref_id,u64 dirid,u64 sequence,const char *name,int name_len);int btrfs_del_root_ref (struct btrfs_trans_handle *trans, -struct btrfs_root *tree_root, +struct btrfs_fs_info *fs_info,u64 root_id,u64 ref_id,u64 dirid,u64 *sequence,const char *name,int name_len); int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
@@ -2954,7 +2954,7 @@ int __must_check btrfs_update_root(struct btrfs_trans_handle *trans,int btrfs_find_root (struct btrfs_root *root,struct btrfs_key *search_key,struct btrfs_path *path,struct btrfs_root_item *root_item,struct btrfs_key *root_key); -int btrfs_find_orphan_roots (struct btrfs_root *tree_root); +int btrfs_find_orphan_roots (struct btrfs_fs_info *fs_info);void btrfs_set_root_node (struct btrfs_root_item *item,struct extent_buffer *node);void btrfs_check_and_init_root_item (struct btrfs_root_item *item);
@@ -2963,10 +2963,10 @@ void btrfs_update_root_times(struct btrfs_trans_handle *trans,/* uuid-tree.c */ int btrfs_uuid_tree_add (struct btrfs_trans_handle *trans, -struct btrfs_root *uuid_root,u8 *uuid,u8 type, +struct btrfs_fs_info *fs_info,u8 *uuid,u8 type,u64 subid);int btrfs_uuid_tree_rem (struct btrfs_trans_handle *trans, -struct btrfs_root *uuid_root,u8 *uuid,u8 type, +struct btrfs_fs_info *fs_info,u8 *uuid,u8 type,u64 subid); int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info, int (*check_func)(struct btrfs_fs_info *, u8 *, u8,
@@ -3613,7 +3613,7 @@ static inline int btrfs_init_acl(struct btrfs_trans_handle *trans,#endif /* relocation.c */ -int btrfs_relocate_block_group (struct btrfs_root *root,u64 group_start); +int btrfs_relocate_block_group (struct btrfs_fs_info *fs_info,u64 group_start);int btrfs_init_reloc_root (struct btrfs_trans_handle *trans,struct btrfs_root *root); int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
fs/btrfs/disk-io.c +23 -21
159 lines not on this page · raw message
fs/btrfs/disk-io.h +2 -2
@@ -56,13 +56,13 @@ void clean_tree_block(struct btrfs_trans_handle *trans,int open_ctree (struct super_block *sb,struct btrfs_fs_devices *fs_devices,char *options); -void close_ctree (struct btrfs_root *root); +void close_ctree (struct btrfs_fs_info *fs_info);int write_ctree_super (struct btrfs_trans_handle *trans,struct btrfs_root *root,int max_mirrors);struct buffer_head *btrfs_read_dev_super (struct block_device *bdev);int btrfs_read_dev_one_super (struct block_device *bdev,int copy_num,struct buffer_head **bh_ret); -int btrfs_commit_super (struct btrfs_root *root); +int btrfs_commit_super (struct btrfs_fs_info *fs_info);struct btrfs_root *btrfs_read_fs_root (struct btrfs_root *tree_root,struct btrfs_key *location);int btrfs_init_fs_root (struct btrfs_root *root);
fs/btrfs/extent-tree.c +11 -9
@@ -9514,8 +9514,9 @@ void btrfs_dec_block_group_ro(struct btrfs_root *root,* @return - -1 if it's not a good idea to relocate this block group, 0 if its * ok to go ahead and try. */ -int btrfs_can_relocate (struct btrfs_root *root,u64 bytenr) +int btrfs_can_relocate (struct btrfs_fs_info *fs_info,u64 bytenr) { +struct btrfs_root *root = fs_info->extent_root;struct btrfs_block_group_cache *block_group;struct btrfs_space_info *space_info;struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices;
@@ -9659,9 +9660,11 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)return ret; } -static int find_first_block_group (struct btrfs_root *root, -struct btrfs_path *path,struct btrfs_key *key) +static int find_first_block_group (struct btrfs_fs_info *fs_info, +struct btrfs_path *path, +struct btrfs_key *key) { +struct btrfs_root *root = fs_info->extent_root;int ret =0 ;struct btrfs_key found_key;struct extent_buffer *leaf;
@@ -9961,7 +9964,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info) need_clear =1 ;while (1 ) { - ret =find_first_block_group (root, path, &key); + ret =find_first_block_group (info, path, &key);if (ret >0 )break ;if (ret !=0 )
@@ -10140,7 +10143,7 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans, sizeof(item));if (ret)btrfs_abort_transaction (trans, ret); - ret =btrfs_finish_chunk_alloc (trans, extent_root, + ret =btrfs_finish_chunk_alloc (trans, extent_root->fs_info, key.objectid, key.offset);if (ret)btrfs_abort_transaction (trans, ret);
@@ -10263,9 +10266,10 @@ static void clear_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) }int btrfs_remove_block_group (struct btrfs_trans_handle *trans, -struct btrfs_root *root,u64 group_start, +struct btrfs_fs_info *fs_info,u64 group_start,struct extent_map *em) { +struct btrfs_root *root = fs_info->extent_root;struct btrfs_path *path;struct btrfs_block_group_cache *block_group;struct btrfs_free_cluster *cluster;
@@ -10279,9 +10283,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,struct btrfs_caching_control *caching_ctl =NULL ;bool remove_em; - root = root->fs_info->extent_root; - - block_group =btrfs_lookup_block_group (root->fs_info, group_start); + block_group =btrfs_lookup_block_group (fs_info, group_start);BUG_ON (!block_group);BUG_ON (!block_group->ro);
fs/btrfs/inode.c +3 -3
@@ -4179,7 +4179,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans, }btrfs_release_path (path); - ret =btrfs_del_root_ref (trans, root->fs_info->tree_root, + ret =btrfs_del_root_ref (trans, root->fs_info, objectid, root->root_key.objectid, dir_ino, &index, name, name_len);if (ret <0 ) {
@@ -6296,7 +6296,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans, }if (unlikely (ino ==BTRFS_FIRST_FREE_OBJECTID )) { - ret =btrfs_add_root_ref (trans, root->fs_info->tree_root, + ret =btrfs_add_root_ref (trans, root->fs_info, key.objectid, root->root_key.objectid, parent_ino, index, name, name_len); }else if (add_backref) {
@@ -6332,7 +6332,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,if (unlikely (ino ==BTRFS_FIRST_FREE_OBJECTID )) {u64 local_index;int err; - err =btrfs_del_root_ref (trans, root->fs_info->tree_root, + err =btrfs_del_root_ref (trans, root->fs_info, key.objectid, root->root_key.objectid, parent_ino, &local_index, name, name_len);
fs/btrfs/ioctl.c +8 -10
@@ -596,14 +596,13 @@ static noinline int create_subvol(struct inode *dir, ret =btrfs_update_inode (trans, root, dir);BUG_ON (ret); - ret =btrfs_add_root_ref (trans, root->fs_info->tree_root, + ret =btrfs_add_root_ref (trans, root->fs_info, objectid, root->root_key.objectid,btrfs_ino (dir), index, name, namelen);BUG_ON (ret); - ret =btrfs_uuid_tree_add (trans, root->fs_info->uuid_root, - root_item->uuid,BTRFS_UUID_KEY_SUBVOL , - objectid); + ret =btrfs_uuid_tree_add (trans, root->fs_info, root_item->uuid, +BTRFS_UUID_KEY_SUBVOL , objectid);if (ret)btrfs_abort_transaction (trans, ret);
@@ -2520,8 +2519,8 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, } } - ret =btrfs_uuid_tree_rem (trans, root->fs_info->uuid_root, - dest->root_item.uuid,BTRFS_UUID_KEY_SUBVOL , + ret =btrfs_uuid_tree_rem (trans, root->fs_info, dest->root_item.uuid, +BTRFS_UUID_KEY_SUBVOL , dest->root_key.objectid);if (ret && ret != -ENOENT ) {btrfs_abort_transaction (trans, ret);
@@ -2529,7 +2528,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, goto out_end_trans; }if (!btrfs_is_empty_uuid (dest->root_item.received_uuid)) { - ret =btrfs_uuid_tree_rem (trans, root->fs_info->uuid_root, + ret =btrfs_uuid_tree_rem (trans, root->fs_info, dest->root_item.received_uuid,BTRFS_UUID_KEY_RECEIVED_SUBVOL , dest->root_key.objectid);
@@ -5148,7 +5147,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file, BTRFS_UUID_SIZE);if (received_uuid_changed && !btrfs_is_empty_uuid (root_item->received_uuid)) -btrfs_uuid_tree_rem (trans, root->fs_info->uuid_root, +btrfs_uuid_tree_rem (trans, root->fs_info, root_item->received_uuid,BTRFS_UUID_KEY_RECEIVED_SUBVOL , root->root_key.objectid);
@@ -5167,8 +5166,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file, goto out; }if (received_uuid_changed && !btrfs_is_empty_uuid (sa->uuid)) { - ret =btrfs_uuid_tree_add (trans, root->fs_info->uuid_root, - sa->uuid, + ret =btrfs_uuid_tree_add (trans, root->fs_info, sa->uuid,BTRFS_UUID_KEY_RECEIVED_SUBVOL , root->root_key.objectid);if (ret <0 && ret != -EEXIST ) {
fs/btrfs/relocation.c +2 -2
@@ -4306,9 +4306,9 @@ static void describe_relocation(struct btrfs_fs_info *fs_info,/* * function to relocate all extents in a block group. */ -int btrfs_relocate_block_group (struct btrfs_root *extent_root,u64 group_start) +int btrfs_relocate_block_group (struct btrfs_fs_info *fs_info,u64 group_start) { -struct btrfs_fs_info *fs_info = extent_root->fs_info; +struct btrfs_root *extent_root = fs_info->extent_root;struct reloc_control *rc;struct inode *inode;struct btrfs_path *path;
fs/btrfs/root-tree.c +6 -3
@@ -216,8 +216,9 @@ int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,return btrfs_insert_item (trans, root, key, item,sizeof (*item)); } -int btrfs_find_orphan_roots (struct btrfs_root *tree_root) +int btrfs_find_orphan_roots (struct btrfs_fs_info *fs_info) { +struct btrfs_root *tree_root = fs_info->tree_root;struct extent_buffer *leaf;struct btrfs_path *path;struct btrfs_key key;
@@ -358,11 +359,12 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, }int btrfs_del_root_ref (struct btrfs_trans_handle *trans, -struct btrfs_root *tree_root, +struct btrfs_fs_info *fs_info,u64 root_id,u64 ref_id,u64 dirid,u64 *sequence,const char *name,int name_len) { +struct btrfs_root *tree_root = fs_info->tree_root;struct btrfs_path *path;struct btrfs_root_ref *ref;struct extent_buffer *leaf;
@@ -429,10 +431,11 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans,* Will return 0, -ENOMEM, or anything from the CoW path */ int btrfs_add_root_ref (struct btrfs_trans_handle *trans, -struct btrfs_root *tree_root, +struct btrfs_fs_info *fs_info,u64 root_id,u64 ref_id,u64 dirid,u64 sequence,const char *name,int name_len) { +struct btrfs_root *tree_root = fs_info->tree_root;struct btrfs_key key;int ret;struct btrfs_path *path;
fs/btrfs/super.c +7 -6
@@ -305,7 +305,7 @@ void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,static void btrfs_put_super (struct super_block *sb) { -close_ctree (btrfs_sb (sb)->tree_root); +close_ctree (btrfs_sb (sb)); }enum {
@@ -1173,7 +1173,7 @@ static int btrfs_fill_super(struct super_block *sb,return 0 ; fail_close: -close_ctree (fs_info->tree_root); +close_ctree (fs_info);return err; }
@@ -1784,7 +1784,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)btrfs_scrub_cancel (fs_info);btrfs_pause_balance (fs_info); - ret =btrfs_commit_super (root); + ret =btrfs_commit_super (fs_info);if (ret) goto restore; }else {
@@ -1901,9 +1901,10 @@ static inline void btrfs_descending_sort_devices(* The helper to calc the free space on the devices that can be used to store * file data. */ -static int btrfs_calc_avail_data_space (struct btrfs_root *root,u64 *free_bytes) +static int btrfs_calc_avail_data_space (struct btrfs_fs_info *fs_info, +u64 *free_bytes) { -struct btrfs_fs_info *fs_info = root->fs_info; +struct btrfs_root *root = fs_info->tree_root;struct btrfs_device_info *devices_info;struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;struct btrfs_device *device;
@@ -2137,7 +2138,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)spin_unlock (&block_rsv->lock); buf->f_bavail =div_u64 (total_free_data, factor); - ret =btrfs_calc_avail_data_space (fs_info->tree_root, &total_free_data); + ret =btrfs_calc_avail_data_space (fs_info, &total_free_data);if (ret)return ret; buf->f_bavail +=div_u64 (total_free_data, factor);
fs/btrfs/transaction.c +3 -3
@@ -1571,7 +1571,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,/* * insert root back/forward references */ - ret =btrfs_add_root_ref (trans, tree_root, objectid, + ret =btrfs_add_root_ref (trans, fs_info, objectid, parent_root->root_key.objectid,btrfs_ino (parent_inode), index, dentry->d_name.name, dentry->d_name.len);
@@ -1631,14 +1631,14 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,btrfs_abort_transaction (trans, ret); goto fail; } - ret =btrfs_uuid_tree_add (trans, fs_info->uuid_root, new_uuid.b, + ret =btrfs_uuid_tree_add (trans, fs_info, new_uuid.b,BTRFS_UUID_KEY_SUBVOL , objectid);if (ret) {btrfs_abort_transaction (trans, ret); goto fail; }if (!btrfs_is_empty_uuid (new_root_item->received_uuid)) { - ret =btrfs_uuid_tree_add (trans, fs_info->uuid_root, + ret =btrfs_uuid_tree_add (trans, fs_info, new_root_item->received_uuid,BTRFS_UUID_KEY_RECEIVED_SUBVOL , objectid);
fs/btrfs/uuid-tree.c +6 -4
@@ -92,9 +92,10 @@ static int btrfs_uuid_tree_lookup(struct btrfs_root *uuid_root, u8 *uuid, }int btrfs_uuid_tree_add (struct btrfs_trans_handle *trans, -struct btrfs_root *uuid_root,u8 *uuid,u8 type, +struct btrfs_fs_info *fs_info,u8 *uuid,u8 type,u64 subid_cpu) { +struct btrfs_root *uuid_root = fs_info->uuid_root;int ret;struct btrfs_path *path =NULL ;struct btrfs_key key;
@@ -138,7 +139,7 @@ int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, offset =btrfs_item_ptr_offset (eb, slot); offset +=btrfs_item_size_nr (eb, slot) -sizeof (subid_le); }else if (ret <0 ) { -btrfs_warn (uuid_root->fs_info, +btrfs_warn (fs_info,"insert uuid item failed %d (0x%016llx, 0x%016llx) type %u!" , ret, (unsigned long long )key.objectid, (unsigned long long )key.offset, type);
@@ -156,9 +157,10 @@ int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, }int btrfs_uuid_tree_rem (struct btrfs_trans_handle *trans, -struct btrfs_root *uuid_root,u8 *uuid,u8 type, +struct btrfs_fs_info *fs_info,u8 *uuid,u8 type,u64 subid) { +struct btrfs_root *uuid_root = fs_info->uuid_root;int ret;struct btrfs_path *path =NULL ;struct btrfs_key key;
@@ -250,7 +252,7 @@ static int btrfs_uuid_iter_rem(struct btrfs_root *uuid_root, u8 *uuid, u8 type, goto out; } - ret =btrfs_uuid_tree_rem (trans, uuid_root, uuid, type, subid); + ret =btrfs_uuid_tree_rem (trans, uuid_root->fs_info, uuid, type, subid);btrfs_end_transaction (trans, uuid_root); out:
fs/btrfs/volumes.c +26 -21
160 lines not on this page · raw message
fs/btrfs/volumes.h +2 -2
@@ -406,7 +406,7 @@ int btrfs_map_sblock(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,int btrfs_rmap_block (struct btrfs_fs_info *fs_info,u64 chunk_start,u64 physical,u64 devid,u64 **logical,int *naddrs,int *stripe_len); -int btrfs_read_sys_array (struct btrfs_root *root); +int btrfs_read_sys_array (struct btrfs_fs_info *fs_info);int btrfs_read_chunk_tree (struct btrfs_fs_info *fs_info);int btrfs_alloc_chunk (struct btrfs_trans_handle *trans,struct btrfs_root *extent_root,u64 type);
@@ -480,7 +480,7 @@ unsigned long btrfs_full_stripe_len(struct btrfs_root *root,struct btrfs_mapping_tree *map_tree, u64 logical);int btrfs_finish_chunk_alloc (struct btrfs_trans_handle *trans, -struct btrfs_root *extent_root, +struct btrfs_fs_info *fs_info,u64 chunk_offset,u64 chunk_size);int btrfs_remove_chunk (struct btrfs_trans_handle *trans,struct btrfs_fs_info *fs_info,u64 chunk_offset);
include/trace/events/btrfs.h +8 -8
@@ -698,10 +698,10 @@ DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head, DECLARE_EVENT_CLASS(btrfs__chunk, - TP_PROTO(struct btrfs_root *root, struct map_lookup *map, + TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map, u64 offset, u64 size), - TP_ARGS(root, map, offset, size), + TP_ARGS(fs_info, map, offset, size), TP_STRUCT__entry_btrfs( __field( int, num_stripes )
@@ -712,13 +712,13 @@ DECLARE_EVENT_CLASS(btrfs__chunk,__field ( u64, root_objectid ) ), -TP_fast_assign_btrfs (root->fs_info, +TP_fast_assign_btrfs (fs_info, __entry->num_stripes = map->num_stripes; __entry->type = map->type; __entry->sub_stripes = map->sub_stripes; __entry->offset = offset; __entry->size = size; - __entry->root_objectid = root->root_key.objectid; + __entry->root_objectid = fs_info->chunk_root->root_key.objectid; ), TP_printk_btrfs("root = %llu(%s), offset = %llu, size = %llu, "
@@ -732,18 +732,18 @@ DECLARE_EVENT_CLASS(btrfs__chunk,DEFINE_EVENT (btrfs__chunk, btrfs_chunk_alloc, - TP_PROTO(struct btrfs_root *root, struct map_lookup *map, + TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map, u64 offset, u64 size), -TP_ARGS (root, map, offset, size) +TP_ARGS (fs_info, map, offset, size) );DEFINE_EVENT (btrfs__chunk, btrfs_chunk_free, - TP_PROTO(struct btrfs_root *root, struct map_lookup *map, + TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map, u64 offset, u64 size), -TP_ARGS (root, map, offset, size) +TP_ARGS (fs_info, map, offset, size) ); TRACE_EVENT(btrfs_cow_block,
Signature · 1 line
2.7.1
PATCH 3/18 btrfs: btrfs_init_new_device should use fs_info->dev_root
In reply to [email protected]From: Jeff Mahoney <[email protected]>
btrfs_init_new_device only uses the root passed in via the ioctl to start the transaction. Nothing else that happens is related to whatever root the user used to initiate the ioctl. We can drop the root requirement and just use fs_info->dev_root instead.
--- fs/btrfs/ioctl.c | 2 +- fs/btrfs/volumes.c | 3 ++- fs/btrfs/volumes.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)
fs/btrfs/ioctl.c +1 -1
@@ -2672,7 +2672,7 @@ static long btrfs_ioctl_add_dev(struct btrfs_root *root, void __user *arg) } vol_args->name[BTRFS_PATH_NAME_MAX ] ='\0' ; - ret =btrfs_init_new_device (root, vol_args->name); + ret =btrfs_init_new_device (root->fs_info, vol_args->name);if (!ret)btrfs_info (root->fs_info,"disk added %s" ,vol_args->name);
fs/btrfs/volumes.c +2 -1
@@ -2310,8 +2310,9 @@ static int btrfs_finish_sprout(struct btrfs_trans_handle *trans,return ret; } -int btrfs_init_new_device (struct btrfs_root *root,char *device_path) +int btrfs_init_new_device (struct btrfs_fs_info *fs_info,char *device_path) { +struct btrfs_root *root = fs_info->dev_root;struct request_queue *q;struct btrfs_trans_handle *trans;struct btrfs_device *device;
fs/btrfs/volumes.h +1 -1
@@ -439,7 +439,7 @@ int btrfs_grow_device(struct btrfs_trans_handle *trans,struct btrfs_device *btrfs_find_device (struct btrfs_fs_info *fs_info,u64 devid,u8 *uuid,u8 *fsid);int btrfs_shrink_device (struct btrfs_device *device,u64 new_size); -int btrfs_init_new_device (struct btrfs_root *root,char *path); +int btrfs_init_new_device (struct btrfs_fs_info *fs_info,char *path);int btrfs_init_dev_replace_tgtdev (struct btrfs_root *root,char *device_path,struct btrfs_device *srcdev,struct btrfs_device **device_out);
Signature · 1 line
2.7.1
PATCH 4/18 btrfs: alloc_reserved_file_extent trace point should use extent_root
In reply to [email protected]From: Jeff Mahoney <[email protected]>
Even though a separate root is passed in, we're still operating on the extent root. Let's use that for the trace point.
--- fs/btrfs/extent-tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/extent-tree.c +2 -1
@@ -8105,7 +8105,8 @@ static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans, ins->objectid, ins->offset);BUG (); } -trace_btrfs_reserved_extent_alloc (root, ins->objectid, ins->offset); +trace_btrfs_reserved_extent_alloc (fs_info->extent_root, + ins->objectid, ins->offset);return ret; }
Signature · 1 line
2.7.1
PATCH 5/18 btrfs: struct btrfsic_state->root should be an fs_info
In reply to [email protected]From: Jeff Mahoney <[email protected]>
The root member is never used except for obtaining an fs_info pointer.
--- fs/btrfs/check-integrity.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
fs/btrfs/check-integrity.c +10 -10
@@ -254,7 +254,7 @@ struct btrfsic_state {struct list_head all_blocks_list;struct btrfsic_block_hashtable block_hashtable;struct btrfsic_block_link_hashtable block_link_hashtable; -struct btrfs_root *root; +struct btrfs_fs_info *fs_info;u64 max_superblock_generation;struct btrfsic_block *latest_superblock;u32 metablock_size;
@@ -717,7 +717,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state, } num_copies = -btrfs_num_copies (state->root->fs_info, +btrfs_num_copies (state->fs_info, next_bytenr, state->metablock_size);if (state->print_mask &BTRFSIC_PRINT_MASK_NUM_COPIES ) pr_info("num_copies(log_bytenr=%llu) = %d\n",
@@ -888,7 +888,7 @@ static int btrfsic_process_superblock_dev_mirror( } num_copies = -btrfs_num_copies (state->root->fs_info, +btrfs_num_copies (state->fs_info, next_bytenr, state->metablock_size);if (state->print_mask &BTRFSIC_PRINT_MASK_NUM_COPIES ) pr_info("num_copies(log_bytenr=%llu) = %d\n",
@@ -1263,7 +1263,7 @@ static int btrfsic_create_link_to_next_block( *next_blockp =NULL ;if (0 == *num_copiesp) { *num_copiesp = -btrfs_num_copies (state->root->fs_info, +btrfs_num_copies (state->fs_info, next_bytenr, state->metablock_size);if (state->print_mask &BTRFSIC_PRINT_MASK_NUM_COPIES ) pr_info("num_copies(log_bytenr=%llu) = %d\n",
@@ -1457,7 +1457,7 @@ static int btrfsic_handle_extent_data( chunk_len = num_bytes; num_copies = -btrfs_num_copies (state->root->fs_info, +btrfs_num_copies (state->fs_info, next_bytenr, state->datablock_size);if (state->print_mask &BTRFSIC_PRINT_MASK_NUM_COPIES ) pr_info("num_copies(log_bytenr=%llu) = %d\n",
@@ -1539,7 +1539,7 @@ static int btrfsic_map_block(struct btrfsic_state *state, u64 bytenr, u32 len,struct btrfs_device *device; length = len; - ret =btrfs_map_block (state->root->fs_info,BTRFS_MAP_READ , + ret =btrfs_map_block (state->fs_info,BTRFS_MAP_READ , bytenr, &length, &multi, mirror_num);if (ret) {
@@ -1741,7 +1741,7 @@ static int btrfsic_test_for_metadata(struct btrfsic_state *state, num_pages = state->metablock_size >>PAGE_SHIFT ; h = (struct btrfs_header *)datav[0 ]; -if (memcmp (h->fsid, state->root->fs_info->fsid,BTRFS_UUID_SIZE )) +if (memcmp (h->fsid, state->fs_info->fsid,BTRFS_UUID_SIZE ))return 1 ;for (i =0 ; i < num_pages; i++) {
@@ -2276,7 +2276,7 @@ static int btrfsic_process_written_superblock( } num_copies = -btrfs_num_copies (state->root->fs_info, +btrfs_num_copies (state->fs_info, next_bytenr,BTRFS_SUPER_INFO_SIZE );if (state->print_mask &BTRFSIC_PRINT_MASK_NUM_COPIES ) pr_info("num_copies(log_bytenr=%llu) = %d\n",
@@ -2705,7 +2705,7 @@ static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state,struct btrfsic_block_data_ctx block_ctx;int match =0 ; - num_copies =btrfs_num_copies (state->root->fs_info, + num_copies =btrfs_num_copies (state->fs_info, bytenr, state->metablock_size);for (mirror_num =1 ; mirror_num <= num_copies; mirror_num++) {
@@ -2936,7 +2936,7 @@ int btrfsic_mount(struct btrfs_root *root, btrfsic_is_initialized =1 ; }mutex_lock (&btrfsic_mutex); - state->root = root; + state->fs_info = root->fs_info; state->print_mask = print_mask; state->include_extent_data = including_extent_data; state->csum_size =0 ;
Signature · 1 line
2.7.1
PATCH 6/18 btrfs: struct reada_control.root -> reada_control.fs_info
In reply to [email protected]From: Jeff Mahoney <[email protected]>
The root is never used. We substitute extent_root in for the reada_find_extent call, since it's only ever used to obtain the node size. This call site will be changed to use fs_info in a later patch.
--- fs/btrfs/ctree.h | 2 +- fs/btrfs/reada.c | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-)
fs/btrfs/ctree.h +1 -1
@@ -3652,7 +3652,7 @@ static inline void btrfs_bio_counter_dec(struct btrfs_fs_info *fs_info)/* reada.c */ struct reada_control { -struct btrfs_root *root;/* tree to prefetch */ +struct btrfs_fs_info *fs_info;/* tree to prefetch */ struct btrfs_key key_start;struct btrfs_key key_end;/* exclusive */ atomic_t elems;
fs/btrfs/reada.c +7 -6
@@ -544,17 +544,18 @@ static void reada_control_release(struct kref *kref)static int reada_add_block (struct reada_control *rc,u64 logical,struct btrfs_key *top,u64 generation) { -struct btrfs_root *root = rc->root; +struct btrfs_fs_info *fs_info = rc->fs_info;struct reada_extent *re;struct reada_extctl *rec; - re =reada_find_extent (root, logical, top);/* takes one ref */ +/* takes one ref */ + re =reada_find_extent (fs_info->tree_root, logical, top);if (!re)return -1 ; rec =kzalloc (sizeof (*rec),GFP_KERNEL );if (!rec) { -reada_extent_put (root->fs_info, re); +reada_extent_put (fs_info, re);return -ENOMEM ; }
@@ -914,7 +915,7 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root,if (!rc)return ERR_PTR (-ENOMEM ); - rc->root = root; + rc->fs_info = root->fs_info; rc->key_start = *key_start; rc->key_end = *key_end;atomic_set (&rc->elems,0 );
@@ -942,7 +943,7 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root,int btrfs_reada_wait (void *handle) {struct reada_control *rc = handle; -struct btrfs_fs_info *fs_info = rc->root->fs_info; +struct btrfs_fs_info *fs_info = rc->fs_info;while (atomic_read (&rc->elems)) {if (!atomic_read (&fs_info->reada_works_cnt))
@@ -963,7 +964,7 @@ int btrfs_reada_wait(void *handle)int btrfs_reada_wait (void *handle) {struct reada_control *rc = handle; -struct btrfs_fs_info *fs_info = rc->root->fs_info; +struct btrfs_fs_info *fs_info = rc->fs_info;while (atomic_read (&rc->elems)) {if (!atomic_read (&fs_info->reada_works_cnt))
Signature · 1 line
2.7.1
PATCH 7/18 btrfs: root->fs_info cleanup, use fs_info->dev_root everywhere
In reply to [email protected]From: Jeff Mahoney <[email protected]>
--- fs/btrfs/check-integrity.c | 2 +- fs/btrfs/disk-io.c | 4 +-- fs/btrfs/extent-tree.c | 2 +- fs/btrfs/scrub.c | 86 +++++++++++++++++++++++----------------------- fs/btrfs/volumes.c | 41 +++++++++++----------- fs/btrfs/volumes.h | 3 +- 6 files changed, 68 insertions(+), 70 deletions(-)
fs/btrfs/check-integrity.c +1 -1
@@ -832,7 +832,7 @@ static int btrfsic_process_superblock_dev_mirror( superblock_tmp->never_written =0 ; superblock_tmp->mirror_num =1 + superblock_mirror_num;if (state->print_mask &BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE ) - btrfs_info_in_rcu(device->dev_root->fs_info, + btrfs_info_in_rcu(device->fs_info, "new initial S-block (bdev %p, %s) @%llu (%s/%llu/%d)", superblock_bdev, rcu_str_deref(device->name), dev_bytenr,
fs/btrfs/disk-io.c +2 -2
@@ -3308,7 +3308,7 @@ static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate)struct btrfs_device *device = (struct btrfs_device *) bh->b_private; -btrfs_warn_rl_in_rcu (device->dev_root->fs_info, +btrfs_warn_rl_in_rcu (device->fs_info,"lost page write due to IO error on %s" ,rcu_str_deref (device->name));/* note, we don't set_buffer_write_io_error because we have
@@ -3453,7 +3453,7 @@ static int write_dev_supers(struct btrfs_device *device, bh =__getblk (device->bdev, bytenr /4096 ,BTRFS_SUPER_INFO_SIZE );if (!bh) { -btrfs_err (device->dev_root->fs_info, +btrfs_err (device->fs_info,"couldn't get super buffer head for bytenr %llu" , bytenr); errors++;
fs/btrfs/extent-tree.c +1 -1
@@ -10853,7 +10853,7 @@ static int btrfs_trim_free_extents(struct btrfs_device *device, ret =0 ;while (1 ) { -struct btrfs_fs_info *fs_info = device->dev_root->fs_info; +struct btrfs_fs_info *fs_info = device->fs_info;struct btrfs_transaction *trans;u64 bytes;
fs/btrfs/scrub.c +43 -43
314 lines not on this page · raw message
fs/btrfs/volumes.c +20 -21
157 lines not on this page · raw message
fs/btrfs/volumes.h +1 -2
@@ -51,8 +51,7 @@ struct btrfs_device {struct list_head dev_list;struct list_head dev_alloc_list;struct btrfs_fs_devices *fs_devices; - -struct btrfs_root *dev_root; +struct btrfs_fs_info *fs_info;struct rcu_string *name;
Signature · 1 line
2.7.1
PATCH 8/18 btrfs: root->fs_info cleanup, io_ctl_init
In reply to [email protected]From: Jeff Mahoney <[email protected]>
The io_ctl->root member was only being used to access root->fs_info.
--- fs/btrfs/ctree.h | 2 +- fs/btrfs/free-space-cache.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
fs/btrfs/ctree.h +1 -1
@@ -519,7 +519,7 @@ struct btrfs_io_ctl {void *cur, *orig;struct page *page;struct page **pages; -struct btrfs_root *root; +struct btrfs_fs_info *fs_info;struct inode *inode;unsigned long size;int index;
fs/btrfs/free-space-cache.c +6 -6
@@ -303,7 +303,7 @@ static int readahead_cache(struct inode *inode) }static int io_ctl_init (struct btrfs_io_ctl *io_ctl,struct inode *inode, -struct btrfs_root *root,int write) +int write) {int num_pages;int check_crcs =0 ;
@@ -325,7 +325,7 @@ static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,return -ENOMEM ; io_ctl->num_pages = num_pages; - io_ctl->root = root; + io_ctl->fs_info =btrfs_sb (inode->i_sb); io_ctl->check_crcs = check_crcs; io_ctl->inode = inode;
@@ -448,7 +448,7 @@ static int io_ctl_check_generation(struct btrfs_io_ctl *io_ctl, u64 generation) gen = io_ctl->cur;if (le64_to_cpu (*gen) != generation) { -btrfs_err_rl (io_ctl->root->fs_info, +btrfs_err_rl (io_ctl->fs_info,"space cache generation (%llu) does not match inode (%llu)" , *gen, generation);io_ctl_unmap_page (io_ctl);
@@ -504,7 +504,7 @@ static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index) PAGE_SIZE - offset);btrfs_csum_final (crc, (u8 *)&crc);if (val != crc) { -btrfs_err_rl (io_ctl->root->fs_info, +btrfs_err_rl (io_ctl->fs_info,"csum mismatch on free space cache" );io_ctl_unmap_page (io_ctl);return -EIO ;
@@ -722,7 +722,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,if (!num_entries)return 0 ; - ret =io_ctl_init (&io_ctl, inode, root,0 ); + ret =io_ctl_init (&io_ctl, inode,0 );if (ret)return ret;
@@ -1229,7 +1229,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,return -EIO ;WARN_ON (io_ctl->pages); - ret =io_ctl_init (io_ctl, inode, root,1 ); + ret =io_ctl_init (io_ctl, inode,1 );if (ret)return ret;
Signature · 1 line
2.7.1
PATCH 10/18 btrfs: root->fs_info cleanup, btrfs_calc_{trans,trunc}_metadata_size
In reply to [email protected]From: Jeff Mahoney <[email protected]>
--- fs/btrfs/ctree.h | 8 ++++---- fs/btrfs/delayed-inode.c | 4 ++-- fs/btrfs/extent-tree.c | 35 +++++++++++++++++++---------------- fs/btrfs/file.c | 4 ++-- fs/btrfs/free-space-cache.c | 4 ++-- fs/btrfs/inode-map.c | 3 ++- fs/btrfs/inode.c | 4 ++-- fs/btrfs/props.c | 2 +- fs/btrfs/transaction.c | 5 +++-- 9 files changed, 37 insertions(+), 32 deletions(-)
fs/btrfs/ctree.h +4 -4
@@ -2535,20 +2535,20 @@ static inline gfp_t btrfs_alloc_write_mask(struct address_space *mapping)u64 btrfs_csum_bytes_to_leaves (struct btrfs_root *root,u64 csum_bytes); -static inline u64 btrfs_calc_trans_metadata_size (struct btrfs_root *root, +static inline u64 btrfs_calc_trans_metadata_size (struct btrfs_fs_info *fs_info,unsigned num_items) { -return root->fs_info->nodesize *BTRFS_MAX_LEVEL *2 * num_items; +return fs_info->nodesize *BTRFS_MAX_LEVEL *2 * num_items; }/* * Doing a truncate won't result in new nodes or leaves, just what we need for * COW. */ -static inline u64 btrfs_calc_trunc_metadata_size (struct btrfs_root *root, +static inline u64 btrfs_calc_trunc_metadata_size (struct btrfs_fs_info *fs_info,unsigned num_items) { -return root->fs_info->nodesize *BTRFS_MAX_LEVEL * num_items; +return fs_info->nodesize *BTRFS_MAX_LEVEL * num_items; } int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans,
fs/btrfs/delayed-inode.c +2 -2
@@ -549,7 +549,7 @@ static int btrfs_delayed_item_reserve_metadata(struct btrfs_trans_handle *trans, src_rsv = trans->block_rsv; dst_rsv = &root->fs_info->delayed_block_rsv; - num_bytes =btrfs_calc_trans_metadata_size (root,1 ); + num_bytes =btrfs_calc_trans_metadata_size (root->fs_info,1 ); ret =btrfs_block_rsv_migrate (src_rsv, dst_rsv, num_bytes,1 );if (!ret) { trace_btrfs_space_reservation(root->fs_info, "delayed_item",
@@ -592,7 +592,7 @@ static int btrfs_delayed_inode_reserve_metadata( src_rsv = trans->block_rsv; dst_rsv = &root->fs_info->delayed_block_rsv; - num_bytes =btrfs_calc_trans_metadata_size (root,1 ); + num_bytes =btrfs_calc_trans_metadata_size (root->fs_info,1 );/* * If our block_rsv is the delalloc block reserve then check and see if
fs/btrfs/extent-tree.c +19 -16
@@ -2791,13 +2791,13 @@ int btrfs_check_space_for_delayed_refs(struct btrfs_trans_handle *trans,u64 num_bytes, num_dirty_bgs_bytes;int ret =0 ; - num_bytes =btrfs_calc_trans_metadata_size (root,1 ); + num_bytes =btrfs_calc_trans_metadata_size (root->fs_info,1 ); num_heads =heads_to_leaves (root, num_heads);if (num_heads >1 ) num_bytes += (num_heads -1 ) * root->fs_info->nodesize; num_bytes <<=1 ; num_bytes +=btrfs_csum_bytes_to_leaves (root, csum_bytes) * root->fs_info->nodesize; - num_dirty_bgs_bytes =btrfs_calc_trans_metadata_size (root, + num_dirty_bgs_bytes =btrfs_calc_trans_metadata_size (root->fs_info, num_dirty_bgs); global_rsv = &root->fs_info->global_block_rsv;
@@ -4440,8 +4440,8 @@ void check_system_chunk(struct btrfs_trans_handle *trans, num_devs =get_profile_num_devs (root, type);/* num_devs device items to update and 1 chunk item to add or remove */ - thresh =btrfs_calc_trunc_metadata_size (root, num_devs) + -btrfs_calc_trans_metadata_size (root,1 ); + thresh =btrfs_calc_trunc_metadata_size (root->fs_info, num_devs) + +btrfs_calc_trans_metadata_size (root->fs_info,1 );if (left < thresh &&btrfs_test_opt (root->fs_info,ENOSPC_DEBUG )) { btrfs_info(root->fs_info, "left=%llu, need=%llu, flags=%llu",
@@ -4695,7 +4695,7 @@ static inline int calc_reclaim_items_nr(struct btrfs_root *root, u64 to_reclaim)u64 bytes;int nr; - bytes =btrfs_calc_trans_metadata_size (root,1 ); + bytes =btrfs_calc_trans_metadata_size (root->fs_info,1 ); nr = (int )div64_u64 (to_reclaim, bytes);if (!nr) nr =1 ;
@@ -5770,7 +5770,7 @@ int btrfs_orphan_reserve_metadata(struct btrfs_trans_handle *trans,* added it, so this takes the reservation so we can release it later * when we are truly done with the orphan item. */ -u64 num_bytes =btrfs_calc_trans_metadata_size (root,1 ); +u64 num_bytes =btrfs_calc_trans_metadata_size (root->fs_info,1 );trace_btrfs_space_reservation (root->fs_info,"orphan" ,btrfs_ino (inode), num_bytes,1 );return btrfs_block_rsv_migrate (src_rsv, dst_rsv, num_bytes,1 );
@@ -5779,7 +5779,7 @@ int btrfs_orphan_reserve_metadata(struct btrfs_trans_handle *trans,void btrfs_orphan_release_metadata (struct inode *inode) {struct btrfs_root *root =BTRFS_I (inode)->root; -u64 num_bytes =btrfs_calc_trans_metadata_size (root,1 ); +u64 num_bytes =btrfs_calc_trans_metadata_size (root->fs_info,1 );trace_btrfs_space_reservation (root->fs_info,"orphan" ,btrfs_ino (inode), num_bytes,0 );btrfs_block_rsv_release (root, root->orphan_block_rsv, num_bytes);
@@ -5821,7 +5821,7 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root *root, *qgroup_reserved = num_bytes; - num_bytes =btrfs_calc_trans_metadata_size (root, items); + num_bytes =btrfs_calc_trans_metadata_size (root->fs_info, items); rsv->space_info =__find_space_info (root->fs_info,BTRFS_BLOCK_GROUP_METADATA ); ret = btrfs_block_rsv_add(root, rsv, num_bytes,
@@ -5925,10 +5925,11 @@ static u64 calc_csum_metadata_size(struct inode *inode, u64 num_bytes,return 0 ;if (reserve) -return btrfs_calc_trans_metadata_size (root, +return btrfs_calc_trans_metadata_size (root->fs_info, num_csums - old_csums); -return btrfs_calc_trans_metadata_size (root, old_csums - num_csums); +return btrfs_calc_trans_metadata_size (root->fs_info, + old_csums - num_csums); }int btrfs_delalloc_reserve_metadata (struct inode *inode,u64 num_bytes)
@@ -5982,7 +5983,8 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)BTRFS_I (inode)->reserved_extents;/* We always want to reserve a slot for updating the inode. */ - to_reserve =btrfs_calc_trans_metadata_size (root, nr_extents +1 ); + to_reserve =btrfs_calc_trans_metadata_size (root->fs_info, + nr_extents +1 ); to_reserve +=calc_csum_metadata_size (inode, num_bytes,1 ); csum_bytes =BTRFS_I (inode)->csum_bytes;spin_unlock (&BTRFS_I (inode)->lock);
@@ -6004,7 +6006,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)spin_lock (&BTRFS_I (inode)->lock);if (test_and_set_bit (BTRFS_INODE_DELALLOC_META_RESERVED , &BTRFS_I (inode)->runtime_flags)) { - to_reserve -=btrfs_calc_trans_metadata_size (root,1 ); + to_reserve -=btrfs_calc_trans_metadata_size (root->fs_info,1 ); release_extra = true; }BTRFS_I (inode)->reserved_extents += nr_extents;
@@ -6018,8 +6020,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) btrfs_ino(inode), to_reserve, 1);if (release_extra)btrfs_block_rsv_release (root, block_rsv, -btrfs_calc_trans_metadata_size (root, -1 )); +btrfs_calc_trans_metadata_size (root->fs_info,1 ));return 0 ; out_fail:
@@ -6074,7 +6075,8 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) }spin_unlock (&BTRFS_I (inode)->lock);if (dropped) - to_free +=btrfs_calc_trans_metadata_size (root, dropped); + to_free +=btrfs_calc_trans_metadata_size (root->fs_info, + dropped);if (to_free) {btrfs_block_rsv_release (root, block_rsv, to_free);
@@ -6109,7 +6111,8 @@ void btrfs_delalloc_release_metadata(struct inode *inode, u64 num_bytes) to_free =calc_csum_metadata_size (inode, num_bytes,0 );spin_unlock (&BTRFS_I (inode)->lock);if (dropped >0 ) - to_free +=btrfs_calc_trans_metadata_size (root, dropped); + to_free +=btrfs_calc_trans_metadata_size (root->fs_info, + dropped);if (btrfs_is_testing (root->fs_info))return ;
fs/btrfs/file.c +2 -2
@@ -2369,7 +2369,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)u64 tail_len;u64 orig_start = offset;u64 cur_offset; -u64 min_size =btrfs_calc_trunc_metadata_size (root,1 ); +u64 min_size =btrfs_calc_trunc_metadata_size (root->fs_info,1 );u64 drop_end;int ret =0 ;int err =0 ;
@@ -2516,7 +2516,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) ret = -ENOMEM ; goto out_free; } - rsv->size =btrfs_calc_trunc_metadata_size (root,1 ); + rsv->size =btrfs_calc_trunc_metadata_size (root->fs_info,1 ); rsv->failfast =1 ;/*
fs/btrfs/free-space-cache.c +2 -2
@@ -210,8 +210,8 @@ int btrfs_check_trunc_cache_free_space(struct btrfs_root *root,int ret;/* 1 for slack space, 1 for updating the inode */ - needed_bytes =btrfs_calc_trunc_metadata_size (root,1 ) + -btrfs_calc_trans_metadata_size (root,1 ); + needed_bytes =btrfs_calc_trunc_metadata_size (root->fs_info,1 ) + +btrfs_calc_trans_metadata_size (root->fs_info,1 );spin_lock (&rsv->lock);if (rsv->reserved < needed_bytes)
fs/btrfs/inode-map.c +2 -1
@@ -433,7 +433,8 @@ int btrfs_save_ino_cache(struct btrfs_root *root,* 1 item for free space object * 3 items for pre-allocation */ - trans->bytes_reserved =btrfs_calc_trans_metadata_size (root,10 ); + trans->bytes_reserved =btrfs_calc_trans_metadata_size (root->fs_info, +10 ); ret =btrfs_block_rsv_add (root, trans->block_rsv, trans->bytes_reserved,BTRFS_RESERVE_NO_FLUSH );
fs/btrfs/inode.c +2 -2
@@ -5217,7 +5217,7 @@ void btrfs_evict_inode(struct inode *inode)return ; } - min_size =btrfs_calc_trunc_metadata_size (root,1 ); + min_size =btrfs_calc_trunc_metadata_size (root->fs_info,1 );evict_inode_truncate_pages (inode);
@@ -9073,7 +9073,7 @@ static int btrfs_truncate(struct inode *inode)int err =0 ;struct btrfs_trans_handle *trans;u64 mask = root->fs_info->sectorsize -1 ; -u64 min_size =btrfs_calc_trunc_metadata_size (root,1 ); +u64 min_size =btrfs_calc_trunc_metadata_size (root->fs_info,1 ); ret =btrfs_wait_ordered_range (inode, inode->i_size & (~mask), (u64)-1 );
fs/btrfs/props.c +1 -1
@@ -320,7 +320,7 @@ static int inherit_props(struct btrfs_trans_handle *trans,if (!value)continue ; - num_bytes =btrfs_calc_trans_metadata_size (root,1 ); + num_bytes =btrfs_calc_trans_metadata_size (root->fs_info,1 ); ret =btrfs_block_rsv_add (root, trans->block_rsv, num_bytes,BTRFS_RESERVE_NO_FLUSH );if (ret)
fs/btrfs/transaction.c +3 -2
@@ -502,7 +502,8 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,if (ret)return ERR_PTR (ret); - num_bytes =btrfs_calc_trans_metadata_size (root, num_items); + num_bytes =btrfs_calc_trans_metadata_size (root->fs_info, + num_items);/* * Do the reservation for the relocation root creation */
@@ -624,7 +625,7 @@ struct btrfs_trans_handle *btrfs_start_transaction_fallback_global_rsv(if (IS_ERR (trans))return trans; - num_bytes =btrfs_calc_trans_metadata_size (root, num_items); + num_bytes =btrfs_calc_trans_metadata_size (root->fs_info, num_items); ret = btrfs_cond_migrate_bytes(root->fs_info, &root->fs_info->trans_block_rsv, num_bytes,
Signature · 1 line
2.7.1
Re: [PATCH 10/18] btrfs: root->fs_info cleanup, btrfs_calc_{trans,trunc}_metadata_size
fs/btrfs/ctree.h static inline gfp_t btrfs_alloc_write_mask(struct address_space *mapping) · line 2541
Quoted 6 lines · On Fri, Dec 02, 2016 at 12:07:30AM -0500, [email protected] wrote:
fs/btrfs/ctree.h +2
-2-static inline u64 btrfs_calc_trans_metadata_size (struct btrfs_root *root, +static inline u64 btrfs_calc_trans_metadata_size (struct btrfs_fs_info *fs_info,unsigned num_items) { -return root->fs_info->nodesize *BTRFS_MAX_LEVEL *2 * num_items; +return fs_info->nodesize *BTRFS_MAX_LEVEL *2 * num_items;
Is there a missing patch that moves 'nodesize' to fs_info? The patch has a minor conflict in the original line where it's just 'root->nodesize', but thre are many compilation faiures due to lack of fs_info::nodesize.
Re: [PATCH 10/18] btrfs: root->fs_info cleanup, btrfs_calc_{trans,trunc}_metadata_size
Quoted 11 lines · David Sterba
fs/btrfs/ctree.h static inline gfp_t btrfs_alloc_write_mask(struct address_space *mapping) · line 2541
Quoted 6 lines · On Fri, Dec 02, 2016 at 12:07:30AM -0500, [email protected] wrote:
fs/btrfs/ctree.h +2
-2-static inline u64 btrfs_calc_trans_metadata_size (struct btrfs_root *root, +static inline u64 btrfs_calc_trans_metadata_size (struct btrfs_fs_info *fs_info,unsigned num_items) { -return root->fs_info->nodesize *BTRFS_MAX_LEVEL *2 * num_items; +return fs_info->nodesize *BTRFS_MAX_LEVEL *2 * num_items;Is there a missing patch that moves 'nodesize' to
fs_info? The patch has a minor conflict in the original line where it's just 'root->nodesize', but thre are many compilation faiures due to lack offs_info::nodesize.
Yeah, it looks like the list dropped it. It shows up in the thread posted to me.
I've pushed the series as the for-4.10/misc-4.10 branch in
my repo at git://git.kernel.org/pub/scm/linux/kernel/git/jeffm/linux-btrfs.git
It also contains the fix Omar suggested in his review.
-Jeff
Signature · 2 lines
Jeff Mahoney SUSE Labs
Re: [PATCH 10/18] btrfs: root->fs_info cleanup, btrfs_calc_{trans,trunc}_metadata_size
Quoted 13 lines · Jeff Mahoney
Quoted 11 lines · David Sterba
fs/btrfs/ctree.h static inline gfp_t btrfs_alloc_write_mask(struct address_space *mapping) · line 2541
Quoted 6 lines · On Fri, Dec 02, 2016 at 12:07:30AM -0500, [email protected] wrote:
fs/btrfs/ctree.h +2
-2-static inline u64 btrfs_calc_trans_metadata_size (struct btrfs_root *root, +static inline u64 btrfs_calc_trans_metadata_size (struct btrfs_fs_info *fs_info,unsigned num_items) { -return root->fs_info->nodesize *BTRFS_MAX_LEVEL *2 * num_items; +return fs_info->nodesize *BTRFS_MAX_LEVEL *2 * num_items;Is there a missing patch that moves 'nodesize' to
fs_info? The patch has a minor conflict in the original line where it's just 'root->nodesize', but thre are many compilation faiures due to lack offs_info::nodesize.
Quoted 7 lines
Yeah, it looks like the list dropped it. It shows up in the thread posted to me.
I've pushed the series as the for-4.10/misc-4.10 branch in
my repo atgit://git.kernel.org/pub/scm/linux/kernel/git/jeffm/linux-btrfs.gitIt also contains the fix Omar suggested in his review.
Thanks, added to 4.10 queue.
PATCH 11/18 btrfs: root->fs_info cleanup, lock/unlock_chunks
In reply to [email protected]From: Jeff Mahoney <[email protected]>
--- fs/btrfs/disk-io.c | 4 +-- fs/btrfs/extent-tree.c | 8 +++--- fs/btrfs/free-space-cache.c | 4 +-- fs/btrfs/volumes.c | 70 ++++++++++++++++++++++----------------------- fs/btrfs/volumes.h | 8 +++--- 5 files changed, 47 insertions(+), 47 deletions(-)
fs/btrfs/disk-io.c +2 -2
@@ -3998,7 +3998,7 @@ void close_ctree(struct btrfs_fs_info *fs_info)__btrfs_free_block_rsv (root->orphan_block_rsv); root->orphan_block_rsv =NULL ; -lock_chunks (root); +lock_chunks (root->fs_info);while (!list_empty (&fs_info->pinned_chunks)) {struct extent_map *em;
@@ -4007,7 +4007,7 @@ void close_ctree(struct btrfs_fs_info *fs_info)list_del_init (&em->list);free_extent_map (em); } -unlock_chunks (root); +unlock_chunks (root->fs_info); } int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid,
fs/btrfs/extent-tree.c +4 -4
@@ -9436,9 +9436,9 @@ int btrfs_inc_block_group_ro(struct btrfs_root *root, out:if (cache->flags &BTRFS_BLOCK_GROUP_SYSTEM ) { alloc_flags =update_block_group_flags (root, cache->flags); -lock_chunks (root->fs_info->chunk_root); +lock_chunks (root->fs_info);check_system_chunk (trans, root, alloc_flags); -unlock_chunks (root->fs_info->chunk_root); +unlock_chunks (root->fs_info); }mutex_unlock (&root->fs_info->ro_block_group_mutex);
@@ -10482,7 +10482,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,memcpy (&key, &block_group->key,sizeof (key)); -lock_chunks (root); +lock_chunks (root->fs_info);if (!list_empty (&em->list)) {/* We're in the transaction->pending_chunks list. */ free_extent_map (em);
@@ -10550,7 +10550,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,free_extent_map (em); } -unlock_chunks (root); +unlock_chunks (root->fs_info); ret =remove_block_group_free_space (trans, root->fs_info, block_group);if (ret)
fs/btrfs/free-space-cache.c +2 -2
@@ -3328,7 +3328,7 @@ void btrfs_put_block_group_trimming(struct btrfs_block_group_cache *block_group)spin_unlock (&block_group->lock);if (cleanup) { -lock_chunks (block_group->fs_info->chunk_root); +lock_chunks (block_group->fs_info); em_tree = &block_group->fs_info->mapping_tree.map_tree;write_lock (&em_tree->lock); em = lookup_extent_mapping(em_tree, block_group->key.objectid,
@@ -3340,7 +3340,7 @@ void btrfs_put_block_group_trimming(struct btrfs_block_group_cache *block_group)*/ remove_extent_mapping (em_tree, em);write_unlock (&em_tree->lock); -unlock_chunks (block_group->fs_info->chunk_root); +unlock_chunks (block_group->fs_info);/* once for us and once for the tree */ free_extent_map (em);
fs/btrfs/volumes.c +35 -35
250 lines not on this page · raw message
fs/btrfs/volumes.h +4 -4
@@ -532,14 +532,14 @@ void btrfs_update_commit_device_size(struct btrfs_fs_info *fs_info);void btrfs_update_commit_device_bytes_used (struct btrfs_root *root,struct btrfs_transaction *transaction); -static inline void lock_chunks (struct btrfs_root *root) +static inline void lock_chunks (struct btrfs_fs_info *fs_info) { -mutex_lock (&root->fs_info->chunk_mutex); +mutex_lock (&fs_info->chunk_mutex); } -static inline void unlock_chunks (struct btrfs_root *root) +static inline void unlock_chunks (struct btrfs_fs_info *fs_info) { -mutex_unlock (&root->fs_info->chunk_mutex); +mutex_unlock (&fs_info->chunk_mutex); }struct list_head *btrfs_get_fs_uuids (void );
Signature · 1 line
2.7.1
PATCH 12/18 btrfs: root->fs_info cleanup, update_block_group{,flags}
In reply to [email protected]From: Jeff Mahoney <[email protected]>
--- fs/btrfs/extent-tree.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
fs/btrfs/extent-tree.c +14 -14
@@ -61,7 +61,7 @@ enum { };static int update_block_group (struct btrfs_trans_handle *trans, -struct btrfs_root *root,u64 bytenr, +struct btrfs_fs_info *fs_info,u64 bytenr,u64 num_bytes,int alloc); static int __btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root,
@@ -6182,11 +6182,10 @@ void btrfs_delalloc_release_space(struct inode *inode, u64 start, u64 len) }static int update_block_group (struct btrfs_trans_handle *trans, -struct btrfs_root *root,u64 bytenr, +struct btrfs_fs_info *info,u64 bytenr,u64 num_bytes,int alloc) {struct btrfs_block_group_cache *cache =NULL ; -struct btrfs_fs_info *info = root->fs_info;u64 total = num_bytes;u64 old_val;u64 byte_in_group;
@@ -6227,7 +6226,7 @@ static int update_block_group(struct btrfs_trans_handle *trans,spin_lock (&cache->space_info->lock);spin_lock (&cache->lock); -if (btrfs_test_opt (root->fs_info,SPACE_CACHE ) && +if (btrfs_test_opt (info,SPACE_CACHE ) && cache->disk_cache_state <BTRFS_DC_CLEAR ) cache->disk_cache_state =BTRFS_DC_CLEAR ;
@@ -7088,7 +7087,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans, goto out; } - ret =update_block_group (trans, root, bytenr, num_bytes,0 ); + ret =update_block_group (trans, root->fs_info, bytenr, + num_bytes,0 );if (ret) {btrfs_abort_transaction (trans, ret); goto out;
@@ -8104,7 +8104,7 @@ static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans,if (ret)return ret; - ret =update_block_group (trans, root, ins->objectid, ins->offset,1 ); + ret =update_block_group (trans, fs_info, ins->objectid, ins->offset,1 );if (ret) {/* -ENOENT, logic error */ btrfs_err (fs_info,"update block group failed for %llu %llu" , ins->objectid, ins->offset);
@@ -8190,9 +8190,8 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,if (ret)return ret; - ret =update_block_group (trans, root, ins->objectid, - root->fs_info->nodesize, -1 ); + ret =update_block_group (trans, fs_info, ins->objectid, + fs_info->nodesize,1 );if (ret) {/* -ENOENT, logic error */ btrfs_err (fs_info,"update block group failed for %llu %llu" , ins->objectid, ins->offset);
@@ -9280,7 +9279,7 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,return ret; } -static u64 update_block_group_flags (struct btrfs_root *root,u64 flags) +static u64 update_block_group_flags (struct btrfs_fs_info *fs_info,u64 flags) {u64 num_devices;u64 stripped;
@@ -9289,11 +9288,11 @@ static u64 update_block_group_flags(struct btrfs_root *root, u64 flags)* if restripe for this chunk_type is on pick target profile and * return, otherwise do the usual balance */ - stripped =get_restripe_target (root->fs_info, flags); + stripped =get_restripe_target (fs_info, flags);if (stripped)return extended_to_chunk (stripped); - num_devices = root->fs_info->fs_devices->rw_devices; + num_devices = fs_info->fs_devices->rw_devices; stripped =BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6 |
@@ -9409,7 +9408,7 @@ int btrfs_inc_block_group_ro(struct btrfs_root *root,* if we are changing raid levels, try to allocate a corresponding * block group with the new raid level. */ - alloc_flags =update_block_group_flags (root, cache->flags); + alloc_flags =update_block_group_flags (root->fs_info, cache->flags);if (alloc_flags != cache->flags) { ret =do_chunk_alloc (trans, root, alloc_flags,CHUNK_ALLOC_FORCE );
@@ -9435,7 +9434,8 @@ int btrfs_inc_block_group_ro(struct btrfs_root *root, ret =inc_block_group_ro (cache,0 ); out:if (cache->flags &BTRFS_BLOCK_GROUP_SYSTEM ) { - alloc_flags =update_block_group_flags (root, cache->flags); + alloc_flags =update_block_group_flags (root->fs_info, + cache->flags);lock_chunks (root->fs_info);check_system_chunk (trans, root, alloc_flags);unlock_chunks (root->fs_info);
Signature · 1 line
2.7.1
PATCH 14/18 btrfs: root->fs_info cleanup, access fs_info->delayed_root directly
In reply to [email protected]From: Jeff Mahoney <[email protected]>
This results in btrfs_assert_delayed_root_empty and btrfs_destroy_delayed_inode taking an fs_info instead of a root.
--- fs/btrfs/delayed-inode.c | 23 ++++++----------------- fs/btrfs/delayed-inode.h | 4 ++-- fs/btrfs/disk-io.c | 8 ++++---- fs/btrfs/transaction.c | 2 +- 4 files changed, 13 insertions(+), 24 deletions(-)
fs/btrfs/delayed-inode.c +6 -17
@@ -72,12 +72,6 @@ static inline int btrfs_is_continuous_delayed_item(return 0 ; } -static inline struct btrfs_delayed_root *btrfs_get_delayed_root ( -struct btrfs_root *root) -{ -return root->fs_info->delayed_root; -} -static struct btrfs_delayed_node *btrfs_get_delayed_node (struct inode *inode) {struct btrfs_inode *btrfs_inode =BTRFS_I (inode);
@@ -1163,7 +1157,7 @@ static int __btrfs_run_delayed_items(struct btrfs_trans_handle *trans, block_rsv = trans->block_rsv; trans->block_rsv = &fs_info->delayed_block_rsv; - delayed_root =btrfs_get_delayed_root (root); + delayed_root = fs_info->delayed_root; curr_node =btrfs_first_delayed_node (delayed_root);while (curr_node && (!count || (count && nr--))) {
@@ -1390,11 +1384,9 @@ static int btrfs_wq_run_delayed_node(struct btrfs_delayed_root *delayed_root,return 0 ; } -void btrfs_assert_delayed_root_empty (struct btrfs_root *root) +void btrfs_assert_delayed_root_empty (struct btrfs_fs_info *fs_info) { -struct btrfs_delayed_root *delayed_root; - delayed_root =btrfs_get_delayed_root (root); -WARN_ON (btrfs_first_delayed_node (delayed_root)); +WARN_ON (btrfs_first_delayed_node (fs_info->delayed_root)); }static int could_end_wait (struct btrfs_delayed_root *delayed_root,int seq)
@@ -1415,7 +1407,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)struct btrfs_delayed_root *delayed_root;struct btrfs_fs_info *fs_info = root->fs_info; - delayed_root =btrfs_get_delayed_root (root); + delayed_root = fs_info->delayed_root;if (atomic_read (&delayed_root->items) <BTRFS_DELAYED_BACKGROUND )return ;
@@ -1980,14 +1972,11 @@ void btrfs_kill_all_delayed_nodes(struct btrfs_root *root) } } -void btrfs_destroy_delayed_inodes (struct btrfs_root *root) +void btrfs_destroy_delayed_inodes (struct btrfs_fs_info *fs_info) { -struct btrfs_delayed_root *delayed_root;struct btrfs_delayed_node *curr_node, *prev_node; - delayed_root =btrfs_get_delayed_root (root); - - curr_node =btrfs_first_delayed_node (delayed_root); + curr_node =btrfs_first_delayed_node (fs_info->delayed_root);while (curr_node) {__btrfs_kill_delayed_node (curr_node);
fs/btrfs/delayed-inode.h +2 -2
@@ -134,7 +134,7 @@ int btrfs_delayed_delete_inode_ref(struct inode *inode);void btrfs_kill_all_delayed_nodes (struct btrfs_root *root);/* Used for clean the transaction */ -void btrfs_destroy_delayed_inodes (struct btrfs_root *root); +void btrfs_destroy_delayed_inodes (struct btrfs_fs_info *fs_info);/* Used for readdir() */ bool btrfs_readdir_get_delayed_items(struct inode *inode,
@@ -153,6 +153,6 @@ int __init btrfs_delayed_inode_init(void);void btrfs_delayed_inode_exit (void );/* for debugging */ -void btrfs_assert_delayed_root_empty (struct btrfs_root *root); +void btrfs_assert_delayed_root_empty (struct btrfs_fs_info *fs_info);#endif
fs/btrfs/disk-io.c +4 -4
@@ -4587,8 +4587,8 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans, cur_trans->state =TRANS_STATE_UNBLOCKED ;wake_up (&fs_info->transaction_wait); -btrfs_destroy_delayed_inodes (root); -btrfs_assert_delayed_root_empty (root); +btrfs_destroy_delayed_inodes (fs_info); +btrfs_assert_delayed_root_empty (fs_info);btrfs_destroy_marked_extents (root, &cur_trans->dirty_pages,EXTENT_DIRTY );
@@ -4649,8 +4649,8 @@ static int btrfs_cleanup_transaction(struct btrfs_root *root) }spin_unlock (&fs_info->trans_lock);btrfs_destroy_all_ordered_extents (fs_info); -btrfs_destroy_delayed_inodes (root); -btrfs_assert_delayed_root_empty (root); +btrfs_destroy_delayed_inodes (fs_info); +btrfs_assert_delayed_root_empty (fs_info);btrfs_destroy_pinned_extent (root, fs_info->pinned_extents);btrfs_destroy_all_delalloc_inodes (fs_info);mutex_unlock (&fs_info->transaction_kthread_mutex);
fs/btrfs/transaction.c +1 -1
@@ -2133,7 +2133,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,* make sure none of the code above managed to slip in a * delayed item */ -btrfs_assert_delayed_root_empty (root); +btrfs_assert_delayed_root_empty (fs_info);WARN_ON (cur_trans != trans->transaction);
Signature · 1 line
2.7.1
PATCH 15/18 btrfs: convert extent-tree tracepoints to use fs_info
In reply to [email protected]From: Jeff Mahoney <[email protected]>
The extent-tree tracepoints all operate on the extent root, regardless of which root is passed in. Let's just use the extent root objectid instead. If it turns out that nobody is depending on the format of this tracepoint, we can drop the root printing entirely.
--- fs/btrfs/extent-tree.c | 17 ++++++++------- include/trace/events/btrfs.h | 49 ++++++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 36 deletions(-)
fs/btrfs/extent-tree.c +8 -9
@@ -7244,7 +7244,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,btrfs_add_free_space (cache, buf->start, buf->len);btrfs_free_reserved_bytes (cache, buf->len,0 );btrfs_put_block_group (cache); -trace_btrfs_reserved_extent_free (root, buf->start, buf->len); +trace_btrfs_reserved_extent_free (fs_info, buf->start, buf->len); pin =0 ; } out:
@@ -7493,7 +7493,7 @@ static noinline int find_free_extent(struct btrfs_root *orig_root, ins->objectid =0 ; ins->offset =0 ; -trace_find_free_extent (orig_root, num_bytes, empty_size, flags); +trace_find_free_extent (fs_info, num_bytes, empty_size, flags); space_info =__find_space_info (fs_info, flags);if (!space_info) {
@@ -7652,7 +7652,7 @@ static noinline int find_free_extent(struct btrfs_root *orig_root,if (offset) {/* we have a block, we're done */ spin_unlock (&last_ptr->refill_lock); -trace_btrfs_reserve_extent_cluster (root, +trace_btrfs_reserve_extent_cluster (fs_info, used_block_group, search_start, num_bytes);if (used_block_group != block_group) {
@@ -7725,7 +7725,7 @@ static noinline int find_free_extent(struct btrfs_root *orig_root,if (offset) {/* we found one, proceed */ spin_unlock (&last_ptr->refill_lock); -trace_btrfs_reserve_extent_cluster (root, +trace_btrfs_reserve_extent_cluster (fs_info, block_group, search_start, num_bytes); goto checks;
@@ -7823,7 +7823,7 @@ static noinline int find_free_extent(struct btrfs_root *orig_root, ins->objectid = search_start; ins->offset = num_bytes; -trace_btrfs_reserve_extent (orig_root, block_group, +trace_btrfs_reserve_extent (fs_info, block_group, search_start, num_bytes);btrfs_release_block_group (block_group, delalloc);break ;
@@ -8048,7 +8048,7 @@ static int __btrfs_free_reserved_extent(struct btrfs_root *root, ret =btrfs_discard_extent (root, start, len,NULL );btrfs_add_free_space (cache, start, len);btrfs_free_reserved_bytes (cache, len, delalloc); -trace_btrfs_reserved_extent_free (root, start, len); +trace_btrfs_reserved_extent_free (fs_info, start, len); }btrfs_put_block_group (cache);
@@ -8139,8 +8139,7 @@ static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans, ins->objectid, ins->offset);BUG (); } -trace_btrfs_reserved_extent_alloc (fs_info->extent_root, - ins->objectid, ins->offset); +trace_btrfs_reserved_extent_alloc (fs_info, ins->objectid, ins->offset);return ret; }
@@ -8226,7 +8225,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,BUG (); } -trace_btrfs_reserved_extent_alloc (root, ins->objectid, +trace_btrfs_reserved_extent_alloc (fs_info, ins->objectid, fs_info->nodesize);return ret; }
include/trace/events/btrfs.h +22 -27
136 lines not on this page · raw message
Signature · 1 line
2.7.1
PATCH 16/18 btrfs: simplify btrfs_wait_cache_io prototype
In reply to [email protected]From: Jeff Mahoney <[email protected]>
With the exception of the one case where btrfs_wait_cache_io is called without a block group, it's called with the same arguments. The root argument is only used in the special case, so let's factor out the core and simplify the call in the normal case to require a trans, block group, and path.
--- fs/btrfs/extent-tree.c | 15 ++++----------- fs/btrfs/free-space-cache.c | 40 ++++++++++++++++++++++++++++------------ fs/btrfs/free-space-cache.h | 6 ++---- 3 files changed, 34 insertions(+), 27 deletions(-)
fs/btrfs/extent-tree.c +4 -11
@@ -3610,9 +3610,7 @@ int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans,*/ if (!list_empty (&cache->io_list)) {list_del_init (&cache->io_list); -btrfs_wait_cache_io (root, trans, cache, - &cache->io_ctl, path, - cache->key.objectid); +btrfs_wait_cache_io (trans, cache, path);btrfs_put_block_group (cache); }
@@ -3767,9 +3765,7 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,if (!list_empty (&cache->io_list)) {spin_unlock (&cur_trans->dirty_bgs_lock);list_del_init (&cache->io_list); -btrfs_wait_cache_io (root, trans, cache, - &cache->io_ctl, path, - cache->key.objectid); +btrfs_wait_cache_io (trans, cache, path);btrfs_put_block_group (cache);spin_lock (&cur_trans->dirty_bgs_lock); }
@@ -3839,8 +3835,7 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans, cache = list_first_entry(io, struct btrfs_block_group_cache, io_list);list_del_init (&cache->io_list); -btrfs_wait_cache_io (root, trans, cache, - &cache->io_ctl, path, cache->key.objectid); +btrfs_wait_cache_io (trans, cache, path);btrfs_put_block_group (cache); }
@@ -10383,9 +10378,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,WARN_ON (!IS_ERR (inode) && inode != block_group->io_ctl.inode);spin_unlock (&trans->transaction->dirty_bgs_lock); -btrfs_wait_cache_io (root, trans, block_group, - &block_group->io_ctl, path, - block_group->key.objectid); +btrfs_wait_cache_io (trans, block_group, path);btrfs_put_block_group (block_group);spin_lock (&trans->transaction->dirty_bgs_lock); }
fs/btrfs/free-space-cache.c +28 -12
@@ -42,6 +42,10 @@ static int link_free_space(struct btrfs_free_space_ctl *ctl, struct btrfs_free_space *info);static void unlink_free_space (struct btrfs_free_space_ctl *ctl,struct btrfs_free_space *info); +static int btrfs_wait_cache_io_root (struct btrfs_root *root, +struct btrfs_trans_handle *trans, +struct btrfs_io_ctl *io_ctl, +struct btrfs_path *path); static struct inode *__lookup_free_space_inode(struct btrfs_root *root, struct btrfs_path *path,
@@ -244,9 +248,7 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root,if (!list_empty (&block_group->io_list)) {list_del_init (&block_group->io_list); -btrfs_wait_cache_io (root, trans, block_group, - &block_group->io_ctl, path, - block_group->key.objectid); +btrfs_wait_cache_io (trans, block_group, path);btrfs_put_block_group (block_group); }
@@ -1139,11 +1141,11 @@ cleanup_write_cache_enospc(struct inode *inode, GFP_NOFS); } -int btrfs_wait_cache_io (struct btrfs_root *root, -struct btrfs_trans_handle *trans, -struct btrfs_block_group_cache *block_group, -struct btrfs_io_ctl *io_ctl, -struct btrfs_path *path,u64 offset) +static int __btrfs_wait_cache_io (struct btrfs_root *root, +struct btrfs_trans_handle *trans, +struct btrfs_block_group_cache *block_group, +struct btrfs_io_ctl *io_ctl, +struct btrfs_path *path,u64 offset) {int ret;struct inode *inode = io_ctl->inode;
@@ -1154,9 +1156,6 @@ int btrfs_wait_cache_io(struct btrfs_root *root, fs_info =btrfs_sb (inode->i_sb); -if (block_group) - root = fs_info->tree_root; -/* Flush the dirty pages in the cache file. */ ret =flush_dirty_cache (inode);if (ret)
@@ -1207,6 +1206,23 @@ int btrfs_wait_cache_io(struct btrfs_root *root, } +static int btrfs_wait_cache_io_root (struct btrfs_root *root, +struct btrfs_trans_handle *trans, +struct btrfs_io_ctl *io_ctl, +struct btrfs_path *path) +{ +return __btrfs_wait_cache_io (root, trans,NULL , io_ctl, path,0 ); +} + +int btrfs_wait_cache_io (struct btrfs_trans_handle *trans, +struct btrfs_block_group_cache *block_group, +struct btrfs_path *path) +{ +return __btrfs_wait_cache_io (block_group->fs_info->tree_root, trans, + block_group, &block_group->io_ctl, + path, block_group->key.objectid); +} +/** * __btrfs_write_out_cache - write out cached info to an inode * @root - the root the inode belongs to
@@ -3541,7 +3557,7 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root,* with or without an error. */ release_metadata = false; - ret =btrfs_wait_cache_io (root, trans,NULL , &io_ctl, path,0 ); + ret =btrfs_wait_cache_io_root (root, trans, &io_ctl, path); }if (ret) {
fs/btrfs/free-space-cache.h +2 -4
@@ -67,11 +67,9 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root, struct inode *inode);int load_free_space_cache (struct btrfs_fs_info *fs_info,struct btrfs_block_group_cache *block_group); -int btrfs_wait_cache_io (struct btrfs_root *root, -struct btrfs_trans_handle *trans, +int btrfs_wait_cache_io (struct btrfs_trans_handle *trans,struct btrfs_block_group_cache *block_group, -struct btrfs_io_ctl *io_ctl, -struct btrfs_path *path,u64 offset); +struct btrfs_path *path); int btrfs_write_out_cache(struct btrfs_fs_info *fs_info, struct btrfs_trans_handle *trans, struct btrfs_block_group_cache *block_group,
Signature · 1 line
2.7.1
PATCH 18/18 btrfs: split btrfs_wait_marked_extents into normal and tree log functions
In reply to [email protected]From: Jeff Mahoney <[email protected]>
btrfs_write_and_wait_marked_extents and btrfs_sync_log both call btrfs_wait_marked_extents, which provides a core loop and then handles errors differently based on whether it's it's a log root or not.
This means that btrfs_write_and_wait_marked_extents needs to take a root because btrfs_wait_marked_extents requires one, even though it's only used to determine whether the root is a log root. The log root code won't ever call into the transaction commit code using a log root, so we can factor out the core loop and provide the error handling appropriate to each waiter in new routines. This allows us to eventually remove the root argument from btrfs_commit_transaction, and as a result, btrfs_end_transaction.
--- fs/btrfs/transaction.c | 79 +++++++++++++++++++++++++++++++------------------- fs/btrfs/transaction.h | 5 ++-- fs/btrfs/tree-log.c | 14 ++++----- 3 files changed, 58 insertions(+), 40 deletions(-)
fs/btrfs/transaction.c +49 -30
@@ -957,11 +957,11 @@ int btrfs_write_marked_extents(struct btrfs_fs_info *fs_info,* time a temporary error. So when it happens, ignore the error * and wait for writeback of this range to finish - because we * failed to set the bit EXTENT_NEED_WAIT for the range, a call -* to btrfs_wait_marked_extents() would not know that writeback -* for this range started and therefore wouldn't wait for it to -* finish - we don't want to commit a superblock that points to -* btree nodes/leafs for which writeback hasn't finished yet -* (and without errors). +* to __btrfs_wait_marked_extents() would not know that +* writeback for this range started and therefore wouldn't +* wait for it to finish - we don't want to commit a +* superblock that points to btree nodes/leafs for which +* writeback hasn't finished yet (and without errors). * We cleanup any entries left in the io tree when committing * the transaction (through clear_btree_io_tree()). */
@@ -989,17 +989,15 @@ int btrfs_write_marked_extents(struct btrfs_fs_info *fs_info,* those extents are on disk for transaction or log commit. We wait * on all the pages and clear them from the dirty pages state tree */ -int btrfs_wait_marked_extents (struct btrfs_root *root, -struct extent_io_tree *dirty_pages,int mark) +static int __btrfs_wait_marked_extents (struct btrfs_fs_info *fs_info, +struct extent_io_tree *dirty_pages) {int err =0 ;int werr =0 ; -struct btrfs_fs_info *fs_info = root->fs_info;struct address_space *mapping = fs_info->btree_inode->i_mapping;struct extent_state *cached_state =NULL ;u64 start =0 ;u64 end; -bool errors = false;while (!find_first_extent_bit (dirty_pages, start, &start, &end,EXTENT_NEED_WAIT , &cached_state)) {
@@ -1027,24 +1025,45 @@ int btrfs_wait_marked_extents(struct btrfs_root *root, }if (err) werr = err; +return werr; +} -if (root->root_key.objectid ==BTRFS_TREE_LOG_OBJECTID ) { -if ((mark &EXTENT_DIRTY ) && -test_and_clear_bit (BTRFS_FS_LOG1_ERR , &fs_info->flags)) - errors = true; +int btrfs_wait_extents (struct btrfs_fs_info *fs_info, +struct extent_io_tree *dirty_pages) +{ +bool errors = false; +int err; -if ((mark &EXTENT_NEW ) && -test_and_clear_bit (BTRFS_FS_LOG2_ERR , &fs_info->flags)) - errors = true; - }else { -if (test_and_clear_bit (BTRFS_FS_BTREE_ERR , &fs_info->flags)) - errors = true; - } + err =__btrfs_wait_marked_extents (fs_info, dirty_pages); +if (test_and_clear_bit (BTRFS_FS_BTREE_ERR , &fs_info->flags)) + errors = true; + +if (errors && !err) + err = -EIO ; +return err; +} -if (errors && !werr) - werr = -EIO ; +int btrfs_wait_tree_log_extents (struct btrfs_root *log_root,int mark) +{ +struct btrfs_fs_info *fs_info = log_root->fs_info; +struct extent_io_tree *dirty_pages = &log_root->dirty_log_pages; +bool errors = false; +int err; -return werr; +ASSERT (log_root->root_key.objectid ==BTRFS_TREE_LOG_OBJECTID ); + + err =__btrfs_wait_marked_extents (fs_info, dirty_pages); +if ((mark &EXTENT_DIRTY ) && +test_and_clear_bit (BTRFS_FS_LOG1_ERR , &fs_info->flags)) + errors = true; + +if ((mark &EXTENT_NEW ) && +test_and_clear_bit (BTRFS_FS_LOG2_ERR , &fs_info->flags)) + errors = true; + +if (errors && !err) + err = -EIO ; +return err; }/*
@@ -1052,7 +1071,7 @@ int btrfs_wait_marked_extents(struct btrfs_root *root,* them in one of two extent_io trees. This is used to make sure all of * those extents are on disk for transaction or log commit */ -static int btrfs_write_and_wait_marked_extents (struct btrfs_root *root, +static int btrfs_write_and_wait_marked_extents (struct btrfs_fs_info *fs_info,struct extent_io_tree *dirty_pages,int mark) {int ret;
@@ -1060,9 +1079,9 @@ static int btrfs_write_and_wait_marked_extents(struct btrfs_root *root,struct blk_plug plug;blk_start_plug (&plug); - ret =btrfs_write_marked_extents (root->fs_info, dirty_pages, mark); + ret =btrfs_write_marked_extents (fs_info, dirty_pages, mark);blk_finish_plug (&plug); - ret2 =btrfs_wait_marked_extents (root, dirty_pages, mark); + ret2 =btrfs_wait_extents (fs_info, dirty_pages);if (ret)return ret;
@@ -1072,11 +1091,11 @@ static int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, }static int btrfs_write_and_wait_transaction (struct btrfs_trans_handle *trans, -struct btrfs_root *root) +struct btrfs_fs_info *fs_info) {int ret; - ret =btrfs_write_and_wait_marked_extents (root, + ret =btrfs_write_and_wait_marked_extents (fs_info, &trans->transaction->dirty_pages,EXTENT_DIRTY );clear_btree_io_tree (&trans->transaction->dirty_pages);
@@ -1384,7 +1403,7 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans,if (ret) goto out;switch_commit_roots (trans->transaction, fs_info); - ret =btrfs_write_and_wait_transaction (trans, src); + ret =btrfs_write_and_wait_transaction (trans, fs_info);if (ret)btrfs_handle_fs_error (fs_info, ret,"Error while writing out transaction for qgroup" );
@@ -2231,7 +2250,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,wake_up (&fs_info->transaction_wait); - ret =btrfs_write_and_wait_transaction (trans, root); + ret =btrfs_write_and_wait_transaction (trans, fs_info);if (ret) {btrfs_handle_fs_error (fs_info, ret,"Error while writing out transaction" );
fs/btrfs/transaction.h +3 -2
@@ -221,8 +221,9 @@ int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans, struct btrfs_root *root);int btrfs_write_marked_extents (struct btrfs_fs_info *fs_info,struct extent_io_tree *dirty_pages,int mark); -int btrfs_wait_marked_extents (struct btrfs_root *root, -struct extent_io_tree *dirty_pages,int mark); +int btrfs_wait_extents (struct btrfs_fs_info *fs_info, +struct extent_io_tree *dirty_pages); +int btrfs_wait_tree_log_extents (struct btrfs_root *root,int mark);int btrfs_transaction_blocked (struct btrfs_fs_info *info);int btrfs_transaction_in_commit (struct btrfs_fs_info *info);void btrfs_put_transaction (struct btrfs_transaction *transaction);
fs/btrfs/tree-log.c +6 -8
@@ -2870,7 +2870,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,mutex_unlock (&log_root_tree->log_mutex); goto out; } -btrfs_wait_marked_extents (log, &log->dirty_log_pages, mark); +btrfs_wait_tree_log_extents (log, mark);btrfs_free_logged_extents (log, log_transid);mutex_unlock (&log_root_tree->log_mutex); ret = -EAGAIN ;
@@ -2888,8 +2888,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, index2 = root_log_ctx.log_transid %2 ;if (atomic_read (&log_root_tree->log_commit[index2])) {blk_finish_plug (&plug); - ret =btrfs_wait_marked_extents (log, &log->dirty_log_pages, - mark); + ret =btrfs_wait_tree_log_extents (log, mark);btrfs_wait_logged_extents (trans, log, log_transid);wait_log_commit (log_root_tree, root_log_ctx.log_transid);
@@ -2914,7 +2913,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,*/ if (btrfs_need_log_full_commit (fs_info, trans)) {blk_finish_plug (&plug); -btrfs_wait_marked_extents (log, &log->dirty_log_pages, mark); +btrfs_wait_tree_log_extents (log, mark);btrfs_free_logged_extents (log, log_transid);mutex_unlock (&log_root_tree->log_mutex); ret = -EAGAIN ;
@@ -2932,11 +2931,10 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,mutex_unlock (&log_root_tree->log_mutex); goto out_wake_log_root; } - ret =btrfs_wait_marked_extents (log, &log->dirty_log_pages, mark); + ret =btrfs_wait_tree_log_extents (log, mark);if (!ret) - ret =btrfs_wait_marked_extents (log_root_tree, - &log_root_tree->dirty_log_pages, -EXTENT_NEW |EXTENT_DIRTY ); + ret =btrfs_wait_tree_log_extents (log_root_tree, +EXTENT_NEW |EXTENT_DIRTY );if (ret) {btrfs_set_log_full_commit (fs_info, trans);btrfs_free_logged_extents (log, log_transid);
Signature · 1 line
2.7.1