[PATCHv2] nvme: use ctrl state accessor

Chaitanya Kulkarni chaitanyak at nvidia.com
Fri Jan 26 00:25:38 PST 2024


On 1/25/24 07:52, Keith Busch wrote:
> From: Keith Busch <kbusch at kernel.org>
>
> The ctrl->state value is updated in another thread using WRITE_ONCE, so
> ensure all the readers use the appropriate accessor.
>
> Signed-off-by: Keith Busch <kbusch at kernel.org>
> ---
>

Keith,

Not sure if nvme_check_ready() needs nvme_ctrl_state() ?

consider :-

* Thread A running timeout handler :-
nvme_timeout()
  ends up resetting ctrl state at the end of function using WRITE_ONCE() :-

  disable:
            nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_RESETTING)
             WRITE_ONCE()

* Thread B issuing I/O :-
nvme_queue_rq() or nvme_prep_rq_batch()
  nvme_check_ready()
   ctrl->state == NVME_CTRL_LIVE

Since timeout handler's nvme_change_ctrl_state() call will result in
updating ctrl->state with WRITE_ONCE(), hence reader in the 
nvme_check_ready()
should also read using nvme_ctrl_state()->READ_ONCE() ?

if it is not needed please ignore above question, looks good to me ..

Reviewed-by: Chaitanya Kulkarni <kch at nvidia.com>

-ck




More information about the Linux-nvme mailing list