[PATCH v2 1/2] nvmet: return Invalid Field for invalid NSIDs in Set Features 82h

Guixin Liu kanie at linux.alibaba.com
Mon Sep 21 00:56:04 PDT 2026



在 2026/9/21 14:53, Christoph Hellwig 写道:
> On Sun, Sep 20, 2026 at 04:37:08PM +0530, Nilay Shroff wrote:
>> On 9/20/26 9:04 AM, Guixin Liu wrote:
>>> diff --git a/drivers/nvme/target/pr.c b/drivers/nvme/target/pr.c
>>> index 0948a690a1c0..a36c732883d4 100644
>>> --- a/drivers/nvme/target/pr.c
>>> +++ b/drivers/nvme/target/pr.c
>>> @@ -51,6 +51,8 @@ u16 nvmet_set_feat_resv_notif_mask(struct nvmet_req *req, u32 mask)
>>>     	if (nsid != U32_MAX) {
>>>   		status = nvmet_req_find_ns(req);
>>> +		if (status == (NVME_SC_INVALID_NS | NVME_STATUS_DNR))
>>> +			return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
>>>   		if (status)
>>>   			return status;
>>>   		if (!req->ns->pr.enable)
>>> -- 
>> This looks good to me. However, to avoid hand-coding the same error
>> return code multiple times in the function and to make it a bit more
>> readable, how about modifying it as follows?
> I don't understand how that helps.  If we really want to refactor,
> we could add a version of nvmet_req_find_ns that does it, but
> that feels like a bit of overkill.
Agree.
>
>> 		if (status == (NVME_SC_INVALID_NS | NVME_STATUS_DNR))
> Still no need for the inner braces here in all versions.
Well, in C, the "==" operator has higher precedence than "|",
so the inner braces are required here.

Best Regards,
Guixin Liu




More information about the Linux-nvme mailing list