Skip to content

Commit

Permalink
nvme: introduce helper function to get ctrl state
Browse files Browse the repository at this point in the history
[ Upstream commit 5c687c2 ]

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 <[email protected]>
Signed-off-by: Keith Busch <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
keithbusch authored and gregkh committed Jan 20, 2024
1 parent 8392d32 commit cc5b051
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/nvme/host/nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@ struct nvme_ctrl {
enum nvme_dctype dctype;
};

static inline enum nvme_ctrl_state nvme_ctrl_state(struct nvme_ctrl *ctrl)
{
return READ_ONCE(ctrl->state);
}

enum nvme_iopolicy {
NVME_IOPOLICY_NUMA,
NVME_IOPOLICY_RR,
Expand Down

0 comments on commit cc5b051

Please sign in to comment.