Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvme-fabrics: fix and refine state checks in __nvmf_check_ready

- make sure we only allow internally generates commands in any non-live
state
- only allow connect commands on non-live queues when actually in the
new or connecting states
- treat all other non-live, non-dead states the same as a default
cach-all

This fixes a regression where we could not shutdown a controller
orderly as we didn't allow the internal generated Property Set
command, and also ensures we don't accidentally let a Connect command
through in the wrong state.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: James Smart <james.smart@broadcom.com>

+19 -20
+19 -20
drivers/nvme/host/fabrics.c
··· 556 556 bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq, 557 557 bool queue_live) 558 558 { 559 - struct nvme_command *cmd = nvme_req(rq)->cmd; 559 + struct nvme_request *req = nvme_req(rq); 560 560 561 + /* 562 + * If we are in some state of setup or teardown only allow 563 + * internally generated commands. 564 + */ 565 + if (!blk_rq_is_passthrough(rq) || (req->flags & NVME_REQ_USERCMD)) 566 + return false; 567 + 568 + /* 569 + * Only allow commands on a live queue, except for the connect command, 570 + * which is require to set the queue live in the appropinquate states. 571 + */ 561 572 switch (ctrl->state) { 562 573 case NVME_CTRL_NEW: 563 574 case NVME_CTRL_CONNECTING: 564 - case NVME_CTRL_DELETING: 565 - /* 566 - * If queue is live, allow only commands that are internally 567 - * generated pass through. These are commands on the admin 568 - * queue to initialize the controller. This will reject any 569 - * ioctl admin cmds received while initializing. 570 - */ 571 - if (queue_live && !(nvme_req(rq)->flags & NVME_REQ_USERCMD)) 575 + if (req->cmd->common.opcode == nvme_fabrics_command && 576 + req->cmd->fabrics.fctype == nvme_fabrics_type_connect) 572 577 return true; 573 - 574 - /* 575 - * If the queue is not live, allow only a connect command. This 576 - * will reject any ioctl admin cmd as well as initialization 577 - * commands if the controller reverted the queue to non-live. 578 - */ 579 - if (!queue_live && blk_rq_is_passthrough(rq) && 580 - cmd->common.opcode == nvme_fabrics_command && 581 - cmd->fabrics.fctype == nvme_fabrics_type_connect) 582 - return true; 583 - return false; 578 + break; 584 579 default: 580 + break; 581 + case NVME_CTRL_DEAD: 585 582 return false; 586 583 } 584 + 585 + return queue_live; 587 586 } 588 587 EXPORT_SYMBOL_GPL(__nvmf_check_ready); 589 588