lib/nvmf: Support custom admin cmd handler for abort
The new abort functionality doesn't take custom admin cmd handlers into account. This commit allows setting a custom admin cmd handler for abort that provides the ability to influence the bdev lookup to which the abort is sent to. Signed-off-by: Michael Haeuptle <michael.haeuptle@hpe.com> Change-Id: I3a66c6f863f5ee4d89cb2194dffdc6855945fa8a Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3485 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
e2b236ed50
commit
62649a7d7b
@ -132,6 +132,19 @@ typedef void (*spdk_nvmf_nvme_passthru_cmd_cb)(struct spdk_nvmf_request *req);
|
||||
int spdk_nvmf_bdev_ctrlr_nvme_passthru_admin(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
||||
struct spdk_io_channel *ch, struct spdk_nvmf_request *req, spdk_nvmf_nvme_passthru_cmd_cb cb_fn);
|
||||
|
||||
/**
|
||||
* Attempts to abort a request in the specified bdev
|
||||
*
|
||||
* \param bdev Bdev that is processing req_to_abort
|
||||
* \param desc Bdev desc
|
||||
* \param ch Channel on which req_to_abort was originally submitted
|
||||
* \param req Abort cmd req
|
||||
* \param req_to_abort The request that should be aborted
|
||||
*/
|
||||
int spdk_nvmf_bdev_ctrlr_abort_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
||||
struct spdk_io_channel *ch, struct spdk_nvmf_request *req,
|
||||
struct spdk_nvmf_request *req_to_abort);
|
||||
|
||||
/**
|
||||
* Provide access to the underlying bdev that is associated with a namespace.
|
||||
*
|
||||
@ -200,4 +213,14 @@ struct spdk_nvme_cmd *spdk_nvmf_request_get_cmd(struct spdk_nvmf_request *req);
|
||||
*/
|
||||
struct spdk_nvme_cpl *spdk_nvmf_request_get_response(struct spdk_nvmf_request *req);
|
||||
|
||||
/**
|
||||
* Get the request to abort that is associated with this request.
|
||||
* The req to abort is only set if the request processing a SPDK_NVME_OPC_ABORT cmd
|
||||
*
|
||||
* \param req The NVMe-oF abort request
|
||||
*
|
||||
* \return req_to_abort The NVMe-oF request that is in process of being aborted
|
||||
*/
|
||||
struct spdk_nvmf_request *spdk_nvmf_request_get_req_to_abort(struct spdk_nvmf_request *req);
|
||||
|
||||
#endif /* SPDK_NVMF_CMD_H_ */
|
||||
|
@ -2173,13 +2173,18 @@ nvmf_ctrlr_abort_request(struct spdk_nvmf_request *req)
|
||||
|
||||
assert(req_to_abort != NULL);
|
||||
|
||||
if (g_nvmf_custom_admin_cmd_hdlrs[SPDK_NVME_OPC_ABORT].hdlr &&
|
||||
nvmf_qpair_is_admin_queue(req_to_abort->qpair)) {
|
||||
return g_nvmf_custom_admin_cmd_hdlrs[SPDK_NVME_OPC_ABORT].hdlr(req);
|
||||
}
|
||||
|
||||
rc = spdk_nvmf_request_get_bdev(req_to_abort->cmd->nvme_cmd.nsid, req_to_abort,
|
||||
&bdev, &desc, &ch);
|
||||
if (rc != 0) {
|
||||
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
return nvmf_bdev_ctrlr_abort_cmd(bdev, desc, ch, req, req_to_abort);
|
||||
return spdk_nvmf_bdev_ctrlr_abort_cmd(bdev, desc, ch, req, req_to_abort);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -2340,7 +2345,8 @@ nvmf_ctrlr_process_admin_cmd(struct spdk_nvmf_request *req)
|
||||
}
|
||||
}
|
||||
|
||||
if (g_nvmf_custom_admin_cmd_hdlrs[cmd->opc].hdlr) {
|
||||
/* Call a custom adm cmd handler if set. Aborts are handled in a different path (see nvmf_passthru_admin_cmd) */
|
||||
if (g_nvmf_custom_admin_cmd_hdlrs[cmd->opc].hdlr && cmd->opc != SPDK_NVME_OPC_ABORT) {
|
||||
rc = g_nvmf_custom_admin_cmd_hdlrs[cmd->opc].hdlr(req);
|
||||
if (rc >= SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE) {
|
||||
/* The handler took care of this commmand */
|
||||
@ -3211,3 +3217,8 @@ uint16_t spdk_nvmf_ctrlr_get_id(struct spdk_nvmf_ctrlr *ctrlr)
|
||||
{
|
||||
return ctrlr->cntlid;
|
||||
}
|
||||
|
||||
struct spdk_nvmf_request *spdk_nvmf_request_get_req_to_abort(struct spdk_nvmf_request *req)
|
||||
{
|
||||
return req->req_to_abort;
|
||||
}
|
||||
|
@ -707,9 +707,9 @@ nvmf_bdev_ctrlr_complete_abort_cmd(struct spdk_bdev_io *bdev_io, bool success, v
|
||||
}
|
||||
|
||||
int
|
||||
nvmf_bdev_ctrlr_abort_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
||||
struct spdk_io_channel *ch, struct spdk_nvmf_request *req,
|
||||
struct spdk_nvmf_request *req_to_abort)
|
||||
spdk_nvmf_bdev_ctrlr_abort_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
||||
struct spdk_io_channel *ch, struct spdk_nvmf_request *req,
|
||||
struct spdk_nvmf_request *req_to_abort)
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
@ -309,9 +309,6 @@ int nvmf_bdev_ctrlr_dsm_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
||||
struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
|
||||
int nvmf_bdev_ctrlr_nvme_passthru_io(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
||||
struct spdk_io_channel *ch, struct spdk_nvmf_request *req);
|
||||
int nvmf_bdev_ctrlr_abort_cmd(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
|
||||
struct spdk_io_channel *ch, struct spdk_nvmf_request *req,
|
||||
struct spdk_nvmf_request *req_to_abort);
|
||||
bool nvmf_bdev_ctrlr_get_dif_ctx(struct spdk_bdev *bdev, struct spdk_nvme_cmd *cmd,
|
||||
struct spdk_dif_ctx *dif_ctx);
|
||||
|
||||
|
@ -91,6 +91,8 @@
|
||||
spdk_nvmf_request_get_data;
|
||||
spdk_nvmf_request_get_cmd;
|
||||
spdk_nvmf_request_get_response;
|
||||
spdk_nvmf_request_get_req_to_abort;
|
||||
spdk_nvmf_bdev_ctrlr_abort_cmd;
|
||||
|
||||
# public functions in nvmf_transport.h
|
||||
spdk_nvmf_transport_register;
|
||||
|
@ -163,7 +163,7 @@ DEFINE_STUB(nvmf_bdev_ctrlr_nvme_passthru_io,
|
||||
struct spdk_nvmf_request *req),
|
||||
0);
|
||||
|
||||
DEFINE_STUB(nvmf_bdev_ctrlr_abort_cmd,
|
||||
DEFINE_STUB(spdk_nvmf_bdev_ctrlr_abort_cmd,
|
||||
int,
|
||||
(struct spdk_bdev *bdev, struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
|
||||
struct spdk_nvmf_request *req, struct spdk_nvmf_request *req_to_abort),
|
||||
|
Loading…
Reference in New Issue
Block a user