Re: [PATCH v2 5/5] nvme: raise FDP placement handle cap to U8_MAX and warn on overflow

Guixin Liu <[email protected]> Tue, 4 Aug 2026 10:20:35 +0800
Newsgroups org.infradead.lists.linux-nvme
Message-ID <[email protected]>

在 2026/8/1 00:36, Kanchan Joshi 写道:
> On 7/31/2026 8:50 AM, Guixin Liu wrote:
>> @@ -2342,7 +2350,7 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info)
>>    	if (!info->runs)
>>    		return ret;
>>    
>> -	size = struct_size(ruhs, ruhsd, S8_MAX - 1);
>> +	size = struct_size(ruhs, ruhsd, NVME_MAX_PLIDS);
>>    	ruhs = kzalloc(size, GFP_KERNEL);
>>    	if (!ruhs)
>>    		return -ENOMEM;
>> @@ -2357,8 +2365,13 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info)
>>    		goto free;
>>    	}
>>    
>> -	head->nr_plids = le16_to_cpu(ruhs->nruhsd);
>> -	head->nr_plids = min_t(u16, head->nr_plids, S8_MAX - 1);
>> +	nr_plids = le16_to_cpu(ruhs->nruhsd);
>> +	if (nr_plids > NVME_MAX_PLIDS)
> I'd move this check down; after if (!head->nr_plids) part below.
>
>> +		dev_warn(ctrl->device,
>> +			 "FDP RUH status reports %u placement handles, capping at %u\n",
>> +			 nr_plids, NVME_MAX_PLIDS);
>> +
>> +	head->nr_plids = min_t(u16, nr_plids, NVME_MAX_PLIDS);
> And will keep this in above if block, alongside dev_warn(). And kill
> that min_t with a simple
> 	head->nr_plids = NVME_MAX_PLIDS;
>
>>    	if (!head->nr_plids)
>>    		goto free;
>>    
> Modulo these nits
> Reviewed-by: Kanchan Joshi <[email protected]>
Changed in v3, thanks.

Best Regards,
Guixin Liu