Add support for ABORT commands, including issuing these commands when

an I/O times out.

Also ensure that we retry commands that are aborted due to a timeout.

Sponsored by:	Intel
This commit is contained in:
Jim Harris 2013-03-26 18:23:35 +00:00
parent d6f54866ea
commit 448195e764
3 changed files with 24 additions and 5 deletions

View File

@ -281,3 +281,19 @@ nvme_ctrlr_cmd_get_health_information_page(struct nvme_controller *ctrlr,
nvme_ctrlr_submit_admin_request(ctrlr, req);
}
void
nvme_ctrlr_cmd_abort(struct nvme_controller *ctrlr, uint16_t cid,
uint16_t sqid, nvme_cb_fn_t cb_fn, void *cb_arg)
{
struct nvme_request *req;
struct nvme_command *cmd;
req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg);
cmd = &req->cmd;
cmd->opc = NVME_OPC_ABORT;
cmd->cdw10 = (cid << 16) | sqid;
nvme_ctrlr_submit_admin_request(ctrlr, req);
}

View File

@ -348,6 +348,8 @@ void nvme_ctrlr_cmd_set_asynchronous_event_config(struct nvme_controller *ctrlr,
void nvme_ctrlr_cmd_asynchronous_event_request(struct nvme_controller *ctrlr,
nvme_cb_fn_t cb_fn,
void *cb_arg);
void nvme_ctrlr_cmd_abort(struct nvme_controller *ctrlr, uint16_t cid,
uint16_t sqid, nvme_cb_fn_t cb_fn, void *cb_arg);
void nvme_payload_map(void *arg, bus_dma_segment_t *seg, int nseg,
int error);

View File

@ -49,6 +49,8 @@ nvme_completion_check_retry(const struct nvme_completion *cpl)
switch (cpl->sf_sct) {
case NVME_SCT_GENERIC:
switch (cpl->sf_sc) {
case NVME_SC_ABORTED_BY_REQUEST:
return (1);
case NVME_SC_NAMESPACE_NOT_READY:
if (cpl->sf_dnr)
return (0);
@ -60,7 +62,6 @@ nvme_completion_check_retry(const struct nvme_completion *cpl)
case NVME_SC_DATA_TRANSFER_ERROR:
case NVME_SC_ABORTED_POWER_LOSS:
case NVME_SC_INTERNAL_DEVICE_ERROR:
case NVME_SC_ABORTED_BY_REQUEST:
case NVME_SC_ABORTED_SQ_DELETION:
case NVME_SC_ABORTED_FAILED_FUSED:
case NVME_SC_ABORTED_MISSING_FUSED:
@ -378,10 +379,10 @@ nvme_io_qpair_destroy(struct nvme_qpair *qpair)
static void
nvme_timeout(void *arg)
{
/*
* TODO: Add explicit abort operation here, once nvme(4) supports
* abort commands.
*/
struct nvme_tracker *tr = arg;
nvme_ctrlr_cmd_abort(tr->qpair->ctrlr, tr->cid, tr->qpair->id,
NULL, NULL);
}
void