From: Qu Wenruo <wqu@suse.de>
To: Nikolay Borisov <nborisov@suse.com>, linux-btrfs@vger.kernel.org
Cc: Yoon Jungyeon <jungyeon@gatech.edu>
Subject: Re: [PATCH] btrfs: Check the first key and level for cached extent buffer
Date: Tue, 12 Mar 2019 16:05:38 +0800 [thread overview]
Message-ID: <37ff2d4f-5823-e150-175e-2a397d84ea13@suse.de> (raw)
In-Reply-To: <f11bba01-1955-b3ba-f824-d999c18578a6@suse.com>
On 2019/3/12 下午3:57, Nikolay Borisov wrote:
[snip]
>> *eb_ret = tmp;
>> return 0;
>> }
>> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
>> index 298b34721bc0..e2a0cb362d28 100644
>> --- a/fs/btrfs/disk-io.c
>> +++ b/fs/btrfs/disk-io.c
>> @@ -423,9 +423,9 @@ static int btrfs_check_super_csum(struct btrfs_fs_info *fs_info,
>> return ret;
>> }
>>
>> -static int verify_level_key(struct btrfs_fs_info *fs_info,
>> - struct extent_buffer *eb, int level,
>> - struct btrfs_key *first_key, u64 parent_transid)
>> +int btrfs_verify_level_key(struct btrfs_fs_info *fs_info,
>> + struct extent_buffer *eb, int level,
>> + struct btrfs_key *first_key, u64 parent_transid)
>> {
>> int found_level;
>> struct btrfs_key found_key;
>> @@ -500,8 +500,8 @@ static int btree_read_extent_buffer_pages(struct btrfs_fs_info *fs_info,
>> if (verify_parent_transid(io_tree, eb,
>> parent_transid, 0))
>> ret = -EIO;
>> - else if (verify_level_key(fs_info, eb, level,
>> - first_key, parent_transid))
>> + else if (btrfs_verify_level_key(fs_info, eb, level,
>> + first_key, parent_transid))
>> ret = -EUCLEAN;
>
> Actually why is the buffer still held when we return EUCLEAN since in
> read_tree_block if btree_read_extent_buffer_pages returns an error
> free_extent_buffer should be called and it should delete the eb from eb
> cache, no ?
Yes, that's the ideal case.
But there is a hole where we could read tree block without first_key
check, just as mentioned it's scrub.
In that case extent buffer will be cached anyway, so we can't skip the
check here.
Thanks,
Qu
> IMO the correct behavior should be to remove the corrupted
> buffer ASAP and not rely on later validation.
>
>> else
>> break;
>> diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
>> index 987a64bc0c66..67a9fe2d29c7 100644
>> --- a/fs/btrfs/disk-io.h
>> +++ b/fs/btrfs/disk-io.h
>> @@ -39,6 +39,9 @@ static inline u64 btrfs_sb_offset(int mirror)
>> struct btrfs_device;
>> struct btrfs_fs_devices;
>>
>> +int btrfs_verify_level_key(struct btrfs_fs_info *fs_info,
>> + struct extent_buffer *eb, int level,
>> + struct btrfs_key *first_key, u64 parent_transid);
>> struct extent_buffer *read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
>> u64 parent_transid, int level,
>> struct btrfs_key *first_key);
>>
next prev parent reply other threads:[~2019-03-12 8:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-12 7:45 [PATCH] btrfs: Check the first key and level for cached extent buffer Qu Wenruo
2019-03-12 7:57 ` Nikolay Borisov
2019-03-12 8:05 ` Qu Wenruo [this message]
2019-03-12 8:11 ` Nikolay Borisov
2019-03-12 8:32 ` Qu Wenruo
2019-03-12 8:34 ` Nikolay Borisov
2019-03-12 8:39 ` Qu Wenruo
2019-03-12 8:28 ` Nikolay Borisov
2019-03-12 8:34 ` Qu Wenruo
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=37ff2d4f-5823-e150-175e-2a397d84ea13@suse.de \
--to=wqu@suse.de \
--cc=jungyeon@gatech.edu \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.