return error when failing to get resource

(cherry picked from commit e3936886259c3e59da4f3df5375fd0a9dc85ac8c)
This commit is contained in:
Hongtao Zhang 2023-12-14 19:42:59 +08:00 committed by openeuler-sync-bot
parent e52750b27f
commit b03844f899
2 changed files with 109 additions and 1 deletions

View File

@ -0,0 +1,104 @@
From 8afb3d003798965618a8f018bac1644204f4b6e2 Mon Sep 17 00:00:00 2001
From: GangCao <gang.cao@intel.com>
Date: Thu, 29 Sep 2022 03:03:22 -0400
Subject: [PATCH] lib/bdev: return error when failing to get resource
To fix issue: 2719
Change-Id: I983ef607fad154608fff9bb9355645968caf0c5a
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14746
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
---
lib/bdev/bdev.c | 55 +++++++++++++++++++++++++++----------------------
1 file changed, 30 insertions(+), 25 deletions(-)
diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c
index 122f3668a..1642289ff 100644
--- a/lib/bdev/bdev.c
+++ b/lib/bdev/bdev.c
@@ -1382,6 +1382,30 @@ spdk_bdev_subsystem_config_json(struct spdk_json_write_ctx *w)
spdk_json_write_array_end(w);
}
+static void
+bdev_mgmt_channel_destroy(void *io_device, void *ctx_buf)
+{
+ struct spdk_bdev_mgmt_channel *ch = ctx_buf;
+ struct spdk_bdev_io *bdev_io;
+
+ if (!STAILQ_EMPTY(&ch->need_buf_small) || !STAILQ_EMPTY(&ch->need_buf_large)) {
+ SPDK_ERRLOG("Pending I/O list wasn't empty on mgmt channel free\n");
+ }
+
+ if (!TAILQ_EMPTY(&ch->shared_resources)) {
+ SPDK_ERRLOG("Module channel list wasn't empty on mgmt channel free\n");
+ }
+
+ while (!STAILQ_EMPTY(&ch->per_thread_cache)) {
+ bdev_io = STAILQ_FIRST(&ch->per_thread_cache);
+ STAILQ_REMOVE_HEAD(&ch->per_thread_cache, internal.buf_link);
+ ch->per_thread_cache_count--;
+ spdk_mempool_put(g_bdev_mgr.bdev_io_pool, (void *)bdev_io);
+ }
+
+ assert(ch->per_thread_cache_count == 0);
+}
+
static int
bdev_mgmt_channel_create(void *io_device, void *ctx_buf)
{
@@ -1399,7 +1423,12 @@ bdev_mgmt_channel_create(void *io_device, void *ctx_buf)
ch->per_thread_cache_count = 0;
for (i = 0; i < ch->bdev_io_cache_size; i++) {
bdev_io = spdk_mempool_get(g_bdev_mgr.bdev_io_pool);
- assert(bdev_io != NULL);
+ if (bdev_io == NULL) {
+ SPDK_ERRLOG("You need to increase bdev_io_pool_size using bdev_set_options RPC.\n");
+ assert(false);
+ bdev_mgmt_channel_destroy(io_device, ctx_buf);
+ return -1;
+ }
ch->per_thread_cache_count++;
STAILQ_INSERT_HEAD(&ch->per_thread_cache, bdev_io, internal.buf_link);
}
@@ -1410,30 +1439,6 @@ bdev_mgmt_channel_create(void *io_device, void *ctx_buf)
return 0;
}
-static void
-bdev_mgmt_channel_destroy(void *io_device, void *ctx_buf)
-{
- struct spdk_bdev_mgmt_channel *ch = ctx_buf;
- struct spdk_bdev_io *bdev_io;
-
- if (!STAILQ_EMPTY(&ch->need_buf_small) || !STAILQ_EMPTY(&ch->need_buf_large)) {
- SPDK_ERRLOG("Pending I/O list wasn't empty on mgmt channel free\n");
- }
-
- if (!TAILQ_EMPTY(&ch->shared_resources)) {
- SPDK_ERRLOG("Module channel list wasn't empty on mgmt channel free\n");
- }
-
- while (!STAILQ_EMPTY(&ch->per_thread_cache)) {
- bdev_io = STAILQ_FIRST(&ch->per_thread_cache);
- STAILQ_REMOVE_HEAD(&ch->per_thread_cache, internal.buf_link);
- ch->per_thread_cache_count--;
- spdk_mempool_put(g_bdev_mgr.bdev_io_pool, (void *)bdev_io);
- }
-
- assert(ch->per_thread_cache_count == 0);
-}
-
static void
bdev_init_complete(int rc)
{
--
2.23.0

View File

@ -3,7 +3,7 @@
Name: spdk
Version: 21.01.1
Release: 8
Release: 9
Summary: Set of libraries and utilities for high performance user-mode storage
License: BSD and MIT
URL: http://spdk.io
@ -28,6 +28,7 @@ Patch17: 0017-barrier-LOONGARCH-memory-barriers.patch
Patch18: 0018-nvme-pcie-add-memory-barrier-for-LOONGARCH.patch
Patch19: 0019-build-Specify-the-target-build-architecture-for-LOON.patch
Patch20: 0020-configure-add-CONFIG_HAVE_ARC4RANDOM.patch
Patch21: 0021-lib-bdev-return-error-when-failing-to-get-resource.patch
%define package_version %{version}-%{release}
@ -198,6 +199,9 @@ mv doc/output/html/ %{install_docdir}
%changelog
* Thu Dec 14 2023 Hongtao Zhang <zhanghongtao22@huawei.com> - 21.01.1-9
- Return error when failing to get resource
* Tue Dec 12 2023 Hongtao Zhang <zhanghongtao22@huawei.com> - 21.01.1-8
- configure add CONFIG_HAVE_ARC4RANDOM