[PATCH] nvme: ensure reset state check ordering

Sagi Grimberg sagi at grimberg.me
Mon Nov 20 06:36:07 PST 2023


>>>> From: Keith Busch <kbusch at kernel.org>
>>>>
>>>> A different CPU may be setting the ctrl->state value while flushing the
>>>> reset work, so ensure proper barriers to prevent reading a stale state.
>>>> Reading the wrong state can report unexpected ENETRESET errors when
>>>> everything was successful.
>>>
>>> smp_load_acquire needs to be paired with a smp_store_release.
>>>
>>> We should either always hold the lock or use WRITE_ONCE/READ_ONCE
>>
>> which lock?
> 
> in this case: ctrl->lock.

Yes, we can do either. READ/WRITE_ONCE seems more appropriate. Worth
a comment because we don't use it in other places where it is advisory.



More information about the Linux-nvme mailing list