From: Filipe Manana <fdmanana@gmail.com>
To: Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>, kernel-team@fb.com
Subject: Re: [PATCH 13/14] btrfs: pass the owner_root and level to alloc_extent_buffer
Date: Fri, 6 Nov 2020 11:54:18 +0000 [thread overview]
Message-ID: <CAL3q7H5Ek-p9z0reYiuo63=Gc8fdfVjxDZRmybRw0jZ2j12czQ@mail.gmail.com> (raw)
In-Reply-To: <6eb34e2f39e9c17cee9e2be74c86607a1e69f39b.1604591048.git.josef@toxicpanda.com>
On Thu, Nov 5, 2020 at 3:47 PM Josef Bacik <josef@toxicpanda.com> wrote:
>
> Now that we've plumbed all of the callers to have the owner root and the
> level, plumb it down into alloc_extent_buffer().
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
I couldn't get anymore the lockdep splat I reported before (after
applying the whole patchset of course), it used to happen very often
with btrfs/033.
Looks good, thanks.
> ---
> fs/btrfs/disk-io.c | 7 ++++---
> fs/btrfs/disk-io.h | 3 ++-
> fs/btrfs/extent-tree.c | 6 ++++--
> fs/btrfs/extent_io.c | 13 +++++++++----
> fs/btrfs/extent_io.h | 5 +++--
> fs/btrfs/reada.c | 8 +++++---
> fs/btrfs/relocation.c | 3 ++-
> fs/btrfs/tree-log.c | 4 +++-
> fs/btrfs/volumes.c | 3 ++-
> 9 files changed, 34 insertions(+), 18 deletions(-)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 934723785ab8..f14398b5d933 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -947,11 +947,12 @@ static const struct address_space_operations btree_aops = {
>
> struct extent_buffer *btrfs_find_create_tree_block(
> struct btrfs_fs_info *fs_info,
> - u64 bytenr)
> + u64 bytenr, u64 owner_root,
> + int level)
> {
> if (btrfs_is_testing(fs_info))
> return alloc_test_extent_buffer(fs_info, bytenr);
> - return alloc_extent_buffer(fs_info, bytenr);
> + return alloc_extent_buffer(fs_info, bytenr, owner_root, level);
> }
>
> /*
> @@ -970,7 +971,7 @@ struct extent_buffer *read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
> struct extent_buffer *buf = NULL;
> int ret;
>
> - buf = btrfs_find_create_tree_block(fs_info, bytenr);
> + buf = btrfs_find_create_tree_block(fs_info, bytenr, owner_root, level);
> if (IS_ERR(buf))
> return buf;
>
> diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
> index 41588babf2ed..e75ea6092942 100644
> --- a/fs/btrfs/disk-io.h
> +++ b/fs/btrfs/disk-io.h
> @@ -47,7 +47,8 @@ struct extent_buffer *read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
> int level, struct btrfs_key *first_key);
> struct extent_buffer *btrfs_find_create_tree_block(
> struct btrfs_fs_info *fs_info,
> - u64 bytenr);
> + u64 bytenr, u64 owner_root,
> + int level);
> void btrfs_clean_tree_block(struct extent_buffer *buf);
> int __cold open_ctree(struct super_block *sb,
> struct btrfs_fs_devices *fs_devices,
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index fe829bb528b5..14b6e19f6151 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -4612,7 +4612,7 @@ btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root,
> struct btrfs_fs_info *fs_info = root->fs_info;
> struct extent_buffer *buf;
>
> - buf = btrfs_find_create_tree_block(fs_info, bytenr);
> + buf = btrfs_find_create_tree_block(fs_info, bytenr, owner, level);
> if (IS_ERR(buf))
> return buf;
>
> @@ -5013,7 +5013,9 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
>
> next = find_extent_buffer(fs_info, bytenr);
> if (!next) {
> - next = btrfs_find_create_tree_block(fs_info, bytenr);
> + next = btrfs_find_create_tree_block(fs_info, bytenr,
> + root->root_key.objectid,
> + level - 1);
> if (IS_ERR(next))
> return PTR_ERR(next);
>
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index c9d652b0770a..a883350d5e7f 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -5171,7 +5171,7 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
> #endif
>
> struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
> - u64 start)
> + u64 start, u64 owner_root, int level)
> {
> unsigned long len = fs_info->nodesize;
> int num_pages;
> @@ -6119,19 +6119,22 @@ int try_release_extent_buffer(struct page *page)
> * btrfs_readahead_tree_block - attempt to readahead a child block.
> * @fs_info - the fs_info for the fs.
> * @bytenr - the bytenr to read.
> + * @owner_root - the objectid of the root that owns this eb.
> * @gen - the generation for the uptodate check, can be 0.
> + * @level - the level for the eb.
> *
> * Attempt to readahead a tree block at @bytenr. If @gen is 0 then we do a
> * normal uptodate check of the eb, without checking the generation. If we have
> * to read the block we will not block on anything.
> */
> void btrfs_readahead_tree_block(struct btrfs_fs_info *fs_info,
> - u64 bytenr, u64 gen)
> + u64 bytenr, u64 owner_root, u64 gen,
> + int level)
> {
> struct extent_buffer *eb;
> int ret;
>
> - eb = btrfs_find_create_tree_block(fs_info, bytenr);
> + eb = btrfs_find_create_tree_block(fs_info, bytenr, owner_root, level);
> if (IS_ERR(eb))
> return;
>
> @@ -6159,5 +6162,7 @@ void btrfs_readahead_node_child(struct extent_buffer *node, int slot)
> {
> btrfs_readahead_tree_block(node->fs_info,
> btrfs_node_blockptr(node, slot),
> - btrfs_node_ptr_generation(node, slot));
> + btrfs_header_owner(node),
> + btrfs_node_ptr_generation(node, slot),
> + btrfs_header_level(node) - 1);
> }
> diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
> index a211e90292f8..578c2e56c5e4 100644
> --- a/fs/btrfs/extent_io.h
> +++ b/fs/btrfs/extent_io.h
> @@ -182,7 +182,7 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo,
> void set_page_extent_mapped(struct page *page);
>
> struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
> - u64 start);
> + u64 start, u64 owner_root, int level);
> struct extent_buffer *__alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,
> u64 start, unsigned long len);
> struct extent_buffer *alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,
> @@ -199,7 +199,8 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait,
> int mirror_num);
> void wait_on_extent_buffer_writeback(struct extent_buffer *eb);
> void btrfs_readahead_tree_block(struct btrfs_fs_info *fs_info,
> - u64 bytenr, u64 gen);
> + u64 bytenr, u64 owner_root, u64 gen,
> + int level);
> void btrfs_readahead_node_child(struct extent_buffer *node, int slot);
>
> static inline int num_extent_pages(const struct extent_buffer *eb)
> diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
> index 83f4e6c53e46..8f26b3b22308 100644
> --- a/fs/btrfs/reada.c
> +++ b/fs/btrfs/reada.c
> @@ -656,12 +656,13 @@ static int reada_pick_zone(struct btrfs_device *dev)
> }
>
> static int reada_tree_block_flagged(struct btrfs_fs_info *fs_info, u64 bytenr,
> - int mirror_num, struct extent_buffer **eb)
> + u64 owner_root, int level, int mirror_num,
> + struct extent_buffer **eb)
> {
> struct extent_buffer *buf = NULL;
> int ret;
>
> - buf = btrfs_find_create_tree_block(fs_info, bytenr);
> + buf = btrfs_find_create_tree_block(fs_info, bytenr, owner_root, level);
> if (IS_ERR(buf))
> return 0;
>
> @@ -749,7 +750,8 @@ static int reada_start_machine_dev(struct btrfs_device *dev)
> logical = re->logical;
>
> atomic_inc(&dev->reada_in_flight);
> - ret = reada_tree_block_flagged(fs_info, logical, mirror_num, &eb);
> + ret = reada_tree_block_flagged(fs_info, logical, re->owner_root,
> + re->level, mirror_num, &eb);
> if (ret)
> __readahead_hook(fs_info, re, NULL, ret);
> else if (eb)
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 3e792bf31ecd..4551650a270d 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -2514,7 +2514,8 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans,
> rbtree_postorder_for_each_entry_safe(block, next, blocks, rb_node) {
> if (!block->key_ready)
> btrfs_readahead_tree_block(fs_info,
> - block->bytenr, 0);
> + block->bytenr, 0, 0,
> + block->level);
> }
>
> /* Get first keys */
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index eb86c632535a..b1f97be57bb3 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -2699,7 +2699,9 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
> btrfs_node_key_to_cpu(cur, &first_key, path->slots[*level]);
> blocksize = fs_info->nodesize;
>
> - next = btrfs_find_create_tree_block(fs_info, bytenr);
> + next = btrfs_find_create_tree_block(fs_info, bytenr,
> + btrfs_header_owner(cur),
> + *level - 1);
> if (IS_ERR(next))
> return PTR_ERR(next);
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 8beb91d3cd88..0ca2e96a9cda 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -6897,7 +6897,8 @@ int btrfs_read_sys_array(struct btrfs_fs_info *fs_info)
> * fixed to BTRFS_SUPER_INFO_SIZE. If nodesize > sb size, this will
> * overallocate but we can keep it as-is, only the first page is used.
> */
> - sb = btrfs_find_create_tree_block(fs_info, BTRFS_SUPER_INFO_OFFSET);
> + sb = btrfs_find_create_tree_block(fs_info, BTRFS_SUPER_INFO_OFFSET,
> + root->root_key.objectid, 0);
> if (IS_ERR(sb))
> return PTR_ERR(sb);
> set_extent_buffer_uptodate(sb);
> --
> 2.26.2
>
--
Filipe David Manana,
“Whether you think you can, or you think you can't — you're right.”
next prev parent reply other threads:[~2020-11-06 11:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 15:45 [PATCH 00/14][REBASED] Set the lockdep class on eb's at allocation time Josef Bacik
2020-11-05 15:45 ` [PATCH 01/14] btrfs: remove lockdep classes for the fs tree Josef Bacik
2020-11-06 11:50 ` Filipe Manana
2020-11-05 15:45 ` [PATCH 02/14] btrfs: cleanup extent buffer readahead Josef Bacik
2020-11-06 11:51 ` Filipe Manana
2020-11-09 15:09 ` David Sterba
2020-11-05 15:45 ` [PATCH 03/14] btrfs: use btrfs_read_node_slot in btrfs_realloc_node Josef Bacik
2020-11-06 11:51 ` Filipe Manana
2020-11-05 15:45 ` [PATCH 04/14] btrfs: use btrfs_read_node_slot in walk_down_reloc_tree Josef Bacik
2020-11-06 11:52 ` Filipe Manana
2020-11-05 15:45 ` [PATCH 05/14] btrfs: use btrfs_read_node_slot in do_relocation Josef Bacik
2020-11-06 11:52 ` Filipe Manana
2020-11-05 15:45 ` [PATCH 06/14] btrfs: use btrfs_read_node_slot in replace_path Josef Bacik
2020-11-06 11:53 ` Filipe Manana
2020-11-05 15:45 ` [PATCH 07/14] btrfs: use btrfs_read_node_slot in walk_down_tree Josef Bacik
2020-11-06 11:53 ` Filipe Manana
2020-11-05 15:45 ` [PATCH 08/14] btrfs: use btrfs_read_node_slot in qgroup_trace_extent_swap Josef Bacik
2020-11-06 11:53 ` Filipe Manana
2020-11-05 15:45 ` [PATCH 09/14] btrfs: use btrfs_read_node_slot in qgroup_trace_new_subtree_blocks Josef Bacik
2020-11-06 11:54 ` Filipe Manana
2020-11-05 15:45 ` [PATCH 10/14] btrfs: use btrfs_read_node_slot in btrfs_qgroup_trace_subtree Josef Bacik
2020-11-06 11:55 ` Filipe Manana
2020-11-05 15:45 ` [PATCH 11/14] btrfs: pass root owner to read_tree_block Josef Bacik
2020-11-06 11:55 ` Filipe Manana
2020-11-05 15:45 ` [PATCH 12/14] btrfs: pass the root owner and level around for reada Josef Bacik
2020-11-06 11:56 ` Filipe Manana
2020-11-05 15:45 ` [PATCH 13/14] btrfs: pass the owner_root and level to alloc_extent_buffer Josef Bacik
2020-11-06 11:54 ` Filipe Manana [this message]
2020-11-05 15:45 ` [PATCH 14/14] btrfs: set the lockdep class for ebs on creation Josef Bacik
2020-11-06 11:58 ` Filipe Manana
2020-11-09 16:50 ` [PATCH 00/14][REBASED] Set the lockdep class on eb's at allocation time David Sterba
-- strict thread matches above, loose matches on Subject: below --
2020-10-30 21:02 [PATCH 00/14] " Josef Bacik
2020-10-30 21:03 ` [PATCH 13/14] btrfs: pass the owner_root and level to alloc_extent_buffer Josef Bacik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAL3q7H5Ek-p9z0reYiuo63=Gc8fdfVjxDZRmybRw0jZ2j12czQ@mail.gmail.com' \
--to=fdmanana@gmail.com \
--cc=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).