Four removal jobs shown first in sequence and then overlapping. The illustration represents waiting order, not measured durations.
Gear / The story

Linux cuts a 64-namespace NVMe disconnect from 1.2 seconds to half a second in a local test

The Linux 7.4 driver can overlap waits while retiring logical devices. Two local transports show why the improvement depends on how the controller is connected.

GeekRadar3 min read

A Linux storage server used to retire its logical devices one at a time when it disconnected from an NVMe controller. In a test with 64 of those devices, the old kernel took 1.20 and 1.31 seconds across two boots to disconnect a local NVMe-over-TCP target. A change merged into the Linux 7.4 development tree on November 20 brought those times down to 533 and 550 milliseconds. The interesting part is where the time went. Linux still has to wait for readers to finish using each device. It can now spend some of that waiting time on all of them at once.

What disappears when a controller disconnects?

One NVMe controller can present several storage devices to an operating system. Each exposes a numbered range of logical blocks called a namespace. Linux might call the first one /dev/nvme0n1. A second namespace can have its own device name even when the underlying storage sits behind the same controller. NVM Express explains the distinction between logical and physical storage.

That distinction is particularly useful when the storage is reached over a network. Disconnecting the host from the controller means retiring the host’s device entries. The operation timed here does not erase the data on the storage target. Nor does timing it tell us how fast the SSD can serve requests while connected. For an example of the latter engineering problem, see how Silicon Motion handles competing workloads on a shared SSD.

Disconnect time in milliseconds for 64 namespaces. A is the original kernel, B the patched kernel. Each row is one boot’s median of three runs. Data from Qiliang Yuan.
Disconnect time in milliseconds for 64 namespaces. A is the original kernel, B the patched kernel. Each row is one boot’s median of three runs. Data from Qiliang Yuan.

Why the waits can overlap

In the old path, Linux finished removing one namespace before starting on the next. Part of removal involved waiting for read-copy-update, or RCU. A kernel reader might already hold a reference to an object when another part of the system takes it out of circulation. The kernel documentation explains why the memory can be reclaimed only after those earlier readers have finished. That interval is called a grace period.

Qiliang Yuan’s patch and test results put the accumulated waits per removal at about 20 milliseconds in the reported setup. Starting 64 removals one by one made the controller pay that cost repeatedly. The revised driver starts independent removal jobs and waits for the whole group before returning. Several jobs can benefit from the same grace period. None gets permission to reclaim an object early.

The TCP result gets the attention, but the loop result is a useful check on what the headline number means. Both configurations had 64 namespaces, used the same change and got faster by different proportions. What the patch gives a storage administrator is a shorter wait at the point a controller is dismantled. A file copy to a healthy drive never reaches that part of the driver.