xnvme: Fix memory leak for xnvme dev.
If we use dd or bdevperf to run the xnvme bdev. the destruct function of xnvme misses to free dev while destructing bdev_xnvme. xnvme_dev_close does free dev, and we can put it in bdev_xnvme_free. Meanwhile fixing cleanup for delete_xnvme_bdev. This rpc for delete_xnvme_bdev doesn't really cleanup to remove the bdev from the list and free the names. Fixes issue: #2654 Signed-off-by: yidong0635 <dongx.yi@intel.com> Change-Id: I1c493cb8130b012d891ba8ee90cd0bfb127207d4 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14177 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: GangCao <gang.cao@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
53ec23cae6
commit
43c5293e16
@ -199,6 +199,7 @@ bdev_xnvme_free(struct bdev_xnvme *xnvme)
|
||||
{
|
||||
assert(xnvme != NULL);
|
||||
|
||||
xnvme_dev_close(xnvme->dev);
|
||||
free(xnvme->filename);
|
||||
free(xnvme->bdev.name);
|
||||
free(xnvme);
|
||||
@ -363,13 +364,12 @@ create_xnvme_bdev(const char *name, const char *filename, const char *io_mechani
|
||||
return &xnvme->bdev;
|
||||
|
||||
error_return:
|
||||
xnvme_dev_close(xnvme->dev);
|
||||
|
||||
bdev_xnvme_free(xnvme);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct delete_xnvme_bdev_ctx {
|
||||
struct bdev_xnvme *xnvme;
|
||||
spdk_delete_xnvme_complete cb_fn;
|
||||
void *cb_arg;
|
||||
};
|
||||
@ -379,6 +379,7 @@ xnvme_bdev_unregister_cb(void *arg, int bdeverrno)
|
||||
{
|
||||
struct delete_xnvme_bdev_ctx *ctx = arg;
|
||||
|
||||
bdev_xnvme_destruct(ctx->xnvme);
|
||||
ctx->cb_fn(ctx->cb_arg, bdeverrno);
|
||||
free(ctx);
|
||||
}
|
||||
@ -400,10 +401,10 @@ delete_xnvme_bdev(struct spdk_bdev *bdev, spdk_delete_xnvme_complete cb_fn, void
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->xnvme = xnvme;
|
||||
ctx->cb_fn = cb_fn;
|
||||
ctx->cb_arg = cb_arg;
|
||||
spdk_bdev_unregister(bdev, xnvme_bdev_unregister_cb, ctx);
|
||||
xnvme_dev_close(xnvme->dev);
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user