nvme: avoid fallback to sequential scan due to transient issues
authorUday Shankar <ushankar@purestorage.com>
Tue, 15 Nov 2022 00:23:59 +0000 (17:23 -0700)
committerChristoph Hellwig <hch@lst.de>
Wed, 16 Nov 2022 07:36:37 +0000 (08:36 +0100)
commit811f4de0344d48a33a94d5c7d31a0ef0490f5701
tree34375aba64fbb37bb0a6fe57a777286c019ba9c6
parent91c11d5f32547a08d462934246488fe72f3d44c3
nvme: avoid fallback to sequential scan due to transient issues

Currently, if nvme_scan_ns_list fails, nvme_scan_work will fall back to
a sequential scan. nvme_scan_ns_list can fail for a variety of reasons,
e.g. a transient transport issue, and the resulting sequential scan can
be extremely expensive on controllers reporting an NN value close to the
maximum allowed (> 4 billion). Avoid sequential scans wherever possible
by only falling back to them in two cases:

- When the NVMe version supported (VS) value reported by the device is
  older than NVME_VS(1, 1, 0), before which support of Identify NS List
  not required.
- When the Identify NS List command fails with the DNR bit set in the
  status. This is to accommodate (non-compliant) devices which report a
  VS value which implies support for Identify NS List, but nevertheless
  do not support the command. Such devices will most likely fail the
  command with the DNR bit set.

The third case is when the device claims support for Identify NS List
but the command fails with DNR not set. In such cases, fallback to
sequential scan is potentially expensive and likely unnecessary, as a
retry of the list scan should succeed. So this change skips the fallback
in this third case.

Signed-off-by: Uday Shankar <ushankar@purestorage.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/core.c