From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v3 00/12] btrfs: scrub: use a more reader friendly code to implement scrub_simple_mirror()
Date: Mon, 20 Mar 2023 10:12:46 +0800 [thread overview]
Message-ID: <cover.1679278088.git.wqu@suse.com> (raw)
This series can be found in my github repo:
https://github.com/adam900710/linux/tree/scrub_stripe
It's recommended to fetch from the repo, as our misc-next seems to
change pretty rapidly.
[Changelog]
v3:
- Add a dedicated @fs_info member for btrfs_bio
Unfortunately although we have a 32 bytes hole between @end_io_work and @bio,
compiler still choose not to use that hole for whatever reasons.
Thus this would increase the size of btrfs_bio by 4 bytes.
- Rebased to lastest misc-next
- Fix various while space error not caught by btrfs-workflow
v2:
- Use batched scrub_stripe submission
This allows much better performance compared to the old scrub code
- Add scrub specific bio layer helpers
This makes the scrub code to be completely rely on logical bytenr +
mirror_num.
[PROBLEMS OF OLD SCRUB]
- Too many delayed jumps, making it hard to read
Even starting from scrub_simple_mirror(), we have the following
functions:
scrub_extent()
|
v
scrub_sectors()
|
v
scrub_add_sector_to_rd_bio()
| endio function
v
scrub_bio_end_io()
| delayed work
v
scrub_bio_end_io_worker()
|
v
scrub_block_complete()
|
v
scrub_handle_errored_blocks()
|
v
scrub_recheck_block()
|
v
scrub_repair_sector_from_good_copy()
Not to mention the hidden jumps in certain branches.
- IOPS inefficient for fragmented extents
The real block size of scrub read is between 4K and 128K.
If the extents are not adjacent, the blocksize drops to 4K and would
be an IOPS disaster.
- All hardcoded to do the logical -> physical mapping by scrub itself
No usage of any existing bio facilities.
And even implemented a RAID56 recovery wrapper.
[NEW SCRUB_STRIPE BASED SOLUTION]
- Overall streamlined code base
queue_scrub_stripe()
|
v
scrub_find_fill_first_stripe()
|
v
done
Or
queue_scrub_stripe()
|
v
flush_scrub_stripes()
|
v
scrub_submit_initial_read()
| endio function
v
scrub_read_endio()
| delayed work
v
scrub_stripe_read_repair_worker()
|
v
scrub_verify_one_stripe()
|
v
scrub_stripe_submit_repair_read()
|
v
scrub_write_sectors()
|
v
scrub_stripe_report_errors()
Only one endio and delayed work, all other work are properly done in a
sequential workflow.
- Always read in 64KiB block size
The real blocksize of read starts at 64KiB, and ends at 512K.
This already results a better performance even for the worst case:
With patchset: 404.81MiB/s
Without patchset: 369.30MiB/s
Around 10% performance improvement on an SATA SSD.
- All logical bytenr/mirror_num based read and write
With the new single stripe fast path in btrfs_submit_bio(), scrub can
reuse most of the bio layer code, result much simpler scrub code.
[TODO]
- More testing on zoned devices
Now the patchset can already pass all scrub/replace groups with
regular devices.
- More cleanup on RAID56 path
Now RAID56 still uses some old facility, resulting things like
scrub_sector and scrub_bio can not be fully cleaned up.
Qu Wenruo (12):
btrfs: scrub: use dedicated super block verification function to scrub
one super block
btrfs: introduce a new helper to submit bio for scrub
btrfs: introduce a new helper to submit write bio for scrub
btrfs: scrub: introduce the structure for new BTRFS_STRIPE_LEN based
interface
btrfs: scrub: introduce a helper to find and fill the sector info for
a scrub_stripe
btrfs: scrub: introduce a helper to verify one metadata
btrfs: scrub: introduce a helper to verify one scrub_stripe
btrfs: scrub: introduce the main read repair worker for scrub_stripe
btrfs: scrub: introduce a writeback helper for scrub_stripe
btrfs: scrub: introduce error reporting functionality for scrub_stripe
btrfs: scrub: introduce the helper to queue a stripe for scrub
btrfs: scrub: switch scrub_simple_mirror() to scrub_stripe
infrastructure
fs/btrfs/bio.c | 144 +++-
fs/btrfs/bio.h | 20 +-
fs/btrfs/file-item.c | 9 +-
fs/btrfs/file-item.h | 3 +-
fs/btrfs/raid56.c | 2 +-
fs/btrfs/scrub.c | 1658 ++++++++++++++++++++++++++++++------------
6 files changed, 1351 insertions(+), 485 deletions(-)
--
2.39.2
next reply other threads:[~2023-03-20 2:13 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-20 2:12 Qu Wenruo [this message]
2023-03-20 2:12 ` [PATCH v3 01/12] btrfs: scrub: use dedicated super block verification function to scrub one super block Qu Wenruo
2023-03-21 5:22 ` Anand Jain
2023-03-21 7:25 ` Qu Wenruo
2023-03-21 22:12 ` David Sterba
2023-03-20 2:12 ` [PATCH v3 02/12] btrfs: introduce a new helper to submit bio for scrub Qu Wenruo
2023-03-21 12:02 ` Christoph Hellwig
2023-03-24 9:58 ` Qu Wenruo
2023-03-25 8:09 ` Christoph Hellwig
2023-03-25 8:21 ` Qu Wenruo
2023-03-25 8:31 ` Christoph Hellwig
2023-03-25 8:48 ` Qu Wenruo
2023-03-27 3:36 ` Christoph Hellwig
2023-03-20 2:12 ` [PATCH v3 03/12] btrfs: introduce a new helper to submit write " Qu Wenruo
2023-03-21 0:14 ` David Sterba
2023-03-21 0:54 ` Qu Wenruo
2023-03-21 1:27 ` David Sterba
2023-03-23 8:48 ` Qu Wenruo
2023-03-20 2:12 ` [PATCH v3 04/12] btrfs: scrub: introduce the structure for new BTRFS_STRIPE_LEN based interface Qu Wenruo
2023-03-21 0:22 ` David Sterba
2023-03-20 2:12 ` [PATCH v3 05/12] btrfs: scrub: introduce a helper to find and fill the sector info for a scrub_stripe Qu Wenruo
2023-03-20 2:12 ` [PATCH v3 06/12] btrfs: scrub: introduce a helper to verify one metadata Qu Wenruo
2023-03-21 0:31 ` David Sterba
2023-03-20 2:12 ` [PATCH v3 07/12] btrfs: scrub: introduce a helper to verify one scrub_stripe Qu Wenruo
2023-03-20 2:12 ` [PATCH v3 08/12] btrfs: scrub: introduce the main read repair worker for scrub_stripe Qu Wenruo
2023-03-20 2:12 ` [PATCH v3 09/12] btrfs: scrub: introduce a writeback helper " Qu Wenruo
2023-03-21 0:43 ` David Sterba
2023-03-20 2:12 ` [PATCH v3 10/12] btrfs: scrub: introduce error reporting functionality " Qu Wenruo
2023-03-20 2:12 ` [PATCH v3 11/12] btrfs: scrub: introduce the helper to queue a stripe for scrub Qu Wenruo
2023-03-20 2:12 ` [PATCH v3 12/12] btrfs: scrub: switch scrub_simple_mirror() to scrub_stripe infrastructure Qu Wenruo
2023-03-21 1:12 ` David Sterba
2023-03-21 0:09 ` [PATCH v3 00/12] btrfs: scrub: use a more reader friendly code to implement scrub_simple_mirror() David Sterba
2023-03-23 6:28 ` Qu Wenruo
2023-03-23 17:51 ` David Sterba
2023-03-24 0:42 ` Qu Wenruo
2023-03-27 23:28 ` 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=cover.1679278088.git.wqu@suse.com \
--to=wqu@suse.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