Commit 5817a1cf authored by Marcin Dziegielewski's avatar Marcin Dziegielewski Committed by Ben Walker
Browse files

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: default avatarMarcin Dziegielewski <marcin.dziegielewski@intel.com>
Change-Id: I2d5c0b529f4ff79960945b9e598f21602209f839
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468983


Reviewed-by: default avatarVitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 18ed0c7f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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));
+2 −0
Original line number Diff line number Diff line
@@ -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;
};