nvme: free completed aers on shutdown

If there are completed asynchronous events that have not been notified
to the user, free them during controller shutdown to avoid memory leaks.
It can happen if an event completes before user has a chance to execute
`spdk_nvme_ctrlr_process_admin_completions()`.

Fixes #2032.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ie608bf9100342f8dfd709e070326f67335d27fed
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8740
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: GangCao <gang.cao@intel.com>
Reviewed-by: <dongx.yi@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Konrad Sztyber 2021-07-12 12:15:12 +02:00 committed by Tomasz Zawadzki
parent d2d1899b90
commit 970e2e2e18

View File

@ -3542,6 +3542,7 @@ nvme_ctrlr_destruct_async(struct spdk_nvme_ctrlr *ctrlr,
struct nvme_ctrlr_detach_ctx *ctx)
{
struct spdk_nvme_qpair *qpair, *tmp;
struct spdk_nvme_ctrlr_aer_completion_list *event;
NVME_CTRLR_DEBUGLOG(ctrlr, "Prepare to destruct SSD\n");
@ -3552,6 +3553,12 @@ nvme_ctrlr_destruct_async(struct spdk_nvme_ctrlr *ctrlr,
nvme_ctrlr_abort_queued_aborts(ctrlr);
nvme_transport_admin_qpair_abort_aers(ctrlr->adminq);
while (!STAILQ_EMPTY(&ctrlr->async_events)) {
event = STAILQ_FIRST(&ctrlr->async_events);
STAILQ_REMOVE_HEAD(&ctrlr->async_events, link);
free(event);
}
TAILQ_FOREACH_SAFE(qpair, &ctrlr->active_io_qpairs, tailq, tmp) {
spdk_nvme_ctrlr_free_io_qpair(qpair);
}