Repository navigation
Conversation
flush_interval defaulted to 1000 ms. Within that window apple_nvme_queue_rq() completed a REQ_OP_FLUSH at once and sent one flush to the drive when the window ended. The filesystem was told the data was durable while it was still in the drive's cache, so a power loss or a crash in that window lost data that fsync() had reported as safe. Post-M4 controllers were already exempt; every earlier ANS (the t8015 and t8103 profiles, which the generic apple,nvme-ans2 compatible also selects for T600x and T8112) ran with the deferral on. Make 0 the default, so every flush reaches the drive before it completes. Keep the parameter for people who accept the risk, and say in its description that a non-zero value acknowledges flushes before they reach the drive. Make the variable static: it was a global symbol named flush_interval. This trades flush latency for durability on M1, M2 and M3 machines. The cost has not been measured: fio numbers on M1, M2 and M3 are needed before this is merged. Checked with a host harness built from the real apple_nvme_delayed_flush() text under ASan and UBSan: with the old default, 99 of 100 flushes sent 10 jiffies apart were completed early; with the new default none are, and an opt-in interval behaves as before. Not built as a kernel module here, and not run on hardware. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com>
T6040 (M4 Pro) is the T8132 controller with a different register layout, as the comment above its profile says. T8132 sets NVME_QUIRK_BROKEN_FUA because writes were lost across a reset on J713 unless they were flushed. T6040 did not set it, so it trusted FUA on the same controller. Name the T8132 quirk set once and use it in both profiles, so T6040 follows the J713 result instead of a copied list that can drift. The block layer then follows each FUA write with a flush on T6040. At worst this costs one extra flush per FUA write; it cannot lose data that FUA alone would have kept. The evidence is the J713 (T8132) result. It has not been repeated on T6040: an M4 Pro run (an fsynced FUA write across an abrupt reset, and fio before and after) is needed before this is merged. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the #2755 split. Draft: it needs numbers I cannot measure (no Mac here).
Summary
Evidence
acked before reaching the drive, and with the new default none are.
and one M3 machine, and an M4 Pro row (an fsynced FUA write across an abrupt reset, and FUA
write throughput).
Merge Danger
Door: two-way
Blast Radius: storage performance
Slower flushes on M1/M2/M3 and slower FUA writes on M4 Pro, in exchange for fsync() meaning what it
says.
flush_interval=1000restores the old behaviour.Assisted-by: LLM (Claude:Opus 5.5)