nvme: wrapper request completion callback into a function
When IO is finished SPDK will trigger callback at controller layer, while here, wrapper the completion callback into a function so that we can add error injection at this function in following patch. Change-Id: I7b7a6d278d87fd09a05f51f688398fdf2e9c4e05 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.gerrithub.io/411630 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
3ca9cd762b
commit
65e56caa17
@ -470,8 +470,7 @@ spdk_nvme_ctrlr_cmd_abort_cpl(void *ctx, const struct spdk_nvme_cpl *cpl)
|
|||||||
next->cpl.status.sct = SPDK_NVME_SCT_GENERIC;
|
next->cpl.status.sct = SPDK_NVME_SCT_GENERIC;
|
||||||
next->cpl.status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
|
next->cpl.status.sc = SPDK_NVME_SC_INTERNAL_DEVICE_ERROR;
|
||||||
next->cpl.status.dnr = 1;
|
next->cpl.status.dnr = 1;
|
||||||
next->cb_fn(next->cb_arg, &req->cpl);
|
nvme_complete_request(next, &req->cpl);
|
||||||
|
|
||||||
nvme_free_request(next);
|
nvme_free_request(next);
|
||||||
} else {
|
} else {
|
||||||
/* If the first abort succeeds, stop iterating. */
|
/* If the first abort succeeds, stop iterating. */
|
||||||
|
@ -626,6 +626,7 @@ struct nvme_request *nvme_allocate_request_contig(struct spdk_nvme_qpair *qpair,
|
|||||||
struct nvme_request *nvme_allocate_request_user_copy(struct spdk_nvme_qpair *qpair,
|
struct nvme_request *nvme_allocate_request_user_copy(struct spdk_nvme_qpair *qpair,
|
||||||
void *buffer, uint32_t payload_size,
|
void *buffer, uint32_t payload_size,
|
||||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg, bool host_to_controller);
|
spdk_nvme_cmd_cb cb_fn, void *cb_arg, bool host_to_controller);
|
||||||
|
void nvme_complete_request(struct nvme_request *req, struct spdk_nvme_cpl *cpl);
|
||||||
void nvme_free_request(struct nvme_request *req);
|
void nvme_free_request(struct nvme_request *req);
|
||||||
void nvme_request_remove_child(struct nvme_request *parent, struct nvme_request *child);
|
void nvme_request_remove_child(struct nvme_request *parent, struct nvme_request *child);
|
||||||
uint64_t nvme_get_quirks(const struct spdk_pci_id *id);
|
uint64_t nvme_get_quirks(const struct spdk_pci_id *id);
|
||||||
|
@ -52,9 +52,7 @@ nvme_cb_complete_child(void *child_arg, const struct spdk_nvme_cpl *cpl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (parent->num_children == 0) {
|
if (parent->num_children == 0) {
|
||||||
if (parent->cb_fn) {
|
nvme_complete_request(parent, &parent->parent_status);
|
||||||
parent->cb_fn(parent->cb_arg, &parent->parent_status);
|
|
||||||
}
|
|
||||||
nvme_free_request(parent);
|
nvme_free_request(parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1129,10 +1129,7 @@ nvme_pcie_qpair_complete_pending_admin_request(struct spdk_nvme_qpair *qpair)
|
|||||||
|
|
||||||
assert(req->pid == pid);
|
assert(req->pid == pid);
|
||||||
|
|
||||||
if (req->cb_fn) {
|
nvme_complete_request(req, &req->cpl);
|
||||||
req->cb_fn(req->cb_arg, &req->cpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
nvme_free_request(req);
|
nvme_free_request(req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1238,9 +1235,7 @@ nvme_pcie_qpair_complete_tracker(struct spdk_nvme_qpair *qpair, struct nvme_trac
|
|||||||
req_from_current_proc = false;
|
req_from_current_proc = false;
|
||||||
nvme_pcie_qpair_insert_pending_admin_request(qpair, req, cpl);
|
nvme_pcie_qpair_insert_pending_admin_request(qpair, req, cpl);
|
||||||
} else {
|
} else {
|
||||||
if (req->cb_fn) {
|
nvme_complete_request(req, cpl);
|
||||||
req->cb_fn(req->cb_arg, cpl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,10 +347,7 @@ nvme_qpair_manual_complete_request(struct spdk_nvme_qpair *qpair,
|
|||||||
nvme_qpair_print_completion(qpair, &cpl);
|
nvme_qpair_print_completion(qpair, &cpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req->cb_fn) {
|
nvme_complete_request(req, &cpl);
|
||||||
req->cb_fn(req->cb_arg, &cpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
nvme_free_request(req);
|
nvme_free_request(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,6 +448,14 @@ nvme_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_request *re
|
|||||||
return nvme_transport_qpair_submit_request(qpair, req);
|
return nvme_transport_qpair_submit_request(qpair, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nvme_complete_request(struct nvme_request *req, struct spdk_nvme_cpl *cpl)
|
||||||
|
{
|
||||||
|
if (req->cb_fn) {
|
||||||
|
req->cb_fn(req->cb_arg, cpl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_nvme_io_qpair_enable(struct spdk_nvme_qpair *qpair)
|
_nvme_io_qpair_enable(struct spdk_nvme_qpair *qpair)
|
||||||
{
|
{
|
||||||
|
@ -187,7 +187,7 @@ static void
|
|||||||
nvme_rdma_req_complete(struct nvme_request *req,
|
nvme_rdma_req_complete(struct nvme_request *req,
|
||||||
struct spdk_nvme_cpl *rsp)
|
struct spdk_nvme_cpl *rsp)
|
||||||
{
|
{
|
||||||
req->cb_fn(req->cb_arg, rsp);
|
nvme_complete_request(req, rsp);
|
||||||
nvme_free_request(req);
|
nvme_free_request(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,6 +293,14 @@ nvme_allocate_request_user_copy(struct spdk_nvme_qpair *qpair, void *buffer, uin
|
|||||||
return nvme_allocate_request_contig(qpair, buffer, payload_size, cb_fn, cb_arg);
|
return nvme_allocate_request_contig(qpair, buffer, payload_size, cb_fn, cb_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nvme_complete_request(struct nvme_request *req, struct spdk_nvme_cpl *cpl)
|
||||||
|
{
|
||||||
|
if (req->cb_fn) {
|
||||||
|
req->cb_fn(req->cb_arg, cpl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nvme_free_request(struct nvme_request *req)
|
nvme_free_request(struct nvme_request *req)
|
||||||
{
|
{
|
||||||
|
@ -183,6 +183,14 @@ nvme_transport_ctrlr_scan(const struct spdk_nvme_transport_id *trid,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nvme_complete_request(struct nvme_request *req, struct spdk_nvme_cpl *cpl)
|
||||||
|
{
|
||||||
|
if (req->cb_fn) {
|
||||||
|
req->cb_fn(req->cb_arg, cpl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
prepare_for_test(struct spdk_nvme_ns *ns, struct spdk_nvme_ctrlr *ctrlr,
|
prepare_for_test(struct spdk_nvme_ns *ns, struct spdk_nvme_ctrlr *ctrlr,
|
||||||
struct spdk_nvme_qpair *qpair,
|
struct spdk_nvme_qpair *qpair,
|
||||||
|
@ -294,6 +294,12 @@ nvme_qpair_enable(struct spdk_nvme_qpair *qpair)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nvme_complete_request(struct nvme_request *req, struct spdk_nvme_cpl *cpl)
|
||||||
|
{
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
struct spdk_nvme_ctrlr *
|
struct spdk_nvme_ctrlr *
|
||||||
spdk_nvme_get_ctrlr_by_trid_unsafe(const struct spdk_nvme_transport_id *trid)
|
spdk_nvme_get_ctrlr_by_trid_unsafe(const struct spdk_nvme_transport_id *trid)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user