Skip to content

Commit 5e5e4c5

Browse files
committed
man: document --repair-crypt-mismatches and --free-crypt-fallback
zpool-scrub(8) gets two new option entries describing the new flags introduced by the BP_USES_CRYPT repair pipeline. zpoolconcepts(7) gets a new "Encryption Flag Mismatches Repair" subsection summarising the bug class, the three repair dispositions (Mode 1.5 smart flip, Mode 3 hole+free, log-only for unrepairable indirects), the eligibility skip list, and the existing user-space alternative ('zfs send -U | zfs recv' onto a fresh pool). Both pages validate cleanly via 'man --warnings -Z'. No code changes. Refs: openzfs#14330 openzfs#15275 openzfs#15464 openzfs#16065 openzfs#18587 Signed-off-by: Jerzy Kołosowski <jerzy@kolosowscy.pl>
1 parent 9827d24 commit 5e5e4c5

2 files changed

Lines changed: 153 additions & 1 deletion

File tree

man/man7/zpoolconcepts.7

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,83 @@ ZFS attempts to bring the device online automatically.
349349
Device attachment detection is hardware-dependent
350350
and might not be supported on all platforms.
351351
.
352+
.Ss Encryption Flag Mismatches Repair
353+
On natively encrypted datasets every block pointer must carry the
354+
.Sy BP_USES_CRYPT
355+
flag.
356+
A small class of rare write-path corruption can leave that flag clear
357+
on otherwise-encrypted blocks; the symptom is an
358+
.Sy EIO
359+
on read of the affected offset and, historically, a kernel panic in
360+
.Fn zfs_mknode .
361+
Issues
362+
.Pq see Sy openzfs/zfs#14330 #15275 #15464 #16065
363+
have been reported intermittently from ZFS 2.0.x through 2.4.x.
364+
.Pp
365+
.Nm zpool Cm scrub
366+
detects this state and reports the affected file in
367+
.Nm zpool Cm status Fl v .
368+
With the
369+
.Sy crypt_repair
370+
feature enabled
371+
.Pq read-compatible ,
372+
the
373+
.Fl -repair-crypt-mismatches
374+
scrub flag attempts in-kernel recovery per BP, in this order:
375+
.Bl -bullet -compact -offset indent
376+
.It
377+
.Em Smart flip
378+
.Pq Mode 1.5 :
379+
decrypt the on-disk block under the dataset key, recompute the MAC, and
380+
if it matches the value stored in
381+
.Sy blk_cksum ,
382+
restore the CRYPT flag on the parent dnode or indirect block.
383+
Lossless - no data is rewritten.
384+
.It
385+
.Em Hole and free
386+
.Pq Mode 3 .
387+
If MAC verification fails on a leaf block and the operator opted in
388+
with
389+
.Fl -free-crypt-fallback ,
390+
the leaf is freed and the parent's reference becomes a hole.
391+
The affected file accumulates zeros at that offset; the rest of the
392+
file remains accessible.
393+
Destructive - not enabled unless explicitly requested.
394+
.It
395+
.Em Log only .
396+
For an indirect BP whose MAC-of-MAC verification fails, the block is
397+
left in
398+
.Nm zpool Cm status Fl v
399+
for operator follow-up.
400+
Automatic free of an indirect would orphan its entire subtree, so it
401+
is not attempted.
402+
.El
403+
.Pp
404+
Several BP classes are skipped without attempting repair, with the
405+
reason logged via
406+
.Nm zpool Cm events :
407+
snapshots, MOS objects, special dnodes
408+
.Pq Sy DMU_OBJECT_IS_SPECIAL
409+
where
410+
.Sy dn_dbuf
411+
can be NULL,
412+
.Sy ZIL
413+
blocks,
414+
.Sy DMU_OT_OBJSET
415+
blocks
416+
.Pq separate authenticated-MAC API ,
417+
gang blocks, deduplicated BPs, and datasets whose key is not loaded.
418+
.Pp
419+
An alternative recovery path that does not require kernel changes is
420+
.Nm zfs Cm send Fl U
421+
plus
422+
.Nm zfs Cm receive
423+
onto a freshly created pool; the encryption pipeline runs again on
424+
ingest and produces correct BPs.
425+
This works without the
426+
.Sy crypt_repair
427+
feature but is heavier-weight than the in-kernel paths above.
428+
.
352429
.Ss Hot Spares
353430
ZFS allows devices to be associated with pools as
354431
.Qq hot spares .

man/man8/zpool-scrub.8

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
.Op Fl w
4343
.Op Fl S Ar date
4444
.Op Fl E Ar date
45+
.Op Fl -repair-crypt-mismatches
46+
.Op Fl -free-crypt-fallback
4547
.Fl a Ns | Ns Ar pool Ns
4648
.
4749
.Sh DESCRIPTION
@@ -166,7 +168,80 @@ Specifying dates prior to enabling this feature will result in scrubbing
166168
starting from the date the pool was created.
167169
If the time was moved backward manually the data range may become inaccurate.
168170
.El
169-
.Sh EXAMPLES
171+
.It Fl -repair-crypt-mismatches
172+
Attempt in-kernel repair of any block pointer found on an encrypted
173+
dataset that lacks the
174+
.Sy BP_USES_CRYPT
175+
flag.
176+
This corruption class has been reported intermittently on natively
177+
encrypted datasets across ZFS 2.0.x through 2.4.x; without this flag
178+
the read path returns
179+
.Sy EIO
180+
and the create path historically panicked in
181+
.Fn zfs_mknode .
182+
.Pp
183+
When set, the scrub examines each detected mismatch and dispatches one
184+
of two repair paths:
185+
.Bl -bullet -compact -offset indent
186+
.It
187+
.Em Smart flip
188+
.Pq Mode 1.5 .
189+
If decryption of the on-disk block succeeds and the MAC stored in
190+
.Sy blk_cksum
191+
verifies under the dataset key, the block is genuinely encrypted
192+
ciphertext that lost only its CRYPT flag in flight.
193+
The flag is restored atomically on the parent dnode or indirect block;
194+
no data is rewritten.
195+
This repair is lossless.
196+
.It
197+
.Em No repair .
198+
If MAC verification fails, the on-disk bytes are not legitimate
199+
ciphertext under the dataset key.
200+
The block is logged in
201+
.Nm zpool Cm status Fl v
202+
for the operator to handle; no further action is taken unless
203+
.Fl -free-crypt-fallback
204+
is also set
205+
.Pq see below .
206+
.El
207+
.Pp
208+
Several BP classes are intentionally skipped and recorded as such in
209+
.Nm zpool Cm events :
210+
snapshot datasets (the parent BP is immutable), MOS objects, special
211+
dnodes
212+
.Pq dn_dbuf can be NULL ,
213+
ZIL blocks, objset blocks
214+
.Pq use a different authenticated MAC API ,
215+
gang blocks, deduplicated BPs
216+
.Pq the DDT key includes the CRYPT bit ,
217+
and datasets whose encryption key is not loaded.
218+
.Pp
219+
The repair pipeline requires the
220+
.Sy feature@crypt_repair
221+
pool feature to be enabled.
222+
Indirect blocks are MAC-of-MAC verified the same way as leaves; only
223+
the destructive
224+
.Fl -free-crypt-fallback
225+
path is restricted to leaves.
226+
.It Fl -free-crypt-fallback
227+
When a leaf block fails Mode 1.5 MAC verification under
228+
.Fl -repair-crypt-mismatches ,
229+
free the leaf and replace the parent's reference with a hole.
230+
The affected file accumulates zeros at the offset of the freed block;
231+
the rest of the file remains accessible.
232+
.Pp
233+
This flag is destructive
234+
.Pq the original bytes are released ,
235+
opt-in only, and applies to leaf BPs only.
236+
Indirect blocks are never auto-freed because doing so would orphan their
237+
entire subtree; an unrepairable indirect is left in
238+
.Nm zpool Cm status Fl v
239+
for the operator to handle out of band.
240+
.Pp
241+
.Fl -free-crypt-fallback
242+
requires
243+
.Fl -repair-crypt-mismatches
244+
to also be set.
170245
.Ss Example 1
171246
Status of pool with ongoing scrub:
172247
.sp

0 commit comments

Comments
 (0)