From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: remove assertion when searching for a key in a node/leaf
Date: Wed, 20 Feb 2019 19:45:04 +0800 [thread overview]
Message-ID: <83dfeab3-15c0-9c11-bc1b-e4f1f067bd11@gmx.com> (raw)
In-Reply-To: <20190220111143.15911-1-fdmanana@kernel.org>
[-- Attachment #1.1: Type: text/plain, Size: 2226 bytes --]
On 2019/2/20 下午7:11, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> At ctree.c:key_search(), the assertion that verifies the first key on a
> child extent buffer corresponds to the key at a specific slot in the
> parent has a disadvantage: we effectively hit a BUG_ON() which requires
> rebooting the machine later. It also does not tell any information about
> which extent buffer is affected, from which root, the expected and found
> keys, etc.
>
> However as of commit 581c1760415c48 ("btrfs: Validate child tree block's
> level and first key"), that assertion is not needed since at the time we
> read an extent buffer from disk we validate that its first key matches the
> key, at the respective slot, in the parent extent buffer. Therefore just
> remove the assertion at key_search().
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/ctree.c | 21 ---------------------
> 1 file changed, 21 deletions(-)
>
> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> index 5b9f602fb9e2..e754bd019618 100644
> --- a/fs/btrfs/ctree.c
> +++ b/fs/btrfs/ctree.c
> @@ -2529,26 +2529,6 @@ setup_nodes_for_search(struct btrfs_trans_handle *trans,
> return ret;
> }
>
> -static void key_search_validate(struct extent_buffer *b,
> - const struct btrfs_key *key,
> - int level)
> -{
> -#ifdef CONFIG_BTRFS_ASSERT
> - struct btrfs_disk_key disk_key;
> -
> - btrfs_cpu_key_to_disk(&disk_key, key);
> -
> - if (level == 0)
> - ASSERT(!memcmp_extent_buffer(b, &disk_key,
> - offsetof(struct btrfs_leaf, items[0].key),
> - sizeof(disk_key)));
> - else
> - ASSERT(!memcmp_extent_buffer(b, &disk_key,
> - offsetof(struct btrfs_node, ptrs[0].key),
> - sizeof(disk_key)));
> -#endif
> -}
> -
> static int key_search(struct extent_buffer *b, const struct btrfs_key *key,
> int level, int *prev_cmp, int *slot)
> {
> @@ -2557,7 +2537,6 @@ static int key_search(struct extent_buffer *b, const struct btrfs_key *key,
> return *prev_cmp;
> }
>
> - key_search_validate(b, key, level);
> *slot = 0;
>
> return 0;
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-02-20 11:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-20 11:11 [PATCH] Btrfs: remove assertion when searching for a key in a node/leaf fdmanana
2019-02-20 11:45 ` Qu Wenruo [this message]
2019-02-22 14:34 ` David Sterba
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=83dfeab3-15c0-9c11-bc1b-e4f1f067bd11@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=fdmanana@kernel.org \
--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).