From df14d53dfecddc03240caf3e1fbf131116224ed3 Mon Sep 17 00:00:00 2001 From: Xiaodong Liu Date: Wed, 22 Nov 2017 22:31:27 -0500 Subject: [PATCH] nbd: add pthread_detach for created thread Using pthead_detach to let system take back the resources owned by SPDK created thread for nbd kernel module. Change-Id: I39f3c0b60ecf57f3227a7b4733a0f144a6e169c5 Signed-off-by: Xiaodong Liu Reviewed-on: https://review.gerrithub.io/388722 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Daniel Verkamp Reviewed-by: Ben Walker Reviewed-by: --- lib/nbd/nbd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/nbd/nbd.c b/lib/nbd/nbd.c index cc96b4b08..a68725daa 100644 --- a/lib/nbd/nbd.c +++ b/lib/nbd/nbd.c @@ -455,6 +455,13 @@ spdk_nbd_start(struct spdk_bdev *bdev, const char *nbd_path) goto err; } + rc = pthread_detach(tid); + if (rc != 0) { + spdk_strerror_r(rc, buf, sizeof(buf)); + SPDK_ERRLOG("could not detach thread for nbd kernel: %s\n", buf); + goto err; + } + fcntl(nbd->spdk_sp_fd, F_SETFL, O_NONBLOCK); to_be32(&nbd->io.resp.magic, NBD_REPLY_MAGIC);