lib/bdev/ocf: fix memory leak of vbdev_ocf_qcxt
Realted to #957 Normally we are using vbdev_ocf_qcxt allocated by spdk device (ctx_buf), but after io_device_destroy_cb this context can be freed, so we allocate a local copy to use for issuing requests on ocf bdev stop. Unfortunately, in current code we are not freeing it, this patch fix that issue. Signed-off-by: Marcin Dziegielewski <marcin.dziegielewski@intel.com> Change-Id: I2d5c0b529f4ff79960945b9e598f21602209f839 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468983 Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
18ed0c7f6b
commit
5817a1cf3f
@ -730,6 +730,9 @@ vbdev_ocf_ctx_queue_stop(ocf_queue_t q)
|
||||
spdk_put_io_channel(qctx->cache_ch);
|
||||
spdk_put_io_channel(qctx->core_ch);
|
||||
spdk_poller_unregister(&qctx->poller);
|
||||
if (qctx->allocated) {
|
||||
free(qctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -779,6 +782,7 @@ io_device_destroy_cb(void *io_device, void *ctx_buf)
|
||||
memcpy(copy, qctx, sizeof(*copy));
|
||||
spdk_poller_unregister(&qctx->poller);
|
||||
copy->poller = spdk_poller_register(queue_poll, copy, 0);
|
||||
copy->allocated = true;
|
||||
} else {
|
||||
SPDK_ERRLOG("Unable to stop OCF queue properly: %s\n",
|
||||
spdk_strerror(ENOMEM));
|
||||
|
@ -55,6 +55,8 @@ struct vbdev_ocf_qcxt {
|
||||
/* Base devices channels */
|
||||
struct spdk_io_channel *cache_ch;
|
||||
struct spdk_io_channel *core_ch;
|
||||
/* If true, we have to free this context on queue stop */
|
||||
bool allocated;
|
||||
/* Link to per-bdev list of queue contexts */
|
||||
TAILQ_ENTRY(vbdev_ocf_qcxt) tailq;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user