|
1 | | -Scrub is a pass over all filesystem data and metadata and verifying the |
2 | | -checksums. If a valid copy is available (replicated block group profiles) then |
3 | | -the damaged one is repaired. All copies of the replicated profiles are validated. |
| 1 | +Scrub is a validation pass over all filesystem data and metadata that detects |
| 2 | +data checksum errors, basic super block errors, basic metadata block header errors, |
| 3 | +and disk read errors. |
| 4 | + |
| 5 | +Scrub is done on a per-device base, if a device is specified to :command:`btrfs scrub start`, |
| 6 | +then only that device will be scrubbed. Although btrfs will also try to read |
| 7 | +other device to find a good copy, if the mirror on that specified device failed |
| 8 | +to be read or pass verification. |
| 9 | + |
| 10 | +If a path of btrfs is specified to :command:`btrfs scrub start`, btrfs will scrub |
| 11 | +all devices in parallel. |
| 12 | + |
| 13 | +On filesystems that use replicated block group profiles (e.g. RAID1), read-write |
| 14 | +scrub will also automatically repair any damage by copying verified good data |
| 15 | +from one of the other replicas. |
| 16 | + |
| 17 | +Such automatic repair is also carried out when reading metadata or data from a |
| 18 | +read-write mounted filesystem. |
| 19 | + |
| 20 | +.. warning:: |
| 21 | + As currently implemented, setting the ``NOCOW`` file attribute (by |
| 22 | + :command:`chattr +C`) on a file implicitly enables |
| 23 | + ``NODATASUM``. This means that while metadata for these files continues to |
| 24 | + be validated and corrected by scrub, the actual file data is not. |
| 25 | + |
| 26 | + Furthermore, btrfs does not currently mark missing or failed disks as |
| 27 | + unreliable, so will continue to load-balance reads to potentially damaged |
| 28 | + replicas. This is not a problem normally because damage is detected by |
| 29 | + checksum validation, but because ``NOCOW`` files are |
| 30 | + not protected by checksums, btrfs has no idea which mirror is good thus it can |
| 31 | + return the bad contents to the user space tool. |
| 32 | + |
| 33 | + Detecting and recovering from such failure requires manual intervention. |
| 34 | + |
| 35 | + Notably, `systemd sets +C on journals by default <https://github.com/systemd/systemd/commit/11689d2a021d95a8447d938180e0962cd9439763>`__, |
| 36 | + and `libvirt ≥ 6.6 sets +C on storage pool directories by default <https://www.libvirt.org/news.html#v6-6-0-2020-08-02>`__. |
| 37 | + Other applications or distributions may also set ``+C`` to try to improve |
| 38 | + performance. |
4 | 39 |
|
5 | 40 | .. note:: |
6 | | - Scrub is not a filesystem checker (fsck) and does not verify nor repair |
7 | | - structural damage in the filesystem. It really only checks checksums of data |
8 | | - and tree blocks, it doesn't ensure the content of tree blocks is valid and |
9 | | - consistent. There's some validation performed when metadata blocks are read |
10 | | - from disk (:doc:`Tree-checker`) but it's not extensive and cannot substitute |
11 | | - full :doc:`btrfs-check` run. |
| 41 | + Scrub is not a filesystem checker (fsck, :doc:`btrfs-check`). It can only detect |
| 42 | + filesystem damage using the checksum validation, and it can only repair |
| 43 | + filesystem damage by copying from other known good replicas. |
| 44 | + |
| 45 | + :doc:`btrfs-check` performs more exhaustive checking and can sometimes be |
| 46 | + used, with expert guidance, to rebuild certain corrupted filesystem structures |
| 47 | + in the absence of any good replica. |
12 | 48 |
|
13 | 49 | The user is supposed to run it manually or via a periodic system service. The |
14 | 50 | recommended period is a month but it could be less. The estimated device bandwidth |
|
0 commit comments