Skip to content

Commit ab7a273

Browse files
author
Christoph Hellwig
committed
nvmet: return bool from nvmet_passthru_ctrl and nvmet_is_passthru_req
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 <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]>
1 parent 77d651a commit ab7a273

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

drivers/nvme/target/admin-cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
10151015
if (unlikely(ret))
10161016
return ret;
10171017

1018-
if (nvmet_req_passthru_ctrl(req))
1018+
if (nvmet_is_passthru_req(req))
10191019
return nvmet_parse_passthru_admin_cmd(req);
10201020

10211021
switch (cmd->common.opcode) {

drivers/nvme/target/configfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ nvmet_subsys_attr_version_store_locked(struct nvmet_subsys *subsys,
10281028
}
10291029

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

10341034
ret = sscanf(page, "%d.%d.%d\n", &major, &minor, &tertiary);

drivers/nvme/target/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
553553
mutex_lock(&subsys->lock);
554554
ret = 0;
555555

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

872-
if (nvmet_req_passthru_ctrl(req))
872+
if (nvmet_is_passthru_req(req))
873873
return nvmet_parse_passthru_io_cmd(req);
874874

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

1210-
if (nvmet_passthru_ctrl(ctrl->subsys))
1210+
if (nvmet_is_passthru_subsys(ctrl->subsys))
12111211
nvmet_passthrough_override_cap(ctrl);
12121212
}
12131213

drivers/nvme/target/nvmet.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ int nvmet_passthru_ctrl_enable(struct nvmet_subsys *subsys);
582582
void nvmet_passthru_ctrl_disable(struct nvmet_subsys *subsys);
583583
u16 nvmet_parse_passthru_admin_cmd(struct nvmet_req *req);
584584
u16 nvmet_parse_passthru_io_cmd(struct nvmet_req *req);
585-
static inline struct nvme_ctrl *nvmet_passthru_ctrl(struct nvmet_subsys *subsys)
585+
static inline bool nvmet_is_passthru_subsys(struct nvmet_subsys *subsys)
586586
{
587587
return subsys->passthru_ctrl;
588588
}
@@ -601,16 +601,15 @@ static inline u16 nvmet_parse_passthru_io_cmd(struct nvmet_req *req)
601601
{
602602
return 0;
603603
}
604-
static inline struct nvme_ctrl *nvmet_passthru_ctrl(struct nvmet_subsys *subsys)
604+
static inline bool nvmet_is_passthru_subsys(struct nvmet_subsys *subsys)
605605
{
606606
return NULL;
607607
}
608608
#endif /* CONFIG_NVME_TARGET_PASSTHRU */
609609

610-
static inline struct nvme_ctrl *
611-
nvmet_req_passthru_ctrl(struct nvmet_req *req)
610+
static inline bool nvmet_is_passthru_req(struct nvmet_req *req)
612611
{
613-
return nvmet_passthru_ctrl(nvmet_req_subsys(req));
612+
return nvmet_is_passthru_subsys(nvmet_req_subsys(req));
614613
}
615614

616615
void nvmet_passthrough_override_cap(struct nvmet_ctrl *ctrl);

drivers/nvme/target/passthru.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int nvmet_passthru_map_sg(struct nvmet_req *req, struct request *rq)
228228

229229
static void nvmet_passthru_execute_cmd(struct nvmet_req *req)
230230
{
231-
struct nvme_ctrl *ctrl = nvmet_req_passthru_ctrl(req);
231+
struct nvme_ctrl *ctrl = nvmet_req_subsys(req)->passthru_ctrl;
232232
struct request_queue *q = ctrl->admin_q;
233233
struct nvme_ns *ns = NULL;
234234
struct request *rq = NULL;
@@ -309,7 +309,7 @@ static void nvmet_passthru_execute_cmd(struct nvmet_req *req)
309309
*/
310310
static void nvmet_passthru_set_host_behaviour(struct nvmet_req *req)
311311
{
312-
struct nvme_ctrl *ctrl = nvmet_req_passthru_ctrl(req);
312+
struct nvme_ctrl *ctrl = nvmet_req_subsys(req)->passthru_ctrl;
313313
struct nvme_feat_host_behavior *host;
314314
u16 status = NVME_SC_INTERNAL;
315315
int ret;

0 commit comments

Comments
 (0)