Skip to content

NVMe Atomic Write fixes

Alan Adamson linux-nvme 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 7 repliesIn review
  2. v22 patches 1 replySuperseded
  3. v12 patches 5 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2nvme: multipath: enable BLK_FEAT_ATOMIC_WRITES for multipathingdrivers/nvme/host/multipath.c+2 -11 reply
2/2nvme: all namespaces in a subsystem must adhere to a common atomic write sizedrivers/nvme/host/core.c drivers/nvme/host/nvme.h+28 -45 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchJohn GarryChaitanya Kulkarni
1/2R-b R-b
2/2R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/2] NVMe Atomic Write fixes

v3: 2/2 - Add comment.
- Include "Namespace will not be added" to error message.

v2: 1/2 - Change wording of patch subject and description

2/2 - Rather than setting a controllers atomic write size to 512b if it doesn't
match the subsystem atomic write size, if a controllers atomic write size is greater than he subsystem atomic write size, reject to probe.

This patch set includes 2 fixes for NVMe Atomic Writes that are reproducable when CMIC.MCTRS (multi-controller support) is set:

PATCH 1/2 - nvme: multipath: enable BLK_FEAT_ATOMIC_WRITES for multipathing PATCH 2/2 - 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: enable BLK_FEAT_ATOMIC_WRITES 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@localhost ~]# nvme id-ctrl /dev/nvme1n1 | grep cmic
cmic : 0x2
[root@localhost ~]# nvme id-ctrl /dev/nvme1n1 | grep awupf
awupf : 63
[root@localhost ~]# nvme id-ns /dev/nvme1n1 | grep nawupf nawupf : 0
[root@localhost ~]# cat /sys/block/nvme1n1/queue/atomic_write_max_bytes 0
[root@localhost ~]#

AFTER
=====
[root@localhost ~]# nvme id-ctrl /dev/nvme1n1 | grep cmic
cmic : 0x2
[root@localhost ~]# nvme id-ctrl /dev/nvme1n1 | grep awupf
awupf : 63
[root@localhost ~]# nvme id-ns /dev/nvme1n1 | grep nawupf nawupf : 0
[root@localhost ~]# cat /sys/block/nvme1n1/queue/atomic_write_max_bytes 32768
[root@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@localhost ~]# nvme id-ctrl /dev/nvme0n1 | grep cmic
cmic : 0x2
[root@localhost ~]# nvme id-ctrl /dev/nvme0n1 | grep awupf
awupf : 15
[root@localhost ~]# nvme id-ns /dev/nvme0n1 | grep nawupf nawupf : 0
[root@localhost ~]# cat /sys/block/nvme0n1/queue/atomic_write_max_bytes 8192
[root@localhost ~]# nvme id-ctrl /dev/nvme0n2 | grep cmic
cmic : 0x2
[root@localhost ~]# nvme id-ctrl /dev/nvme0n2 | grep awupf
awupf : 31
[root@localhost ~]# nvme id-ns /dev/nvme0n2 | grep nawupf nawupf : 0
[root@localhost ~]# cat /sys/block/nvme0n2/queue/atomic_write_max_bytes 8192
[root@localhost ~]#

AFTER
=====
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS

sda           8:0    0   40G  0 disk 
├─sda1        8:1    0    1G  0 part /boot
└─sda2        8:2    0   39G  0 part 
  └─ol-root 252:0    0   39G  0 lvm  /
sr0          11:0    1 1024M  0 rom  
nvme1n2     259:1    0  250G  0 disk 

[root@localhost ~]# nvme id-ctrl /dev/nvme0n1 | grep cmic
cmic : 0x2
[root@localhost ~]# nvme id-ctrl /dev/nvme0n1 | grep awupf
awupf : 15
[root@localhost ~]# nvme id-ns /dev/nvme0n1 | grep nawupf nawupf : 0
[root@localhost ~]# cat /sys/block/nvme0n1/queue/atomic_write_max_bytes 8192

Console output:

[    2.848854] nvme0c1n2: Inconsistent Atomic Write Size, Namespace will not be added: Subsystem=8192 bytes, Controller/Namespace=16384 bytes
Signature · 1 line
2.43.5