Skip to content

nvme: apple: send every flush to the drive by default; T6040 shares the T8132 quirks - #2989

Draft
Alyx-ML wants to merge 2 commits into
aurora-silicon:mainfrom
Alyx-ML:aurora/nvme-flush-durability
Draft

Alyx-ML wants to merge 2 commits into
aurora-silicon:mainfrom
Alyx-ML:aurora/nvme-flush-durability

Conversation

@Alyx-ML

@Alyx-ML Alyx-ML commented Nov 23, 2026

Copy link
Copy Markdown

Part of the #2755 split. Draft: it needs numbers I cannot measure (no Mac here).

Summary

-unsigned int flush_interval = 1000;    # flushes inside 1 s are acked before the drive flushes
+static unsigned int flush_interval;    # 0: every flush reaches the drive; still a module parameter
+#define APPLE_NVME_T8132_QUIRKS NVME_QUIRK_BROKEN_FUA   # the J713 result
 t8132: .quirks = APPLE_NVME_T8132_QUIRKS
-t6040: .quirks = NVME_QUIRK_NO_APST
+t6040: .quirks = APPLE_NVME_T8132_QUIRKS | NVME_QUIRK_NO_APST   # the same controller

Evidence

  • A host harness shows that with the old default, 99 of 100 flushes sent 10 jiffies apart were
    acked before reaching the drive, and with the new default none are.
  • Build: passed, Apple build and KUnit.
  • Needed before merging: fio fsync and sync-write numbers, before and after, on one M1, one M2
    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=1000 restores the old behaviour.

Assisted-by: LLM (Claude:Opus 5.5)

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant