[PATCH v2] nvme: Fix handling of large MDTS values
Bart Van Assche
bvanassche at acm.org
Fri Apr 2 02:37:03 BST 2021
On 4/1/21 8:54 AM, Keith Busch wrote:
> On Wed, Mar 31, 2021 at 08:59:52PM -0700, Bart Van Assche wrote:
>> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
>> index 40215a0246e4..25bc28e8845f 100644
>> --- a/drivers/nvme/host/core.c
>> +++ b/drivers/nvme/host/core.c
>> @@ -3123,10 +3123,11 @@ static int nvme_init_identify(struct nvme_ctrl *ctrl)
>>
>> atomic_set(&ctrl->abort_limit, id->acl + 1);
>> ctrl->vwc = id->vwc;
>> - if (id->mdts)
>> - max_hw_sectors = 1 << (id->mdts + page_shift - 9);
>> - else
>> + max_hw_sectors = UINT_MAX;
>> + if (id->mdts && check_shl_overflow(1U, id->mdts + page_shift - 9,
>> + &max_hw_sectors)) {
>> max_hw_sectors = UINT_MAX;
>> + }
>
> The condition can be rearranged so that max_hw_sectors is set to
> UINT_MAX just once:
>
> if (!id->mdts || check_shl_overflow(1U, id->mdts + page_shift - 9,
> &max_hw_sectors)) {
> max_hw_sectors = UINT_MAX;
> }
Hi Keith,
That's an interesting suggestion. I will integrate this change in my
patch and repost it.
Thanks,
Bart.
More information about the Linux-nvme
mailing list