[PATCH 0/2] NVMe Atomic Write fixes
Alan Adamson
alan.adamson at oracle.com
Wed Apr 30 10:18:28 PDT 2025
This patch set includes 2 fixes for NVMe Atomic Writes that are reproducable
when CMIC.MCTRS (multi-controller support) is set:
nvme: multipath: atomic queue limits need to be inherited for multipathing
nvme: all namespaces in a subsystem must adhere to a common atomic write size
QEMU v10.0 can be used to reproduce and validate the fixes.
nvme: multipath: atomic queue limits need to be inherited for multipathing
--------------------------------------------------------------------------
- Include BLK_FEAT_ATOMIC_WRITES feature when allocating multipath disk (nvme_mpath_alloc_disk).
QEMU Config
===========
-device nvme,id=nvme-ctrl-0,serial=nvme-1,atomic.dn=off,atomic.awun=31,atomic.awupf=15 \
-drive file=/dev/nullb2,if=none,id=nvm-1 \
-device nvme-ns,drive=nvm-1,bus=nvme-ctrl-0,nsid=1 \
-device nvme,id=nvme-ctrl-1,serial=nvme-2,atomic.dn=off,atomic.awun=31,atomic.awupf=7 \
-drive file=/dev/nullb3,if=none,id=nvm-2 \
-device nvme-ns,drive=nvm-2,bus=nvme-ctrl-1,nsid=2 \
-device nvme,id=nvme-ctrl-2,serial=nvme-3,atomic.dn=off,atomic.awun=127,atomic.awupf=63 \
-drive file=/dev/nullb4,if=none,id=nvm-3 \
-device nvme-ns,drive=nvm-3,bus=nvme-ctrl-2 \
Before
======
[root at localhost ~]# nvme id-ctrl /dev/nvme1n1 | grep cmic
cmic : 0x2
[root at localhost ~]# nvme id-ctrl /dev/nvme1n1 | grep awupf
awupf : 63
[root at localhost ~]# nvme id-ns /dev/nvme1n1 | grep nawupf
nawupf : 0
[root at localhost ~]# cat /sys/block/nvme1n1/queue/atomic_write_max_bytes
0
[root at localhost ~]#
AFTER
=====
[root at localhost ~]# nvme id-ctrl /dev/nvme1n1 | grep cmic
cmic : 0x2
[root at localhost ~]# nvme id-ctrl /dev/nvme1n1 | grep awupf
awupf : 63
[root at localhost ~]# nvme id-ns /dev/nvme1n1 | grep nawupf
nawupf : 0
[root at localhost ~]# cat /sys/block/nvme1n1/queue/atomic_write_max_bytes
32768
[root at localhost ~]#
nvme: all namespaces in a subsystem must adhere to a common atomic write size
------------------------------------------------------------------------------
- Replace awupf field in nvme_subsystem struct with atomic_bs. The atomic_bs
value with awupf or nawupf. (nvme_update_disk_info)
- When a namespace is added, the atomic write size (from awupf or nawupf) is
checked with subsys->atomic_bs. If they don't match, the atomic write size is
set to 512 (1U << head->lba_shift) and a message in logged. (nvme_update_disk_info)
QEMU Config
===========
-device nvme-subsys,id=subsys0 \
-device nvme,serial=deadbeef,id=nvme0,subsys=subsys0,atomic.dn=off,atomic.awun=31,atomic.awupf=15 \
-drive id=ns1,file=/dev/nullb1,if=none \
-device nvme-ns,drive=ns1,bus=nvme0,nsid=1,zoned=false,shared=false \
-device nvme,serial=deadbeef,id=nvme1,subsys=subsys0,atomic.dn=off,atomic.awun=63,atomic.awupf=31 \
-drive id=ns2,file=/dev/nullb2,if=none \
-device nvme-ns,drive=ns2,bus=nvme1,nsid=2,zoned=false,shared=false \
BEFORE
======
[root at localhost ~]# nvme id-ctrl /dev/nvme0n1 | grep cmic
cmic : 0x2
[root at localhost ~]# nvme id-ctrl /dev/nvme0n1 | grep awupf
awupf : 15
[root at localhost ~]# nvme id-ns /dev/nvme0n1 | grep nawupf
nawupf : 0
[root at localhost ~]# cat /sys/block/nvme0n1/queue/atomic_write_max_bytes
8192
[root at localhost ~]# nvme id-ctrl /dev/nvme0n2 | grep cmic
cmic : 0x2
[root at localhost ~]# nvme id-ctrl /dev/nvme0n2 | grep awupf
awupf : 31
[root at localhost ~]# nvme id-ns /dev/nvme0n2 | grep nawupf
nawupf : 0
[root at localhost ~]# cat /sys/block/nvme0n2/queue/atomic_write_max_bytes
8192
[root at localhost ~]#
AFTER
=====
[root at localhost ~]# nvme id-ctrl /dev/nvme0n1 | grep cmic
cmic : 0x2
[root at localhost ~]# nvme id-ctrl /dev/nvme0n1 | grep awupf
awupf : 15
[root at localhost ~]# nvme id-ns /dev/nvme0n1 | grep nawupf
nawupf : 0
[root at localhost ~]# cat /sys/block/nvme0n1/queue/atomic_write_max_bytes
8192
[root at localhost ~]# nvme id-ctrl /dev/nvme0n2 | grep cmic
cmic : 0x2
[root at localhost ~]# nvme id-ctrl /dev/nvme0n2 | grep awupf
awupf : 31
[root at localhost ~]# nvme id-ns /dev/nvme0n2 | grep nawupf
nawupf : 0
[root at localhost ~]# cat /sys/block/nvme0n2/queue/atomic_write_max_bytes
512
Console Message:
[ 2.852814] nvme0c1n2: Inconsistent Atomic Write Size: Subsystem=8192 bytes, Controller/Namespace=16384 bytes
Alan Adamson (2):
nvme: multipath: atomic queue limits need to be inherited for
multipathing
nvme: all namespaces in a subsystem must adhere to a common atomic
write size
drivers/nvme/host/core.c | 20 +++++++++++++++++---
drivers/nvme/host/multipath.c | 3 ++-
drivers/nvme/host/nvme.h | 3 ++-
drivers/ras/amd/atl/internal.h | 3 +++
drivers/ras/amd/atl/umc.c | 19 +++++++++++++++++--
drivers/ras/amd/fmpm.c | 9 ++++++++-
6 files changed, 49 insertions(+), 8 deletions(-)
--
2.43.5
More information about the Linux-nvme
mailing list