* [PATCH] nvme: honor the volatile write cache enable state
@ 2026-10-16 14:12 Erwan Velu
2026-10-16 16:57 ` Keith Busch
0 siblings, 1 reply; 18+ messages in thread
From: Erwan Velu @ 2026-10-16 14:12 UTC (permalink / raw)
To: linux-nvme; +Cc: kbusch, axboe, hch, sagi, linux-kernel, Erwan Velu
A controller with a volatile write cache present (NVME_CTRL_VWC_PRESENT)
but disabled (Volatile Write Cache Enable cleared) is exposed in
write-back mode, as the driver never reads the Volatile Write Cache
feature. The block layer then issues flushes and FUA writes for
nothing, hurting performance.
On a Kioxia CD6-V (KCD6XVUL3T20, HPE firmware GPK8), compliant with
NVMe 1.4.0 and reporting VWC 0x5 with WCE cleared, 4k random writes with
an fsync after each write (fio, 30s) give, before (write back) and after
(write through) this patch:
job | cache | IOPS | fsync avg | flushes | gain
----------------------+---------+--------+-----------+---------+------
psync buffered, QD1 | back | 3885 | 247.6us | 116552 |
| through | 48325 | 15.7us | 0 | x12.4
----------------------+---------+--------+-----------+---------+------
io_uring direct, QD1 | back | 3886 | 238.2us | 116593 |
| through | 41924 | 5.7us | 0 | x10.8
----------------------+---------+--------+-----------+---------+------
io_uring direct, QD32 | back | 5088 | 6173.5us | 117793 |
| through | 140196 | 107.0us | 0 | x27.6
From NVMe 1.4c (sections 5.21.1.6 and 6.8) up to the NVMe Base
Specification 2.4 (sections 5.2.30.1.4 and 7.2), a Flush command has no
effect if the volatile write cache is not enabled. The NVMe Base
Specification 2.3 and 2.4 (sections 5.2.26.1.4 and 5.2.30.1.4) also
state that user data written to a namespace shall be persistent if the
volatile write cache is disabled.
Make the driver honor the Volatile Write Cache Enable bit:
- Read the feature in nvme_query_vwc_status() when the controller is
identified. The cache is assumed to be enabled unless the controller
explicitly reports it disabled, so a failure keeps the current
behavior.
- Add the nvme_ctrl_vwc_enabled() helper so that the volatile write
cache state is evaluated in a single place, combining both bits,
instead of testing NVME_CTRL_VWC_PRESENT on its own as is done today.
The chosen logic is the following:
NVME_CTRL_VWC_PRESENT | NVME_FEAT_VWC_ENABLE | Write cache
----------------------+----------------------+--------------
0 | absent/0/1 | write-through
1 | absent | write-back
1 | 0 | write-through
1 | 1 | write-back
This is safe by default: a present volatile write cache is considered
enabled, and the namespaces are exposed in write-back mode, until the
controller reports the WCE bit cleared.
- Refresh the state and rescan the namespaces in nvme_passthru_end()
after a successful Set Features for this feature, so that a change
made from userspace (e.g. "nvme set-feature -f 6 --value 1 /dev/nvme0")
is applied to the namespaces:
- if the volatile write cache is now enabled, wait for the rescan to
complete, so that the namespaces are back in write-back mode and
flushes and FUA writes are issued again before the command returns;
- if the volatile write cache is now disabled, do not wait, as
flushes sent in the meantime have no effect.
The performance issue is not specific to the drive tested here: any
controller that reports a volatile write cache with WCE cleared is
affected, whatever its vendor or product.
Assisted-by: Claude Opus 5.5
Signed-off-by: Erwan Velu <e.velu@criteo.com>
---
drivers/nvme/host/core.c | 41 +++++++++++++++++++++++++++++++++++++++-
drivers/nvme/host/nvme.h | 10 ++++++++++
include/linux/nvme.h | 1 +
3 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 531f9bb14bab..5b03bf06b57c 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1278,6 +1278,30 @@ u32 nvme_passthru_start(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u8 opcode)
}
EXPORT_SYMBOL_NS_GPL(nvme_passthru_start, "NVME_TARGET_PASSTHRU");
+static void nvme_query_vwc_status(struct nvme_ctrl *ctrl)
+{
+ u32 result;
+ int ret;
+
+ /* Assume the volatile write cache is enabled until proven otherwise */
+ ctrl->vwc_status |= NVME_FEAT_VWC_ENABLE;
+
+ if (!(ctrl->vwc & NVME_CTRL_VWC_PRESENT))
+ return;
+
+ ret = nvme_get_features(ctrl, NVME_FEAT_VOLATILE_WC, 0, NULL, 0,
+ &result);
+ if (ret) {
+ dev_warn(ctrl->device,
+ "failed to get volatile write cache status (%d)\n",
+ ret);
+ return;
+ }
+
+ if (!(result & NVME_FEAT_VWC_ENABLE))
+ ctrl->vwc_status &= ~NVME_FEAT_VWC_ENABLE;
+}
+
u32 nvme_passthru_end(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u32 effects,
struct nvme_command *cmd, int status)
{
@@ -1313,6 +1337,20 @@ u32 nvme_passthru_end(struct nvme_ctrl *ctrl, struct nvme_ns *ns, u32 effects,
if (!status)
nvme_update_keep_alive(ctrl, cmd);
break;
+ case NVME_FEAT_VOLATILE_WC:
+ /*
+ * Refresh the volatile write cache state and revalidate
+ * the namespaces so that flushes and FUA writes are
+ * issued if the cache was enabled. In that case, wait
+ * for the revalidation to complete before returning.
+ */
+ if (!status) {
+ nvme_query_vwc_status(ctrl);
+ nvme_queue_scan(ctrl);
+ if (nvme_ctrl_vwc_enabled(ctrl))
+ flush_work(&ctrl->scan_work);
+ }
+ break;
default:
break;
}
@@ -2478,7 +2516,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
"not enabling zoned mode");
}
- if ((ns->ctrl->vwc & NVME_CTRL_VWC_PRESENT) && !info->no_vwc)
+ if (nvme_ctrl_vwc_enabled(ns->ctrl) && !info->no_vwc)
lim.features |= BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA;
else
lim.features &= ~(BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA);
@@ -3679,6 +3717,7 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
atomic_set(&ctrl->abort_limit, id->acl + 1);
ctrl->vwc = id->vwc;
+ nvme_query_vwc_status(ctrl);
if (id->mdts)
max_hw_sectors = nvme_mps_to_sectors(ctrl, id->mdts);
else
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index a8ef62b8e34b..b993ebd457c5 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -399,6 +399,7 @@ struct nvme_ctrl {
u32 max_namespaces;
atomic_t abort_limit;
u8 vwc;
+ u32 vwc_status;
u32 vs;
u32 sgls;
u16 kas;
@@ -1274,6 +1275,15 @@ static inline void nvme_start_request(struct request *rq)
blk_mq_start_request(rq);
}
+/*
+ * The volatile write cache status depends on both its presence and its state.
+ */
+static inline bool nvme_ctrl_vwc_enabled(struct nvme_ctrl *ctrl)
+{
+ return (ctrl->vwc & NVME_CTRL_VWC_PRESENT) &&
+ (ctrl->vwc_status & NVME_FEAT_VWC_ENABLE);
+}
+
static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl)
{
return ctrl->sgls & (NVME_CTRL_SGLS_BYTE_ALIGNED |
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 91ce434a7e8d..c7a1fd29bda7 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -1402,6 +1402,7 @@ enum {
NVME_FEAT_WRITE_PROTECT = 0x84,
NVME_FEAT_VENDOR_START = 0xC0,
NVME_FEAT_VENDOR_END = 0xFF,
+ NVME_FEAT_VWC_ENABLE = 1 << 0,
NVME_LOG_SUPPORTED = 0x00,
NVME_LOG_ERROR = 0x01,
NVME_LOG_SMART = 0x02,
base-commit: 2e8e30b3cf9f165e1a1d079331543cb7f2ad0e0c
--
2.53.0
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-16 14:12 [PATCH] nvme: honor the volatile write cache enable state Erwan Velu
@ 2026-10-16 16:57 ` Keith Busch
2026-10-16 17:15 ` Erwan Velu
0 siblings, 1 reply; 18+ messages in thread
From: Keith Busch @ 2026-10-16 16:57 UTC (permalink / raw)
To: Erwan Velu; +Cc: linux-nvme, axboe, hch, sagi, linux-kernel, Erwan Velu
On Fri, Oct 16, 2026 at 04:12:08PM +0200, Erwan Velu wrote:
> job | cache | IOPS | fsync avg | flushes | gain
> ----------------------+---------+--------+-----------+---------+------
> psync buffered, QD1 | back | 3885 | 247.6us | 116552 |
> | through | 48325 | 15.7us | 0 | x12.4
> ----------------------+---------+--------+-----------+---------+------
> io_uring direct, QD1 | back | 3886 | 238.2us | 116593 |
> | through | 41924 | 5.7us | 0 | x10.8
> ----------------------+---------+--------+-----------+---------+------
> io_uring direct, QD32 | back | 5088 | 6173.5us | 117793 |
> | through | 140196 | 107.0us | 0 | x27.6
>
> From NVMe 1.4c (sections 5.21.1.6 and 6.8) up to the NVMe Base
> Specification 2.4 (sections 5.2.30.1.4 and 7.2), a Flush command has no
> effect if the volatile write cache is not enabled.
Yeah, the NVMe Flush operation should be a no-op in the device, so the
dramatic performance difference is a bit alarming. Surely the block
stack's flush machinery is not the reason for the difference, right?
If the device's flush handling is this bad when VWC is disabled, what
happens when you have it enabled? Can you re-run the same test with that
setting?
I'm not necessarily against what you're proposing here, but your numbers
are unexpected.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-16 16:57 ` Keith Busch
@ 2026-10-16 17:15 ` Erwan Velu
2026-10-16 17:27 ` Keith Busch
0 siblings, 1 reply; 18+ messages in thread
From: Erwan Velu @ 2026-10-16 17:15 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-nvme, axboe, hch, sagi, linux-kernel, Erwan Velu
Le ven. 16 oct. 2026 à 18:57, Keith Busch <kbusch@kernel.org> a écrit :
>
> On Fri, Oct 16, 2026 at 04:12:08PM +0200, Erwan Velu wrote:
> > job | cache | IOPS | fsync avg | flushes | gain
> > ----------------------+---------+--------+-----------+---------+------
> > psync buffered, QD1 | back | 3885 | 247.6us | 116552 |
> > | through | 48325 | 15.7us | 0 | x12.4
> > ----------------------+---------+--------+-----------+---------+------
> > io_uring direct, QD1 | back | 3886 | 238.2us | 116593 |
> > | through | 41924 | 5.7us | 0 | x10.8
> > ----------------------+---------+--------+-----------+---------+------
> > io_uring direct, QD32 | back | 5088 | 6173.5us | 117793 |
> > | through | 140196 | 107.0us | 0 | x27.6
> >
> > From NVMe 1.4c (sections 5.21.1.6 and 6.8) up to the NVMe Base
> > Specification 2.4 (sections 5.2.30.1.4 and 7.2), a Flush command has no
> > effect if the volatile write cache is not enabled.
>
> Yeah, the NVMe Flush operation should be a no-op in the device, so the
> dramatic performance difference is a bit alarming. Surely the block
> stack's flush machinery is not the reason for the difference, right?
>
> If the device's flush handling is this bad when VWC is disabled, what
> happens when you have it enabled? Can you re-run the same test with that
> setting?
>
> I'm not necessarily against what you're proposing here, but your numbers
> are unexpected.
Maybe my table here isn't probably clear enough.
The numbers shown in the "write back" mode were done with VWC enabled.
The numbers shown in the "write through" mode were done with VWC disabled.
As I'm doing lots of fsync (on purpose in this test by having
--fsync=1 in my fio cmdline), you can see the "flushes" counter is
very high when VWC is enabled.
The impressive numbers (more than 10x) come from this workload : lots
of fsync for little data.
Please note this patch is following an investigation after a report
from one of my users complaining of poor latency on this NVMe drive
series in particular.
So this isn't an unrealistic use case; the impact we see in production
is of the same order of magnitude as what this patch reports.
Erwan,
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-16 17:15 ` Erwan Velu
@ 2026-10-16 17:27 ` Keith Busch
2026-10-16 17:43 ` Erwan Velu
0 siblings, 1 reply; 18+ messages in thread
From: Keith Busch @ 2026-10-16 17:27 UTC (permalink / raw)
To: Erwan Velu; +Cc: linux-nvme, axboe, hch, sagi, linux-kernel, Erwan Velu
On Fri, Oct 16, 2026 at 07:15:20PM +0200, Erwan Velu wrote:
> Le ven. 16 oct. 2026 à 18:57, Keith Busch <kbusch@kernel.org> a écrit :
> >
> > On Fri, Oct 16, 2026 at 04:12:08PM +0200, Erwan Velu wrote:
> > > job | cache | IOPS | fsync avg | flushes | gain
> > > ----------------------+---------+--------+-----------+---------+------
> > > psync buffered, QD1 | back | 3885 | 247.6us | 116552 |
> > > | through | 48325 | 15.7us | 0 | x12.4
> > > ----------------------+---------+--------+-----------+---------+------
> > > io_uring direct, QD1 | back | 3886 | 238.2us | 116593 |
> > > | through | 41924 | 5.7us | 0 | x10.8
> > > ----------------------+---------+--------+-----------+---------+------
> > > io_uring direct, QD32 | back | 5088 | 6173.5us | 117793 |
> > > | through | 140196 | 107.0us | 0 | x27.6
> > >
> > > From NVMe 1.4c (sections 5.21.1.6 and 6.8) up to the NVMe Base
> > > Specification 2.4 (sections 5.2.30.1.4 and 7.2), a Flush command has no
> > > effect if the volatile write cache is not enabled.
> >
> > Yeah, the NVMe Flush operation should be a no-op in the device, so the
> > dramatic performance difference is a bit alarming. Surely the block
> > stack's flush machinery is not the reason for the difference, right?
> >
> > If the device's flush handling is this bad when VWC is disabled, what
> > happens when you have it enabled? Can you re-run the same test with that
> > setting?
> >
> > I'm not necessarily against what you're proposing here, but your numbers
> > are unexpected.
>
> Maybe my table here isn't probably clear enough.
> The numbers shown in the "write back" mode were done with VWC enabled.
But you said the table came from tests "with WCE cleared" in the VWC
feature. ?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-16 17:27 ` Keith Busch
@ 2026-10-16 17:43 ` Erwan Velu
2026-10-16 17:55 ` Keith Busch
0 siblings, 1 reply; 18+ messages in thread
From: Erwan Velu @ 2026-10-16 17:43 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-nvme, axboe, hch, sagi, linux-kernel, Erwan Velu
Ok let me clarify this.
This disk is configured by default with VWC_PRESENT enabled, but the
Volatile Write Cache is disabled (NVME_FEAT_VWC_ENABLE=0), so the
device has a Volatile Write Cache, but it's disabled.
In that configuration, even though VWC_PRESENT is set to 1 and the
volatile cache is disabled, the kernel treats it as enabled and
switches to "write back" mode, causing tons of sync and bad
performance.
In this table, with my patch, I've enabled and disabled the volatile
write cache using nvme set-feature -f 6; this only affects
NVME_FEAT_VWC_ENABLE, and VWC_PRESENT is still reported as present.
If the volatile cache is enabled, write-back mode engages, resulting
in poor performance.
If the volatile cache is disabled, write-through mode engages with the
expected performance.
Note that in the current mainline state, my drive is _always_ in
write-back mode because NVME_FEAT_VWC_ENABLE isn't being considered,
resulting in horrible performance.
That's why this patch ensures the volatile write cache status (which
the kernel uses to decide which caching mode to engage) depends on
both VWC_PRESENT __and__ NVME_FEAT_VWC_ENABLE.
Hope that's make it more clear,
Erwan,
Le ven. 16 oct. 2026 à 19:27, Keith Busch <kbusch@kernel.org> a écrit :
>
> On Fri, Oct 16, 2026 at 07:15:20PM +0200, Erwan Velu wrote:
> > Le ven. 16 oct. 2026 à 18:57, Keith Busch <kbusch@kernel.org> a écrit :
> > >
> > > On Fri, Oct 16, 2026 at 04:12:08PM +0200, Erwan Velu wrote:
> > > > job | cache | IOPS | fsync avg | flushes | gain
> > > > ----------------------+---------+--------+-----------+---------+------
> > > > psync buffered, QD1 | back | 3885 | 247.6us | 116552 |
> > > > | through | 48325 | 15.7us | 0 | x12.4
> > > > ----------------------+---------+--------+-----------+---------+------
> > > > io_uring direct, QD1 | back | 3886 | 238.2us | 116593 |
> > > > | through | 41924 | 5.7us | 0 | x10.8
> > > > ----------------------+---------+--------+-----------+---------+------
> > > > io_uring direct, QD32 | back | 5088 | 6173.5us | 117793 |
> > > > | through | 140196 | 107.0us | 0 | x27.6
> > > >
> > > > From NVMe 1.4c (sections 5.21.1.6 and 6.8) up to the NVMe Base
> > > > Specification 2.4 (sections 5.2.30.1.4 and 7.2), a Flush command has no
> > > > effect if the volatile write cache is not enabled.
> > >
> > > Yeah, the NVMe Flush operation should be a no-op in the device, so the
> > > dramatic performance difference is a bit alarming. Surely the block
> > > stack's flush machinery is not the reason for the difference, right?
> > >
> > > If the device's flush handling is this bad when VWC is disabled, what
> > > happens when you have it enabled? Can you re-run the same test with that
> > > setting?
> > >
> > > I'm not necessarily against what you're proposing here, but your numbers
> > > are unexpected.
> >
> > Maybe my table here isn't probably clear enough.
> > The numbers shown in the "write back" mode were done with VWC enabled.
>
> But you said the table came from tests "with WCE cleared" in the VWC
> feature. ?
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-16 17:43 ` Erwan Velu
@ 2026-10-16 17:55 ` Keith Busch
2026-10-17 4:25 ` Erwan Velu
0 siblings, 1 reply; 18+ messages in thread
From: Keith Busch @ 2026-10-16 17:55 UTC (permalink / raw)
To: Erwan Velu; +Cc: linux-nvme, axboe, hch, sagi, linux-kernel, Erwan Velu
On Fri, Oct 16, 2026 at 07:43:24PM +0200, Erwan Velu wrote:
> This disk is configured by default with VWC_PRESENT enabled, but the
> Volatile Write Cache is disabled (NVME_FEAT_VWC_ENABLE=0), so the
> device has a Volatile Write Cache, but it's disabled.
...
> In this table, with my patch, I've enabled and disabled the volatile
> write cache using nvme set-feature -f 6; this only affects
> NVME_FEAT_VWC_ENABLE, and VWC_PRESENT is still reported as present.
...
> Hope that's make it more clear,
Unfortunately, no: there are contradicting statements here.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-16 17:55 ` Keith Busch
@ 2026-10-17 4:25 ` Erwan Velu
2026-10-22 13:27 ` Erwan Velu
0 siblings, 1 reply; 18+ messages in thread
From: Erwan Velu @ 2026-10-17 4:25 UTC (permalink / raw)
To: Keith Busch, Erwan Velu; +Cc: linux-nvme, axboe, hch, sagi, linux-kernel
[...]
> Unfortunately, no: there are contradicting statements here.
Hi Keith,
Sorry for the confusion, my previous replies were wrong and contradicted
the commit message. Let me restate it with new measurements.
To make sure the numbers are relevant, I switched to the latest nvme
branch, nvme-7.4 (2e8e30b3cf9f), and re-ran all the tests from scratch,
with and without the patch on top of it, on the same drive (Kioxia
CD6-V, NVMe 1.4, VWC 0x5, WCE cleared by default).
Both rows of each job in the commit message table were measured with
WCE cleared; only the kernel differs. Without the patch, WCE is ignored
and the namespace is exposed in write-back mode, so one Flush is sent
per fsync. With the patch, the namespace is in write-through mode and no
Flush is sent.
To answer your question, I measured the Flush latency at the driver
level, between the nvme_setup_cmd and nvme_complete_rq tracepoints:
- passthrough: 2000 "nvme flush" sent directly to the device
- fio: 4k randwrite, io_uring, direct, QD1, fsync=1, 10s
kernel | WCE | mode | passthrough | fio: Flush | fio: fsync | IOPS
| | | Flush avg | avg (drv) | avg (fio) |
--------+-----+---------+-------------+------------+------------+------
nvme-7.4| 0 | back | 194.8us | 214.6us | 236.1us | 3917
patched | 0 | through | 194.2us | (none) | 5.7us | 44433
patched | 1 | back | 194.2us | 219.7us | 237.1us | 3916
So:
- The block layer flush handling is not the reason: without the patch,
the device accounts for ~215us of the ~236us fsync, the rest of the
stack for ~21us.
- The drive spends ~194us on a Flush whether the volatile write cache
is enabled or not. It does not short-circuit the Flush when WCE is
cleared, although the spec says it has no effect in that case.
- Without the patch, WCE cleared therefore performs exactly like the
volatile write cache enabled (3917 vs 3916 IOPS), while the patched
kernel skips the Flush entirely (44433 IOPS).
The slow no-op Flush is a firmware behavior, but the kernel should not
send it in the first place when WCE is cleared, which is what the patch
does.
I also re-ran the commit message benchmark on nvme-7.4, WCE cleared in
both cases (fio 4k randwrite, fsync=1, 30s):
job | kernel | IOPS | fsync avg | flushes | gain
----------------------+----------+--------+-----------+---------+------
psync buffered, QD1 | nvme-7.4 | 3917 | 249.2us | 117506 |
| patched | 48227 | 15.7us | 0 | x12.3
----------------------+----------+--------+-----------+---------+------
io_uring direct, QD1 | nvme-7.4 | 3888 | 238.2us | 116636 |
| patched | 42580 | 5.5us | 0 | x11.0
----------------------+----------+--------+-----------+---------+------
io_uring direct, QD32 | nvme-7.4 | 5674 | 5514.1us | 117774 |
| patched | 140090 | 107.1us | 0 | x24.7
If you think it makes the commit message clearer, I can send a v2 with
these numbers, the kernel anitly, and the driver level Flush latency above.
Thanks,
Erwan
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-17 4:25 ` Erwan Velu
@ 2026-10-22 13:27 ` Erwan Velu
2026-10-22 23:17 ` Keith Busch
0 siblings, 1 reply; 18+ messages in thread
From: Erwan Velu @ 2026-10-22 13:27 UTC (permalink / raw)
To: Erwan Velu; +Cc: Keith Busch, linux-nvme, axboe, hch, sagi, linux-kernel
Le sam. 17 oct. 2026 à 06:25, Erwan Velu <e.velu@criteo.com> a écrit :
>
> [...]
> > Unfortunately, no: there are contradicting statements here.
[...]
> If you think it makes the commit message clearer, I can send a v2 with
> these numbers, the kernel anitly, and the driver level Flush latency above.
Hey Keith,
WDYT of these explanations and additional details?
Hope that's better and could be considered for inclusion in the next
releases, maybe as a backport to the stable ones as incorrect
detection of the volatile's cache status can lead to severe
performance impact on this type of drive.
Erwan,
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-22 13:27 ` Erwan Velu
@ 2026-10-22 23:17 ` Keith Busch
2026-10-23 14:53 ` Erwan Velu
0 siblings, 1 reply; 18+ messages in thread
From: Keith Busch @ 2026-10-22 23:17 UTC (permalink / raw)
To: Erwan Velu; +Cc: Erwan Velu, linux-nvme, axboe, hch, sagi, linux-kernel
On Thu, Oct 22, 2026 at 03:27:50PM +0200, Erwan Velu wrote:
> Le sam. 17 oct. 2026 à 06:25, Erwan Velu <e.velu@criteo.com> a écrit :
> >
> > [...]
> > > Unfortunately, no: there are contradicting statements here.
> [...]
> > If you think it makes the commit message clearer, I can send a v2 with
> > these numbers, the kernel anitly, and the driver level Flush latency above.
>
> Hey Keith,
> WDYT of these explanations and additional details?
> Hope that's better and could be considered for inclusion in the next
> releases, maybe as a backport to the stable ones as incorrect
> detection of the volatile's cache status can lead to severe
> performance impact on this type of drive.
I just wanted to see if there was any difference in the controller's
Flush behavior when the volatile cache was enabled vs disabled, and this
looks like it's the same either way. The Flush should have been a no-op
to the device with WCE cleared, so something seems off here.
I'm wondering if the device is actually really respecting WCE set to 0
now. That might be tricky to prove, but it wouldn't be the first time a
device lied about durability. Not saying that's happening here, but the
behavior you're reporting is suspicious: 15usec writes are not
physically possible with TLC NAND (your model says BiCS TLC) without a
cache, and your controller says your cache is volatile.
Anyway, the principle of what you're proposing looks fine to me from a
spec standpoint. I'll get this queued up if I don't see any other review
feedback or concerns that it's going to corrupt something...
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-22 23:17 ` Keith Busch
@ 2026-10-23 14:53 ` Erwan Velu
2026-10-28 16:08 ` Keith Busch
0 siblings, 1 reply; 18+ messages in thread
From: Erwan Velu @ 2026-10-23 14:53 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-nvme, axboe, hch, sagi, linux-kernel, Erwan Velu
On 10/23/26 01:17, Keith Busch wrote:
[...]
> I just wanted to see if there was any difference in the controller's
> Flush behavior when the volatile cache was enabled vs disabled, and this
> looks like it's the same either way. The Flush should have been a no-op
> to the device with WCE cleared, so something seems off here.
>
> I'm wondering if the device is actually really respecting WCE set to 0
> now. That might be tricky to prove, but it wouldn't be the first time a
> device lied about durability. Not saying that's happening here, but the
> behavior you're reporting is suspicious: 15usec writes are not
> physically possible with TLC NAND (your model says BiCS TLC) without a
> cache, and your controller says your cache is volatile.
>
> Anyway, the principle of what you're proposing looks fine to me from a
> spec standpoint. I'll get this queued up if I don't see any other review
> feedback or concerns that it's going to corrupt something...
Thanks for your feedback.
I'll discuss this firmware question with the vendor in private and will
keep you aware.
Considering the performance impact for these type of device,s would you
be open to a backport to stable once merged ?
This patch is really about matching the spec and it would be probably a
great positive impact for many stable users to benefit from this patch.
WDYT ?
Erwan,
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-23 14:53 ` Erwan Velu
@ 2026-10-28 16:08 ` Keith Busch
2026-10-28 16:16 ` Christoph Hellwig
` (3 more replies)
0 siblings, 4 replies; 18+ messages in thread
From: Keith Busch @ 2026-10-28 16:08 UTC (permalink / raw)
To: Erwan Velu; +Cc: linux-nvme, axboe, hch, sagi, linux-kernel, Erwan Velu
On Fri, Oct 23, 2026 at 04:53:54PM +0200, Erwan Velu wrote:
> > I just wanted to see if there was any difference in the controller's
> > Flush behavior when the volatile cache was enabled vs disabled, and this
> > looks like it's the same either way. The Flush should have been a no-op
> > to the device with WCE cleared, so something seems off here.
> >
> > I'm wondering if the device is actually really respecting WCE set to 0
> > now. That might be tricky to prove, but it wouldn't be the first time a
> > device lied about durability. Not saying that's happening here, but the
> > behavior you're reporting is suspicious: 15usec writes are not
> > physically possible with TLC NAND (your model says BiCS TLC) without a
> > cache, and your controller says your cache is volatile.
> >
> > Anyway, the principle of what you're proposing looks fine to me from a
> > spec standpoint. I'll get this queued up if I don't see any other review
> > feedback or concerns that it's going to corrupt something...
>
> Thanks for your feedback.
>
> I'll discuss this firmware question with the vendor in private and will keep
> you aware.
>
> Considering the performance impact for these type of device,s would you be
> open to a backport to stable once merged ?
Not sure when a performance improvement is stable worthy. I'm more
concerned that doing this is going to expose corruption, but it's what
the device is asking for, so fine to introduce it, but stable is
questionable.
> This patch is really about matching the spec and it would be probably a
> great positive impact for many stable users to benefit from this patch.
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.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-28 16:08 ` Keith Busch
@ 2026-10-28 16:16 ` Christoph Hellwig
2026-10-28 17:08 ` Erwan Velu
` (2 subsequent siblings)
3 siblings, 0 replies; 18+ messages in thread
From: Christoph Hellwig @ 2026-10-28 16:16 UTC (permalink / raw)
To: Keith Busch
Cc: Erwan Velu, linux-nvme, axboe, hch, sagi, linux-kernel, Erwan Velu
On Wed, Oct 28, 2026 at 10:08:05AM -0600, Keith Busch wrote:
> > Considering the performance impact for these type of device,s would you be
> > open to a backport to stable once merged ?
>
> Not sure when a performance improvement is stable worthy. I'm more
> concerned that doing this is going to expose corruption, but it's what
> the device is asking for, so fine to introduce it, but stable is
> questionable.
Same here. We should not send these improvements to stable, but let
them soak in linux-next and mainline.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-28 16:08 ` Keith Busch
2026-10-28 16:16 ` Christoph Hellwig
@ 2026-10-28 17:08 ` Erwan Velu
2026-10-28 17:47 ` Keith Busch
2026-11-26 10:07 ` Erwan Velu
2026-11-30 17:10 ` Erwan Velu
3 siblings, 1 reply; 18+ messages in thread
From: Erwan Velu @ 2026-10-28 17:08 UTC (permalink / raw)
To: Keith Busch; +Cc: Erwan Velu, linux-nvme, axboe, hch, sagi, linux-kernel
Le mer. 28 oct. 2026 à 17:08, Keith Busch <kbusch@kernel.org> a écrit :
[...]
> > Considering the performance impact for these type of device,s would you be
> > open to a backport to stable once merged ?
>
> Not sure when a performance improvement is stable worthy. I'm more
> concerned that doing this is going to expose corruption, but it's what
> the device is asking for, so fine to introduce it, but stable is
> questionable.
If we consider this dangerous for this device, should we add a quirk
for some devices that could be seen as lying?
PS: I'm still waiting vendor's feedback on this question.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-28 17:08 ` Erwan Velu
@ 2026-10-28 17:47 ` Keith Busch
0 siblings, 0 replies; 18+ messages in thread
From: Keith Busch @ 2026-10-28 17:47 UTC (permalink / raw)
To: Erwan Velu; +Cc: Erwan Velu, linux-nvme, axboe, hch, sagi, linux-kernel
On Wed, Oct 28, 2026 at 06:08:17PM +0100, Erwan Velu wrote:
> Le mer. 28 oct. 2026 à 17:08, Keith Busch <kbusch@kernel.org> a écrit :
> [...]
> > > Considering the performance impact for these type of device,s would you be
> > > open to a backport to stable once merged ?
> >
> > Not sure when a performance improvement is stable worthy. I'm more
> > concerned that doing this is going to expose corruption, but it's what
> > the device is asking for, so fine to introduce it, but stable is
> > questionable.
> If we consider this dangerous for this device, should we add a quirk
> for some devices that could be seen as lying?
Let's just assume spec complaince for now until proven otherwise.
When/if a device is discovered to be quirky on this feature, we can
introduce handling to ignore WCE.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-28 16:08 ` Keith Busch
2026-10-28 16:16 ` Christoph Hellwig
2026-10-28 17:08 ` Erwan Velu
@ 2026-11-26 10:07 ` Erwan Velu
2026-11-30 16:01 ` Keith Busch
2026-11-30 17:10 ` Erwan Velu
3 siblings, 1 reply; 18+ messages in thread
From: Erwan Velu @ 2026-11-26 10:07 UTC (permalink / raw)
To: Keith Busch; +Cc: Erwan Velu, linux-nvme, axboe, hch, sagi, linux-kernel
Le mer. 28 oct. 2026 à 17:08, Keith Busch <kbusch@kernel.org> a écrit :
[...]
> > This patch is really about matching the spec and it would be probably a
> > great positive impact for many stable users to benefit from this patch.
>
> 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.
Hey Keith,
Any update on this additional patch you mentioned and status on mine ?
Erwan,
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-11-26 10:07 ` Erwan Velu
@ 2026-11-30 16:01 ` Keith Busch
0 siblings, 0 replies; 18+ messages in thread
From: Keith Busch @ 2026-11-30 16:01 UTC (permalink / raw)
To: Erwan Velu; +Cc: Erwan Velu, linux-nvme, axboe, hch, sagi, linux-kernel
On Thu, Nov 26, 2026 at 11:07:41AM +0100, Erwan Velu wrote:
> Le mer. 28 oct. 2026 à 17:08, Keith Busch <kbusch@kernel.org> a écrit :
> [...]
> > > This patch is really about matching the spec and it would be probably a
> > > great positive impact for many stable users to benefit from this patch.
> >
> > 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.
>
> Hey Keith,
> Any update on this additional patch you mentioned and status on mine ?
> Erwan,
Sorry for the confusion here. I was suggesting you spin up a new version
that doesn't have that gap rather than volunteer to write a separate
patch on top of it.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-10-28 16:08 ` Keith Busch
` (2 preceding siblings ...)
2026-11-26 10:07 ` Erwan Velu
@ 2026-11-30 17:10 ` Erwan Velu
2026-11-30 19:34 ` Keith Busch
3 siblings, 1 reply; 18+ messages in thread
From: Erwan Velu @ 2026-11-30 17:10 UTC (permalink / raw)
To: Keith Busch; +Cc: Erwan Velu, linux-nvme, axboe, hch, sagi, linux-kernel
[...]
> 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?
I'd like to be sure I understand your point before going further.
Erwan,
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] nvme: honor the volatile write cache enable state
2026-11-30 17:10 ` Erwan Velu
@ 2026-11-30 19:34 ` Keith Busch
0 siblings, 0 replies; 18+ messages in thread
From: Keith Busch @ 2026-11-30 19:34 UTC (permalink / raw)
To: Erwan Velu; +Cc: Erwan Velu, linux-nvme, axboe, hch, sagi, linux-kernel
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.
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2026-11-30 19:34 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-16 14:12 [PATCH] nvme: honor the volatile write cache enable state Erwan Velu
2026-10-16 16:57 ` Keith Busch
2026-10-16 17:15 ` Erwan Velu
2026-10-16 17:27 ` Keith Busch
2026-10-16 17:43 ` Erwan Velu
2026-10-16 17:55 ` Keith Busch
2026-10-17 4:25 ` Erwan Velu
2026-10-22 13:27 ` Erwan Velu
2026-10-22 23:17 ` Keith Busch
2026-10-23 14:53 ` Erwan Velu
2026-10-28 16:08 ` Keith Busch
2026-10-28 16:16 ` Christoph Hellwig
2026-10-28 17:08 ` Erwan Velu
2026-10-28 17:47 ` Keith Busch
2026-11-26 10:07 ` Erwan Velu
2026-11-30 16:01 ` Keith Busch
2026-11-30 17:10 ` Erwan Velu
2026-11-30 19:34 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®