[PATCH 3/3] nvme: use helper nvme_ctrl_state in nvme_keep_alive_end_io function
Nilay Shroff
nilay at linux.ibm.com
Tue Oct 29 23:07:15 PDT 2024
On 10/29/24 20:31, Keith Busch wrote:
> On Sun, Oct 27, 2024 at 10:32:06PM +0530, Nilay Shroff wrote:
>> We no more need acquiring ctrl->lock before accessing the
>> NVMe controller state and instead we can now use the helper
>> nvme_ctrl_state. So replace the use of ctrl->lock from
>> nvme_keep_alive_end_io function with nvme_ctrl_state call.
>>
>> Signed-off-by: Nilay Shroff <nilay at linux.ibm.com>
>> ---
>> drivers/nvme/host/core.c | 11 +++--------
>> 1 file changed, 3 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
>> index 865c00ea19e3..6e814daf1002 100644
>> --- a/drivers/nvme/host/core.c
>> +++ b/drivers/nvme/host/core.c
>> @@ -1296,10 +1296,9 @@ static enum rq_end_io_ret nvme_keep_alive_end_io(struct request *rq,
>> blk_status_t status)
>> {
>> struct nvme_ctrl *ctrl = rq->end_io_data;
>> - unsigned long flags;
>> - bool startka = false;
>> unsigned long rtt = jiffies - (rq->deadline - rq->timeout);
>> unsigned long delay = nvme_keep_alive_work_period(ctrl);
>> + enum nvme_ctrl_state state = nvme_ctrl_state(ctrl->state);
>>
>> /*
>> * Subtract off the keepalive RTT so nvme_keep_alive_work runs
>> @@ -1324,13 +1323,9 @@ static enum rq_end_io_ret nvme_keep_alive_end_io(struct request *rq,
>>
>> ctrl->ka_last_check_time = jiffies;
>> ctrl->comp_seen = false;
>> - spin_lock_irqsave(&ctrl->lock, flags);
>> - if (ctrl->state == NVME_CTRL_LIVE ||
>> - ctrl->state == NVME_CTRL_CONNECTING)
>> - startka = true;
>> - spin_unlock_irqrestore(&ctrl->lock, flags);
>> - if (startka)
>> + if (state == NVME_CTRL_LIVE || state == NVME_CTRL_CONNECTING)
>> queue_delayed_work(nvme_wq, &ctrl->ka_work, delay);
>> +
>> return RQ_END_IO_NONE;
>> }
>
> This restores what you had in the reverted patch, which was a
> significant portion of the diff stat. If we're keeping this chunk, maybe
> a full revert isn't necessary, and we can squash the series to just one
> fixing commit.
>
This doesn't exactly restore what was reverted in the patch. If you
closely look at the reverted patch then you would find that we reverted
the nvme_keep_alive_finish function which is not exactly same as
nvme_keep_alive_end_io function. We renamed nvme_keep_alive_end_io()
to nvme_keep_alive_finish() for the upstream patch.
So the revert patch restores nvme_keep_alive_end_io function and also
restores the nvme_keep_alive_work changes. Then the current patch in this
patchset, actually works upon nvme_keep_alive_end_io function.
Thanks,
--Nilay
More information about the Linux-nvme
mailing list