Re: [PATCH 4/6] nvme: set discard_granularity from NPDG/NPDA

From: Christoph Hellwig

Date: Fri Feb 20 2026 - 11:11:04 EST


On Thu, Feb 19, 2026 at 08:28:07PM -0700, Caleb Sander Mateos wrote:
> -static void nvme_config_discard(struct nvme_ns *ns, struct queue_limits *lim)
> +static void nvme_config_discard(struct nvme_ns *ns, struct nvme_id_ns *id,
> + struct nvme_id_ns_nvm *nvm,
> + struct queue_limits *lim)

The indentation here looks weird, this should be just two tabs.

> - lim->discard_granularity = lim->logical_block_size;
> + optperf = id->nsfeat >> NVME_NS_FEAT_OPTPERF_SHIFT &
> + NVME_NS_FEAT_OPTPERF_MASK;
> + npdg = optperf & 0x2 && nvm && nvm->npdgl ? le32_to_cpu(nvm->npdgl) :
> + optperf & 0x1 ? le16_to_cpu(id->npdg) + 1 : 1;
> + npda = optperf & 0x2 && nvm && nvm->npdal ? le32_to_cpu(nvm->npdal) :
> + optperf ? le16_to_cpu(id->npda) + 1 : 1;

Please undinw this into a few if statemens. (And I really
with the spec would given the bits names..)