[PATCH] Add new clear_ids attribute for passthru targets
Alan Adamson
alan.adamson at oracle.com
Mon Jun 27 16:24:57 PDT 2022
> On Jun 27, 2022, at 2:00 PM, Chaitanya Kulkarni <chaitanyak at nvidia.com> wrote:
>
> On 6/22/22 15:47, Alan Adamson wrote:
>> If the clear_ids attribute is set to true, the EUI/GUID/UUID is
>> cleared for the passthru target. By default, loop targets will
>> set clear_ids to true.
>>
>> This resolves an issue where a connect to a passthru target fails
>> when using a trtype of 'loop' because EUI/GUID/UUID is not unique.
>>
>> Signed-off-by: Alan Adamson <alan.adamson at oracle.com>
>> ---
>> drivers/nvme/target/configfs.c | 20 ++++++++++++
>> drivers/nvme/target/core.c | 4 +++
>> drivers/nvme/target/nvmet.h | 1 +
>> drivers/nvme/target/passthru.c | 58 ++++++++++++++++++++++++++++++++++
>> 4 files changed, 83 insertions(+)
>>
>> diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
>> index e44b2988759e..ff77c3d2354f 100644
>> --- a/drivers/nvme/target/configfs.c
>> +++ b/drivers/nvme/target/configfs.c
>> @@ -773,11 +773,31 @@ static ssize_t nvmet_passthru_io_timeout_store(struct config_item *item,
>> }
>> CONFIGFS_ATTR(nvmet_passthru_, io_timeout);
>>
>> +static ssize_t nvmet_passthru_clear_ids_show(struct config_item *item,
>> + char *page)
>> +{
>> + return sprintf(page, "%u\n", to_subsys(item->ci_parent)->clear_ids);
>
> should we use snprintf() ? (I don't think so just a thought.
I used sprintf() to be consistent with the other passthru attributes.
>>
>> +static u16 nvmet_passthru_override_id_descs(struct nvmet_req *req)
>> +{
>> + struct nvmet_ctrl *ctrl = req->sq->ctrl;
>> + void *data;
>> + struct nvme_ns_id_desc *cur;
>> + u16 status = NVME_SC_SUCCESS;
>> + u8 csi;
>> + int pos, len;
>> + bool csi_seen;
>> +
>
> consider followig if it works, totally untested :-
>
> struct nvmet_ctrl *ctrl = req->sq->ctrl;
> struct nvme_ns_id_desc *cur;
> u16 status = NVME_SC_SUCCESS;
> int pos, len;
> bool csi_seen;
> void *data;
> u8 csi;
I'll include these changes in v2.
>>
>> static u16 nvmet_passthru_override_id_ns(struct nvmet_req *req)
>> {
>> + struct nvmet_ctrl *ctrl = req->sq->ctrl;
>
> since ctrl is only used once in this function do can we get away with
> the req->sq->ctrl->subsys->clear_ids ?
I’ll include in v2.
>>
>
> Irrespective of cosmetics, looks good.
>
> Reviewed-by: Chaitanya Kulkarni <kch at nvidia.com>
>
> -ck
>
Thanks,
Alan
More information about the Linux-nvme
mailing list