Skip to content

Commit

Permalink
nvmet: return bool from nvmet_passthru_ctrl and nvmet_is_passthru_req
Browse files Browse the repository at this point in the history
The target core code never needs the host-side nvme_ctrl structure.
Open code two uses of nvmet_is_passthru_req in passthru.c, and then
switch the helpers used by the core to return bool.  Also rename the
fuctions to better match their usage:

  nvmet_passthru_ctrl -> nvmet_is_passthru_subsys
  nvmet_req_passthru_ctrl -> nvmet_is_passthru_req

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
  • Loading branch information
Christoph Hellwig committed Sep 6, 2021
1 parent 77d651a commit ab7a273
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion drivers/nvme/target/admin-cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
if (unlikely(ret))
return ret;

if (nvmet_req_passthru_ctrl(req))
if (nvmet_is_passthru_req(req))
return nvmet_parse_passthru_admin_cmd(req);

switch (cmd->common.opcode) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/nvme/target/configfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ nvmet_subsys_attr_version_store_locked(struct nvmet_subsys *subsys,
}

/* passthru subsystems use the underlying controller's version */
if (nvmet_passthru_ctrl(subsys))
if (nvmet_is_passthru_subsys(subsys))
return -EINVAL;

ret = sscanf(page, "%d.%d.%d\n", &major, &minor, &tertiary);
Expand Down
6 changes: 3 additions & 3 deletions drivers/nvme/target/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
mutex_lock(&subsys->lock);
ret = 0;

if (nvmet_passthru_ctrl(subsys)) {
if (nvmet_is_passthru_subsys(subsys)) {
pr_info("cannot enable both passthru and regular namespaces for a single subsystem");
goto out_unlock;
}
Expand Down Expand Up @@ -869,7 +869,7 @@ static u16 nvmet_parse_io_cmd(struct nvmet_req *req)
if (unlikely(ret))
return ret;

if (nvmet_req_passthru_ctrl(req))
if (nvmet_is_passthru_req(req))
return nvmet_parse_passthru_io_cmd(req);

ret = nvmet_req_find_ns(req);
Expand Down Expand Up @@ -1207,7 +1207,7 @@ static void nvmet_init_cap(struct nvmet_ctrl *ctrl)
/* maximum queue entries supported: */
ctrl->cap |= NVMET_QUEUE_SIZE - 1;

if (nvmet_passthru_ctrl(ctrl->subsys))
if (nvmet_is_passthru_subsys(ctrl->subsys))
nvmet_passthrough_override_cap(ctrl);
}

Expand Down
9 changes: 4 additions & 5 deletions drivers/nvme/target/nvmet.h
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ int nvmet_passthru_ctrl_enable(struct nvmet_subsys *subsys);
void nvmet_passthru_ctrl_disable(struct nvmet_subsys *subsys);
u16 nvmet_parse_passthru_admin_cmd(struct nvmet_req *req);
u16 nvmet_parse_passthru_io_cmd(struct nvmet_req *req);
static inline struct nvme_ctrl *nvmet_passthru_ctrl(struct nvmet_subsys *subsys)
static inline bool nvmet_is_passthru_subsys(struct nvmet_subsys *subsys)
{
return subsys->passthru_ctrl;
}
Expand All @@ -601,16 +601,15 @@ static inline u16 nvmet_parse_passthru_io_cmd(struct nvmet_req *req)
{
return 0;
}
static inline struct nvme_ctrl *nvmet_passthru_ctrl(struct nvmet_subsys *subsys)
static inline bool nvmet_is_passthru_subsys(struct nvmet_subsys *subsys)
{
return NULL;
}
#endif /* CONFIG_NVME_TARGET_PASSTHRU */

static inline struct nvme_ctrl *
nvmet_req_passthru_ctrl(struct nvmet_req *req)
static inline bool nvmet_is_passthru_req(struct nvmet_req *req)
{
return nvmet_passthru_ctrl(nvmet_req_subsys(req));
return nvmet_is_passthru_subsys(nvmet_req_subsys(req));
}

void nvmet_passthrough_override_cap(struct nvmet_ctrl *ctrl);
Expand Down
4 changes: 2 additions & 2 deletions drivers/nvme/target/passthru.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static int nvmet_passthru_map_sg(struct nvmet_req *req, struct request *rq)

static void nvmet_passthru_execute_cmd(struct nvmet_req *req)
{
struct nvme_ctrl *ctrl = nvmet_req_passthru_ctrl(req);
struct nvme_ctrl *ctrl = nvmet_req_subsys(req)->passthru_ctrl;
struct request_queue *q = ctrl->admin_q;
struct nvme_ns *ns = NULL;
struct request *rq = NULL;
Expand Down Expand Up @@ -309,7 +309,7 @@ static void nvmet_passthru_execute_cmd(struct nvmet_req *req)
*/
static void nvmet_passthru_set_host_behaviour(struct nvmet_req *req)
{
struct nvme_ctrl *ctrl = nvmet_req_passthru_ctrl(req);
struct nvme_ctrl *ctrl = nvmet_req_subsys(req)->passthru_ctrl;
struct nvme_feat_host_behavior *host;
u16 status = NVME_SC_INTERNAL;
int ret;
Expand Down

0 comments on commit ab7a273

Please sign in to comment.