From f45c98dd298e71dd89a12dda8993fd07c07fa1e6 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Wed, 2 Mar 2022 02:55:10 +0000 Subject: [PATCH] blobcli: use spdk_thread_send_msg when dumping blob For thin provisioned blobs, an IO read to an unallocated cluster completes inline, meaning that if the read completion function issues another read, we can quickly blow the stack. So use spdk_thread_send_msg() to issue the next read operation. Fixes #2405. Signed-off-by: Jim Harris Change-Id: I10a40b83bfc25fa6bbd8bc93b6fea36ac8ee83c6 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11784 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Dong Yi Reviewed-by: Tomasz Zawadzki --- examples/blob/cli/blobcli.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/blob/cli/blobcli.c b/examples/blob/cli/blobcli.c index 3f6553044..d326c87a3 100644 --- a/examples/blob/cli/blobcli.c +++ b/examples/blob/cli/blobcli.c @@ -578,6 +578,8 @@ set_xattr_cb(void *cb_arg, struct spdk_blob *blob, int bserrno) spdk_blob_sync_md(cli_context->blob, sync_cb, cli_context); } +static void __read_dump_cb(void *arg1); + /* * Callback function for reading a blob for dumping to a file. */ @@ -603,6 +605,19 @@ read_dump_cb(void *arg1, int bserrno) return; } + /* This completion may have occurred in the context of a read to + * an unallocated cluster. So we can't issue the next read here, or + * we risk overflowing the stack. So use spdk_thread_send_msg() to + * make sure we unwind before doing the next read. + */ + spdk_thread_send_msg(spdk_get_thread(), __read_dump_cb, cli_context); +} + +static void +__read_dump_cb(void *arg1) +{ + struct cli_context_t *cli_context = arg1; + printf("."); if (++cli_context->io_unit_count < cli_context->blob_io_units) { /* perform another read */