From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Anand Jain <anand.jain@oracle.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/2] btrfs: fix BUG_ON with proper error handle in find_next_devid
Date: Tue, 27 Aug 2019 16:12:50 +0800 [thread overview]
Message-ID: <2a203bdb-7cde-f970-6e33-38ba5f190c1b@gmx.com> (raw)
In-Reply-To: <20190827074045.5563-2-anand.jain@oracle.com>
[-- Attachment #1.1: Type: text/plain, Size: 1366 bytes --]
On 2019/8/27 下午3:40, Anand Jain wrote:
> In a corrupted tree if search for next devid finds the device with
> devid = -1, then report the error -EUCLEAN back to the parent
> function to fail gracefully.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> fs/btrfs/volumes.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 4db4a100c05b..36aa5f79fb6c 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -1849,7 +1849,12 @@ static noinline int find_next_devid(struct btrfs_fs_info *fs_info,
> if (ret < 0)
> goto error;
>
> - BUG_ON(ret == 0); /* Corruption */
> + if (ret == 0) {
> + /* Corruption */
> + btrfs_err(fs_info, "corrupted chunk tree devid -1 matched");
It will never hit this branch.
As in tree checker, we have checked if the devid is so large that a
chunk item or system chunk array can't contain one.
That limit is way smaller than (u64)-1.
Thus if we really have a key (DEV_ITEMS DEV_ITEM -1), it will be
rejected by tree-checker in the first place, thus you will get a ret ==
-EUCLEAN from previous btrfs_search_slot() call.
Thanks,
Qu
> + ret = -EUCLEAN;
> + goto error;
> + }
>
> ret = btrfs_previous_item(fs_info->chunk_root, path,
> BTRFS_DEV_ITEMS_OBJECTID,
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-08-27 8:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-27 7:40 [PATCH 0/2] fix BUG_ON and retun real error in find_next_devid() and clone_fs_devices() Anand Jain
2019-08-27 7:40 ` [PATCH 1/2] btrfs: fix BUG_ON with proper error handle in find_next_devid Anand Jain
2019-08-27 8:07 ` Johannes Thumshirn
2019-08-27 8:12 ` Qu Wenruo [this message]
2019-08-27 9:58 ` Anand Jain
2019-08-27 11:11 ` Qu Wenruo
2019-08-27 7:40 ` [PATCH 2/2] btrfs: fix error return on alloc fail in clone_fs_devices Anand Jain
2019-08-27 8:12 ` Johannes Thumshirn
2019-08-27 7:59 ` [PATCH 0/2] fix BUG_ON and retun real error in find_next_devid() and clone_fs_devices() Nikolay Borisov
2019-08-27 13:25 ` David Sterba
2019-08-27 13:28 ` Nikolay Borisov
2019-08-27 23:12 ` Anand Jain
2019-09-10 8:57 ` Anand Jain
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=2a203bdb-7cde-f970-6e33-38ba5f190c1b@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=anand.jain@oracle.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