Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH RFC 0/5] btrfs: scrub: introduce SCRUB_LOGICAL flag
@ 2023-06-17  5:07 Qu Wenruo
  2023-06-17  5:07 ` [PATCH RFC 1/5] btrfs: scrub: make scrub_ctx::stripes dynamically allocated Qu Wenruo
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Qu Wenruo @ 2023-06-17  5:07 UTC (permalink / raw)
  To: linux-btrfs

[BACKGROUND]
Scrub originally works in a per-device basis, that means if we want to
scrub the full fs, we would queue a scrub for each writeable device.

This is normally fine, but some behavior is not ideal like the
following:
		X	X+16K	X+32K
 Mirror 1	|XXXXXXX|       |
 Mirror 2	|       |XXXXXXX|

When scrubbing mirror 1, we found [X, X+16K) has corruption, then we
will try to read from mirror 2 and repair using the correct data.

This applies to range [X+16K, X+32K) of mirror 2, causing the good copy
to be read twice, which may or may not be a big deal.

But the problem can easily go crazy for RAID56, as its repair requires
the full stripe to be read out, so is its P/Q verification.


There are also some other minor problems, like due to the difference in
the disk read speed, we may be scrubbing different block groups on
different devices.
This can lead to reduced available space and higher chance of false
-ENOSPC.

[ENHANCEMENT]
Instead of the existing per-device scrub, this patchset introduce a new
flag, SCRUB_LOGICAL, to do logical address space based scrub.

Unlike per-device scrub, this new flag would make scrub a per-fs
operation.

This allows us to scrub the different mirrors in one go, and avoid
unnecessary read to repair the corruption.

This also makes user space handling much simpler, just one ioctl to
scrub the full fs, without the current multi-thread scrub code.

[TODO]
The long todo list is the main reason for RFC:

- Missing RAID56 handling
  Unlike pure mirror based profiles, RAID56 repair now needs to be
  handled inside scrub (or some new raid interfaces to handle fully
  cached stripes).

  This can be some extra investment, and add an exception for the
  elegant and simpler mirror based read-repair path.

- Better progs integration
  In theory we can silently try SCRUB_LOGICAL first, if the kernel
  doesn't support it, then fallback to the old multi-device scrub.

  But for current testing, a dedicated option is still assigned for
  scrub subcommand.

  And currently it only supports full report, no summary nor scrub file
  support.

- More testing
  Currently only very basic tests done, no stress tests yet.

Qu Wenruo (5):
  btrfs: scrub: make scrub_ctx::stripes dynamically allocated
  btrfs: scrub: introduce the skeleton for logical-scrub
  btrfs: scrub: extract the common preparation before scrubbing a block
    group
  btrfs: scrub: implement the basic extent iteration code
  btrfs: scrub: implement the repair part of scrub logical

 fs/btrfs/disk-io.c         |   1 +
 fs/btrfs/fs.h              |  12 +
 fs/btrfs/ioctl.c           |   6 +-
 fs/btrfs/scrub.c           | 757 ++++++++++++++++++++++++++++++-------
 fs/btrfs/scrub.h           |   2 +
 include/uapi/linux/btrfs.h |  11 +-
 6 files changed, 647 insertions(+), 142 deletions(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-06-20  9:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-17  5:07 [PATCH RFC 0/5] btrfs: scrub: introduce SCRUB_LOGICAL flag Qu Wenruo
2023-06-17  5:07 ` [PATCH RFC 1/5] btrfs: scrub: make scrub_ctx::stripes dynamically allocated Qu Wenruo
2023-06-20  8:43   ` Johannes Thumshirn
2023-06-17  5:07 ` [PATCH RFC 2/5] btrfs: scrub: introduce the skeleton for logical-scrub Qu Wenruo
2023-06-20  8:50   ` Johannes Thumshirn
2023-06-17  5:07 ` [PATCH RFC 3/5] btrfs: scrub: extract the common preparation before scrubbing a block group Qu Wenruo
2023-06-20  8:55   ` Johannes Thumshirn
2023-06-17  5:07 ` [PATCH RFC 4/5] btrfs: scrub: implement the basic extent iteration code Qu Wenruo
2023-06-17  5:07 ` [PATCH RFC 5/5] btrfs: scrub: implement the repair part of scrub logical Qu Wenruo
2023-06-20  9:24   ` Johannes Thumshirn
2023-06-17  5:12 ` [PATCH RFC 0/5] btrfs: scrub: introduce SCRUB_LOGICAL flag Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox