mirror of
https://github.com/freemkv/libfreemkv.git
synced 2026-10-07 18:13:10 +00:00
Patch was strictly serial (per-sector recovery: read → seek+write → mapfile.record → next). Lifting the write+record onto a consumer thread lets the drive issue the next per-sector retry while the previous block's recovered bytes are being committed — small but real win on damaged discs with many bad sectors, and uniform with sweep's threading model. - New PatchSink: Sink<PatchItem> impl in src/disc/patch.rs. Owns WritebackFile + Mapfile. apply() seeks+writes recovered bytes and records mapfile state per item; close() runs sync_all and mapfile.flush. - Channel depth: WRITE_THROUGH_DEPTH (1). Patch wants minimum buffering — back-pressure should kick in immediately so the drive's per-sector retry budget isn't ahead of the writer. - Disc::patch: keeps every existing recovery decision on the producer (reverse walk, damage-window skip, NOT_READY pauses, bridge-degradation handling, wedge exit, range watchdog). WritebackFile ownership moves to the sink. Behaviour-preserving: per-sector single-shot read budget unchanged (BU40N+Initio bridge wedge concern still respected); recovery algorithm bit-identical. See (internal)/memory/0_18_redesign.md. Single contributor: MattJackson.