[PATCH 2/7] nvme-fabrics: introduce nvmf_reconnect_or_remove API

Max Gurtovoy mgurtovoy at nvidia.com
Tue Oct 19 05:58:14 PDT 2021


On 10/19/2021 3:36 PM, Sagi Grimberg wrote:
>
>> This logic is duplicated today for RDMA and TCP controllers. Move it to
>> the fabrics driver and export it as a new API.
>>
>> Also update the RDMA/TCP transport drivers to use this API and remove
>> the duplicated code.
>>
>> Reviewed-by: Israel Rukshin <israelr at nvidia.com>
>> Signed-off-by: Max Gurtovoy <mgurtovoy at nvidia.com>
>> ---
>>   drivers/nvme/host/fabrics.c | 21 +++++++++++++++++++++
>>   drivers/nvme/host/fabrics.h |  1 +
>>   drivers/nvme/host/rdma.c    | 25 +++----------------------
>>   drivers/nvme/host/tcp.c     | 26 +++-----------------------
>>   4 files changed, 28 insertions(+), 45 deletions(-)
>>
>> diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
>> index 668c6bb7a567..4a1ef67c6fb3 100644
>> --- a/drivers/nvme/host/fabrics.c
>> +++ b/drivers/nvme/host/fabrics.c
>> @@ -472,6 +472,27 @@ bool nvmf_should_reconnect(struct nvme_ctrl *ctrl)
>>   }
>>   EXPORT_SYMBOL_GPL(nvmf_should_reconnect);
>>   +void nvmf_reconnect_or_remove(struct nvme_ctrl *ctrl)
>> +{
>> +    /* If we are resetting/deleting then do nothing */
>> +    if (ctrl->state != NVME_CTRL_CONNECTING) {
>> +        WARN_ON_ONCE(ctrl->state == NVME_CTRL_NEW ||
>> +            ctrl->state == NVME_CTRL_LIVE);
>> +        return;
>> +    }
>> +
>> +    if (nvmf_should_reconnect(ctrl)) {
>> +        dev_info(ctrl->device, "Reconnecting in %d seconds...\n",
>> +            ctrl->opts->reconnect_delay);
>> +        queue_delayed_work(nvme_wq, &ctrl->connect_work,
>> +                ctrl->opts->reconnect_delay * HZ);
>> +    } else {
>> +        dev_info(ctrl->device, "Removing controller...\n");
>> +        nvme_delete_ctrl(ctrl);
>> +    }
>
> We need to look at fc here as it does this differently.
> Can it converge somehow? if not we can add a callback for a driver
> to override it.

we need to start somewhere.

Adding a callback to override this logic is not a problem and i thought 
about it but decided not to do so.

James and other FC developers evaluate moving FC code using more core 
functionality to ease on this driver.

This work can be done also after merging this series.

This series is not related to that.




More information about the Linux-nvme mailing list