Skip to content

Commit

Permalink
nvme: introduce helper function to get ctrl state
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Keith Busch committed Dec 4, 2023
1 parent a134cd8 commit 5c687c2
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 @@ -387,6 +387,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 5c687c2

Please sign in to comment.