Skip to content

Commit 5c687c2

Browse files
committed
nvme: introduce helper function to get ctrl state
The controller state is typically written by another CPU, so reading it should ensure no optimizations are taken. This is a repeated pattern in the driver, so start with adding a convenience function that returns the controller state with READ_ONCE(). Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent a134cd8 commit 5c687c2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/nvme/host/nvme.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@ struct nvme_ctrl {
387387
enum nvme_dctype dctype;
388388
};
389389

390+
static inline enum nvme_ctrl_state nvme_ctrl_state(struct nvme_ctrl *ctrl)
391+
{
392+
return READ_ONCE(ctrl->state);
393+
}
394+
390395
enum nvme_iopolicy {
391396
NVME_IOPOLICY_NUMA,
392397
NVME_IOPOLICY_RR,

0 commit comments

Comments
 (0)