Re: [PATCH] nvme: honor the volatile write cache enable state
From: Keith Busch
Date: Mon Nov 30 2026 - 14:34:42 EST
On Mon, Nov 30, 2026 at 06:10:14PM +0100, Erwan Velu wrote:
> [...]
> > There's just a gap with the multipath head: if you start up with WCE
> > cleared, then turn it on, the head isn't updated to indicate flush
> > limits. Let's get that fixed, then I'll queue this up.
> Hi Keith,
>
> Back to this, I'll work on a v2.
>
> Before I do, I want to be sure I fix the right gap. With a single
> controller, my understanding is that the head does pick up the change:
> the Set Features triggers a rescan that we wait for, nvme_update_ns_info()
> commits BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA on the path, then stacks it
> on the head with queue_limits_stack_bdev(), and blk_stack_limits()
> inherits both flags through BLK_FEAT_INHERIT_MASK.
>
> The gap I can see is with several controllers in the subsystem: the
> Set Features only refreshes the controller it was sent to. The other
> controllers keep WCE cleared, so their paths stay write-through. The head
> is write-back, but a flush or FUA write routed through one of those
> paths has REQ_PREFLUSH/REQ_FUA stripped by submit_bio_noacct(), so it
> never reaches the device.
>
> There is also the opposite direction: since stacking only ORs the
> inherited features, once the head is write-back it stays write-back
> after WCE is cleared. It is harmless for data integrity, but the head
> keeps reporting a write-back cache.
>
> Is the multi-controller case what you had in mind? If so, for v2 I plan
> to refresh the WCE state and rescan every controller of the subsystem
> after a successful Set Features, waiting for the rescans when the cache
> gets enabled. Should I also recompute the head write cache features from
> all the paths, so that clearing WCE is reflected on the head as well?
You're right about the single controller case for the off->on transtion,
I was mistaken there. The on->off transition will show the wrong thing
on the head, but I think that's mostly harmless.
Your multi-controller question turned up an existing problem when WCE is
turned on: the spec says a Flush only covers commands completed by the
controller it's sent to, but multipath sends it down only one path.
Writes completed through another controller path aren't necessarily made
durable.
So sorry again, I think I really do have something to fix up ahead of
your patch.