From 70ba1ba7cc110d33c97fd0fed360f308cd6aa565 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 29 Aug 2016 14:06:00 -0700 Subject: [PATCH] bdev: clean up child I/O in bdev core When an I/O with children is being freed, also free its child I/O requests that were allocated via spdk_bdev_get_child_io(). Change-Id: I2d44aed845c1035ae8f8cb07c5992da855f1dc99 Signed-off-by: Daniel Verkamp --- lib/bdev/bdev.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index a2b1a04c2..e03565ac5 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -418,6 +418,24 @@ __submit_request(spdk_event_t event) } bdev->fn_table->submit_request(bdev_io); } else { + struct spdk_bdev_io *child_io, *tmp; + + TAILQ_FOREACH_SAFE(child_io, &bdev_io->child_io, link, tmp) { + /* + * Make sure no references to the parent I/O remain, since it is being + * returned to the free pool. + */ + child_io->parent = NULL; + TAILQ_REMOVE(&bdev_io->child_io, child_io, link); + + /* + * Child I/O may have an rbuf that needs to be returned to a pool + * on a different core, so free it through the request submission + * process rather than calling put_io directly here. + */ + spdk_bdev_free_io(child_io); + } + spdk_bdev_put_io(bdev_io); } }