|
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 `btrfs scrub`, then |
| 6 | +only that device will be scrubbed. Although btrfs will also try to read other device |
| 7 | +to find a good copy, if the mirror on that specified device failed to be read or pass |
| 8 | +verification. |
| 9 | + |
| 10 | +If a path of btrfs is specified to `btrfs scrub`, btrfs will scrub all devices |
| 11 | +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 btrfs. |
| 19 | + |
| 20 | +.. warning:: |
| 21 | + Setting the ``No_COW`` (``chattr +C``) attribute on a file implicitly enables |
| 22 | + ``nodatasum``. This means that while metadata for these files continues to |
| 23 | + be validated and corrected by scrub, the actual file data is not. |
| 24 | + |
| 25 | + Furthermore, btrfs does not currently mark missing or failed disks as |
| 26 | + unreliable, so will continue to load-balance reads to potentially damaged |
| 27 | + replicas. This is not a problem normally because damage is detected by |
| 28 | + checksum validation, but because ``No_COW`` files are |
| 29 | + not protected by checksum, btrfs has no idea which mirror is good thus it can |
| 30 | + return the bad contents to the user space tool. |
| 31 | + |
| 32 | + Detecting and recovering from such failure requires manual intervention. |
| 33 | + |
| 34 | + Notably, `systemd sets +C on journals by default <https://github.com/systemd/systemd/commit/11689d2a021d95a8447d938180e0962cd9439763>`_, |
| 35 | + and `libvirt ≥ 6.6 sets +C on storage pool directories by default <https://www.libvirt.org/news.html#v6-6-0-2020-08-02>`_. |
| 36 | + Other applications or distributions may also set +C to try to improve |
| 37 | + performance. |
4 | 38 |
|
5 | 39 | .. 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. |
| 40 | + Scrub is not a filesystem checker (fsck). It can only detect filesystem damage |
| 41 | + using the checksum validation, and it can only repair |
| 42 | + filesystem damage by copying from other known good replicas. |
| 43 | + |
| 44 | + :doc:`btrfs-check` performs more exhaustive checking and can sometimes be |
| 45 | + used, with expert guidance, to rebuild certain corrupted filesystem structures |
| 46 | + in the absence of any good replica. |
12 | 47 |
|
13 | 48 | The user is supposed to run it manually or via a periodic system service. The
|
14 | 49 | recommended period is a month but it could be less. The estimated device bandwidth
|
|
0 commit comments