summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorCaleb Sander Mateos <csander@purestorage.com>2026-02-27 13:23:51 -0700
committerKeith Busch <kbusch@kernel.org>2026-03-27 07:35:04 -0700
commit1029298da36559866ecb5ddaa3d78deb02f2ab9b (patch)
tree5e241ad05ad4d0fdc3ce3a966ff647a4997d23ec /scripts
parentb465046c8cca9e418c7b39cfb41bb8e3b62f22f6 (diff)
nvme: set discard_granularity from NPDG/NPDA
Currently, nvme_config_discard() always sets the discard_granularity queue limit to the logical block size. However, NVMe namespaces can advertise a larger preferred discard granularity in the NPDG or NPDA field of the Identify Namespace structure or the NPDGL or NPDAL fields of the I/O Command Set Specific Identify Namespace structure. Use these fields to compute the discard_granularity limit. The logic is somewhat involved. First, the fields are optional. NPDG is only reported if the low bit of OPTPERF is set in NSFEAT. NPDA is reported if any bit of OPTPERF is set. And NPDGL and NPDAL are reported if the high bit of OPTPERF is set. NPDGL and NPDAL can also each be set to 0 to opt out of reporting a limit. I/O Command Set Specific Identify Namespace may also not be supported by older NVMe controllers. Another complication is that multiple values may be reported among NPDG, NPDGL, NPDA, and NPDAL. The spec says to prefer the values reported in the L variants. The spec says NPDG should be a multiple of NPDA and NPDGL should be a multiple of NPDAL, but it doesn't specify a relationship between NPDG and NPDAL or NPDGL and NPDA. So use the maximum of the reported NPDG(L) and NPDA(L) values as the discard_granularity. Signed-off-by: Caleb Sander Mateos <csander@purestorage.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions