nvme: make AER callback per-process

For the same reason as commit 31bf5d795e54 ("nvme: make timeout function
per process"), the AER callback also needs to be stored in the
per-process controller data structure.

Change-Id: I41425d81a2ab16c06ef9b900bef6a6128117fcb0
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/410953
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Daniel Verkamp 2018-05-11 14:50:55 -07:00
parent 267318d671
commit 955b295a58
2 changed files with 18 additions and 6 deletions

View File

@ -1136,6 +1136,7 @@ nvme_ctrlr_async_event_cb(void *arg, const struct spdk_nvme_cpl *cpl)
{
struct nvme_async_event_request *aer = arg;
struct spdk_nvme_ctrlr *ctrlr = aer->ctrlr;
struct spdk_nvme_ctrlr_process *active_proc;
if (cpl->status.sc == SPDK_NVME_SC_ABORTED_SQ_DELETION) {
/*
@ -1147,8 +1148,9 @@ nvme_ctrlr_async_event_cb(void *arg, const struct spdk_nvme_cpl *cpl)
return;
}
if (ctrlr->aer_cb_fn != NULL) {
ctrlr->aer_cb_fn(ctrlr->aer_cb_arg, cpl);
active_proc = spdk_nvme_ctrlr_get_current_process(ctrlr);
if (active_proc && active_proc->aer_cb_fn) {
active_proc->aer_cb_fn(active_proc->aer_cb_arg, cpl);
}
/*
@ -1976,8 +1978,17 @@ spdk_nvme_ctrlr_register_aer_callback(struct spdk_nvme_ctrlr *ctrlr,
spdk_nvme_aer_cb aer_cb_fn,
void *aer_cb_arg)
{
ctrlr->aer_cb_fn = aer_cb_fn;
ctrlr->aer_cb_arg = aer_cb_arg;
struct spdk_nvme_ctrlr_process *active_proc;
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
active_proc = spdk_nvme_ctrlr_get_current_process(ctrlr);
if (active_proc) {
active_proc->aer_cb_fn = aer_cb_fn;
active_proc->aer_cb_arg = aer_cb_arg;
}
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
}
void

View File

@ -375,6 +375,9 @@ struct spdk_nvme_ctrlr_process {
/** Allocated IO qpairs */
TAILQ_HEAD(, spdk_nvme_qpair) allocated_io_qpairs;
spdk_nvme_aer_cb aer_cb_fn;
void *aer_cb_arg;
/**
* A function pointer to timeout callback function
*/
@ -437,8 +440,6 @@ struct spdk_nvme_ctrlr {
uint32_t num_aers;
struct nvme_async_event_request aer[NVME_MAX_ASYNC_EVENTS];
spdk_nvme_aer_cb aer_cb_fn;
void *aer_cb_arg;
/** guards access to the controller itself, including admin queues */
pthread_mutex_t ctrlr_lock;