From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Christoph Hellwig <hch@infradead.org>, Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH RFC v2 04/12] btrfs: add btrfs_read_repair_ctrl to record corrupted sectors
Date: Fri, 29 Apr 2022 06:51:50 +0800 [thread overview]
Message-ID: <b27d0b0f-89de-13a5-013b-323e03d7cc40@gmx.com> (raw)
In-Reply-To: <YmqYm+iFDSRTbV5W@infradead.org>
On 2022/4/28 21:37, Christoph Hellwig wrote:
> On Wed, Apr 27, 2022 at 03:18:50PM +0800, Qu Wenruo wrote:
>> Currently we only allocate two bitmaps and initialize various members,
>> no real work done yet.
>
> I'm rather worried about these allocations. These are called from
> the I/O completion work queues, which can be rather deadlock heavy.
> Never mind that just failing an I/O repair/recovery when we are out
> of memory seems like a rather bad idea.
That's why there is a btrfs_read_repair_ctrl::error member.
If we failed the memory allocation, then we will not do any repair.
To me, memory allocation is a much bigger problem.
Although we can put the bitmap into btrfs_bio structure, and
pre-allocate it for every bio we're going to submit.
But I'm not sure if the pre-allocation way is a good idea, considering
read-repair should be a relatively code path.
>
>> + if (!ctrl->initialized) {
>
> I don't think you need the initialize field. Just check for
> failed_bio being non-NULL to simplify this.
That's indeed simpler.
>
>> + const u32 sectorsize = fs_info->sectorsize;
>> +
>> + ASSERT(ctrl->cur_bad_bitmap == NULL &&
>> + ctrl->prev_bad_bitmap == NULL);
>> + /*
>> + * failed_bio->bi_iter is not reliable at endio time, thus we
>> + * must rely on btrfs_bio::iter to grab the original logical
>> + * bytenr.
>> + */
>> + ASSERT(btrfs_bio(failed_bio)->iter.bi_size);
>
> Also things would be lot more readable if the code inside this branch
> just moved into a helper that you call if ->failed_bio is not set.
Indeed.
>
>> + ctrl->cur_bad_bitmap = bitmap_alloc(ctrl->bio_size >>
>> + fs_info->sectorsize_bits, GFP_NOFS);
>> + ctrl->prev_bad_bitmap = bitmap_alloc(ctrl->bio_size >>
>> + fs_info->sectorsize_bits, GFP_NOFS);
>> + /* Just set the error bit, so we will never try repair */
>> + if (!ctrl->cur_bad_bitmap || !ctrl->prev_bad_bitmap) {
>> + kfree(ctrl->cur_bad_bitmap);
>> + kfree(ctrl->prev_bad_bitmap);
>> + ctrl->cur_bad_bitmap = NULL;
>> + ctrl->prev_bad_bitmap = NULL;
>> + ctrl->error = true;
>> + }
>
> I don't think we need the extra error value either, you can just check
> one of the bitmap pointers for NULL. That being said, as mentioned
> above I'm really worried about these huge allocations that can fail.
> I think we need a mempool of some fixed size here and use that, and just
> change the algorithm to work in chunks based on this upper bound.
>
>> +/* Strucutre for data read time repair. */
>> +struct btrfs_read_repair_ctrl {
>
> Can we keep that structure private? Based on the rest of the series
> there actually is a fair amount of code using it, what about isolating
> it in a new read_repair.c instead of in the giant extent_io.c and
> inode.c files?
I was considering putting it into read_repair.c, and since you're also
mentioning that, I guess it's a good idea now.
And if we're going to make that structure private, I guess we have to
pre-allocate it in btrfs_bio as a pointer then.
Thanks,
Qu
next prev parent reply other threads:[~2022-04-28 22:52 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1651043617.git.wqu@suse.com>
2022-04-27 7:18 ` [PATCH RFC v2 01/12] btrfs: introduce a pure data checksum checking helper Qu Wenruo
2022-04-28 13:26 ` Christoph Hellwig
2022-04-27 7:18 ` [PATCH RFC v2 02/12] btrfs: always save bio::bi_iter into btrfs_bio::iter before submitting Qu Wenruo
2022-04-28 5:16 ` Qu Wenruo
2022-04-28 13:32 ` Christoph Hellwig
2022-04-28 22:41 ` Qu Wenruo
2022-04-29 15:09 ` Christoph Hellwig
2022-04-29 23:04 ` Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 03/12] btrfs: remove duplicated parameters from submit_data_read_repair() Qu Wenruo
2022-04-28 13:32 ` Christoph Hellwig
2022-04-27 7:18 ` [PATCH RFC v2 04/12] btrfs: add btrfs_read_repair_ctrl to record corrupted sectors Qu Wenruo
2022-04-28 13:37 ` Christoph Hellwig
2022-04-28 22:51 ` Qu Wenruo [this message]
2022-04-29 0:09 ` Qu Wenruo
2022-04-29 15:12 ` Christoph Hellwig
2022-04-29 15:11 ` Christoph Hellwig
2022-04-27 7:18 ` [PATCH RFC v2 05/12] btrfs: add a helper to queue a corrupted sector for read repair Qu Wenruo
2022-04-28 5:20 ` Qu Wenruo
2022-04-28 13:44 ` Christoph Hellwig
2022-04-28 22:55 ` Qu Wenruo
2022-04-29 7:11 ` Qu Wenruo
2022-04-29 15:14 ` Christoph Hellwig
2022-04-29 23:08 ` Qu Wenruo
2022-05-01 23:59 ` Qu Wenruo
2022-05-02 16:45 ` Christoph Hellwig
2022-05-02 23:00 ` Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 06/12] btrfs: introduce a helper to repair from one mirror Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 07/12] btrfs: allow btrfs read repair to submit all writes in one go Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 08/12] btrfs: switch buffered read to the new btrfs_read_repair_* based repair routine Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 09/12] btrfs: switch direct IO routine to use btrfs_read_repair_ctrl Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 10/12] btrfs: cleanup btrfs_repair_one_sector() Qu Wenruo
2022-04-28 13:45 ` Christoph Hellwig
2022-04-27 7:18 ` [PATCH RFC v2 11/12] btrfs: remove io_failure_record infrastructure completely Qu Wenruo
2022-04-27 7:18 ` [PATCH RFC v2 12/12] btrfs: remove btrfs_inode::io_failure_tree 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=b27d0b0f-89de-13a5-013b-323e03d7cc40@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=hch@infradead.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox