bdev: allocate accel_channel for each bdev_channel

This channel will be used to execute accel operation sequences.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ied4bb57d14a50a923908ffb13ef4ba34ca65175c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16972
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
Konrad Sztyber 2023-02-14 12:19:54 +01:00 committed by Ben Walker
parent dc4cb8bf83
commit 80b22cf314
5 changed files with 100 additions and 7 deletions

View File

@ -8,6 +8,7 @@
#include "spdk/bdev.h" #include "spdk/bdev.h"
#include "spdk/accel.h"
#include "spdk/config.h" #include "spdk/config.h"
#include "spdk/env.h" #include "spdk/env.h"
#include "spdk/thread.h" #include "spdk/thread.h"
@ -263,6 +264,9 @@ struct spdk_bdev_channel {
/* The channel for the underlying device */ /* The channel for the underlying device */
struct spdk_io_channel *channel; struct spdk_io_channel *channel;
/* Accel channel */
struct spdk_io_channel *accel_channel;
/* Per io_device per thread data */ /* Per io_device per thread data */
struct spdk_bdev_shared_resource *shared_resource; struct spdk_bdev_shared_resource *shared_resource;
@ -3277,6 +3281,7 @@ bdev_channel_destroy_resource(struct spdk_bdev_channel *ch)
} }
spdk_put_io_channel(ch->channel); spdk_put_io_channel(ch->channel);
spdk_put_io_channel(ch->accel_channel);
shared_resource = ch->shared_resource; shared_resource = ch->shared_resource;
@ -3494,6 +3499,12 @@ bdev_channel_create(void *io_device, void *ctx_buf)
return -1; return -1;
} }
ch->accel_channel = spdk_accel_get_io_channel();
if (!ch->accel_channel) {
spdk_put_io_channel(ch->channel);
return -1;
}
spdk_trace_record(TRACE_BDEV_IOCH_CREATE, 0, 0, 0, ch->bdev->name, spdk_trace_record(TRACE_BDEV_IOCH_CREATE, 0, 0, 0, ch->bdev->name,
spdk_thread_get_id(spdk_io_channel_get_thread(ch->channel))); spdk_thread_get_id(spdk_io_channel_get_thread(ch->channel)));
@ -3508,6 +3519,7 @@ bdev_channel_create(void *io_device, void *ctx_buf)
mgmt_io_ch = spdk_get_io_channel(&g_bdev_mgr); mgmt_io_ch = spdk_get_io_channel(&g_bdev_mgr);
if (!mgmt_io_ch) { if (!mgmt_io_ch) {
spdk_put_io_channel(ch->channel); spdk_put_io_channel(ch->channel);
spdk_put_io_channel(ch->accel_channel);
return -1; return -1;
} }
@ -3524,6 +3536,7 @@ bdev_channel_create(void *io_device, void *ctx_buf)
shared_resource = calloc(1, sizeof(*shared_resource)); shared_resource = calloc(1, sizeof(*shared_resource));
if (shared_resource == NULL) { if (shared_resource == NULL) {
spdk_put_io_channel(ch->channel); spdk_put_io_channel(ch->channel);
spdk_put_io_channel(ch->accel_channel);
spdk_put_io_channel(mgmt_io_ch); spdk_put_io_channel(mgmt_io_ch);
return -1; return -1;
} }

View File

@ -59,7 +59,7 @@ DEPDIRS-net := log util $(JSON_LIBS)
DEPDIRS-notify := log util $(JSON_LIBS) DEPDIRS-notify := log util $(JSON_LIBS)
DEPDIRS-trace := log util $(JSON_LIBS) DEPDIRS-trace := log util $(JSON_LIBS)
DEPDIRS-bdev := log util thread $(JSON_LIBS) notify trace dma DEPDIRS-bdev := accel log util thread $(JSON_LIBS) notify trace dma
DEPDIRS-blobfs := log thread blob trace util DEPDIRS-blobfs := log thread blob trace util
DEPDIRS-event := log util thread $(JSON_LIBS) trace init DEPDIRS-event := log util thread $(JSON_LIBS) trace init
DEPDIRS-init := jsonrpc json log rpc thread util DEPDIRS-init := jsonrpc json log rpc thread util

View File

@ -24,6 +24,7 @@ DEFINE_STUB(spdk_memory_domain_get_dma_device_type, enum spdk_dma_device_type,
static bool g_memory_domain_pull_data_called; static bool g_memory_domain_pull_data_called;
static bool g_memory_domain_push_data_called; static bool g_memory_domain_push_data_called;
static int g_accel_io_device;
DEFINE_RETURN_MOCK(spdk_memory_domain_pull_data, int); DEFINE_RETURN_MOCK(spdk_memory_domain_pull_data, int);
int int
@ -49,6 +50,12 @@ spdk_memory_domain_push_data(struct spdk_memory_domain *dst_domain, void *dst_do
return 0; return 0;
} }
struct spdk_io_channel *
spdk_accel_get_io_channel(void)
{
return spdk_get_io_channel(&g_accel_io_device);
}
int g_status; int g_status;
int g_count; int g_count;
enum spdk_bdev_event_type g_event_type1; enum spdk_bdev_event_type g_event_type1;
@ -66,14 +73,29 @@ spdk_scsi_nvme_translate(const struct spdk_bdev_io *bdev_io,
} }
static int static int
null_init(void) ut_accel_ch_create_cb(void *io_device, void *ctx)
{ {
return 0; return 0;
} }
static int static void
null_clean(void) ut_accel_ch_destroy_cb(void *io_device, void *ctx)
{ {
}
static int
ut_bdev_setup(void)
{
spdk_io_device_register(&g_accel_io_device, ut_accel_ch_create_cb,
ut_accel_ch_destroy_cb, 0, NULL);
return 0;
}
static int
ut_bdev_teardown(void)
{
spdk_io_device_unregister(&g_accel_io_device, NULL);
return 0; return 0;
} }
@ -7012,7 +7034,7 @@ main(int argc, char **argv)
CU_set_error_action(CUEA_ABORT); CU_set_error_action(CUEA_ABORT);
CU_initialize_registry(); CU_initialize_registry();
suite = CU_add_suite("bdev", null_init, null_clean); suite = CU_add_suite("bdev", ut_bdev_setup, ut_bdev_teardown);
CU_ADD_TEST(suite, bytes_to_blocks_test); CU_ADD_TEST(suite, bytes_to_blocks_test);
CU_ADD_TEST(suite, num_blocks_test); CU_ADD_TEST(suite, num_blocks_test);

View File

@ -50,6 +50,14 @@ spdk_memory_domain_push_data(struct spdk_memory_domain *dst_domain, void *dst_do
return 0; return 0;
} }
static int g_accel_io_device;
struct spdk_io_channel *
spdk_accel_get_io_channel(void)
{
return spdk_get_io_channel(&g_accel_io_device);
}
struct ut_bdev { struct ut_bdev {
struct spdk_bdev bdev; struct spdk_bdev bdev;
void *io_target; void *io_target;
@ -73,6 +81,17 @@ int g_status = 0;
int g_count = 0; int g_count = 0;
struct spdk_histogram_data *g_histogram = NULL; struct spdk_histogram_data *g_histogram = NULL;
static int
ut_accel_ch_create_cb(void *io_device, void *ctx)
{
return 0;
}
static void
ut_accel_ch_destroy_cb(void *io_device, void *ctx)
{
}
static int static int
stub_create_ch(void *io_device, void *ctx_buf) stub_create_ch(void *io_device, void *ctx_buf)
{ {
@ -300,6 +319,8 @@ setup_test(void)
spdk_bdev_initialize(bdev_init_cb, &done); spdk_bdev_initialize(bdev_init_cb, &done);
spdk_io_device_register(&g_io_device, stub_create_ch, stub_destroy_ch, spdk_io_device_register(&g_io_device, stub_create_ch, stub_destroy_ch,
sizeof(struct ut_bdev_channel), NULL); sizeof(struct ut_bdev_channel), NULL);
spdk_io_device_register(&g_accel_io_device, ut_accel_ch_create_cb,
ut_accel_ch_destroy_cb, 0, NULL);
register_bdev(&g_bdev, "ut_bdev", &g_io_device); register_bdev(&g_bdev, "ut_bdev", &g_io_device);
spdk_bdev_open_ext("ut_bdev", true, _bdev_event_cb, NULL, &g_desc); spdk_bdev_open_ext("ut_bdev", true, _bdev_event_cb, NULL, &g_desc);
} }
@ -320,6 +341,7 @@ teardown_test(void)
unregister_bdev(&g_bdev); unregister_bdev(&g_bdev);
spdk_io_device_unregister(&g_io_device, NULL); spdk_io_device_unregister(&g_io_device, NULL);
spdk_bdev_finish(finish_cb, NULL); spdk_bdev_finish(finish_cb, NULL);
spdk_io_device_unregister(&g_accel_io_device, NULL);
spdk_iobuf_finish(finish_cb, NULL); spdk_iobuf_finish(finish_cb, NULL);
poll_threads(); poll_threads();
memset(&g_bdev, 0, sizeof(g_bdev)); memset(&g_bdev, 0, sizeof(g_bdev));
@ -2353,7 +2375,6 @@ bdev_init_wt_cb(void *done, int rc)
{ {
} }
static int static int
wrong_thread_setup(void) wrong_thread_setup(void)
{ {
@ -2361,6 +2382,8 @@ wrong_thread_setup(void)
allocate_threads(2); allocate_threads(2);
set_thread(0); set_thread(0);
spdk_io_device_register(&g_accel_io_device, ut_accel_ch_create_cb,
ut_accel_ch_destroy_cb, 0, NULL);
spdk_bdev_initialize(bdev_init_wt_cb, NULL); spdk_bdev_initialize(bdev_init_wt_cb, NULL);
spdk_io_device_register(&g_io_device, stub_create_ch, stub_destroy_ch, spdk_io_device_register(&g_io_device, stub_create_ch, stub_destroy_ch,
sizeof(struct ut_bdev_channel), NULL); sizeof(struct ut_bdev_channel), NULL);
@ -2388,6 +2411,7 @@ wrong_thread_teardown(void)
} }
g_teardown_done = false; g_teardown_done = false;
spdk_io_device_unregister(&g_accel_io_device, NULL);
free_threads(); free_threads();
free_cores(); free_cores();

View File

@ -26,6 +26,7 @@ struct bdev_ut_channel {
static uint32_t g_part_ut_io_device; static uint32_t g_part_ut_io_device;
static struct bdev_ut_channel *g_bdev_ut_channel; static struct bdev_ut_channel *g_bdev_ut_channel;
static int g_accel_io_device;
DEFINE_STUB(spdk_notify_send, uint64_t, (const char *type, const char *ctx), 0); DEFINE_STUB(spdk_notify_send, uint64_t, (const char *type, const char *ctx), 0);
DEFINE_STUB(spdk_notify_type_register, struct spdk_notify_type *, (const char *type), NULL); DEFINE_STUB(spdk_notify_type_register, struct spdk_notify_type *, (const char *type), NULL);
@ -58,6 +59,39 @@ spdk_memory_domain_push_data(struct spdk_memory_domain *dst_domain, void *dst_do
return 0; return 0;
} }
struct spdk_io_channel *
spdk_accel_get_io_channel(void)
{
return spdk_get_io_channel(&g_accel_io_device);
}
static int
ut_accel_ch_create_cb(void *io_device, void *ctx)
{
return 0;
}
static void
ut_accel_ch_destroy_cb(void *io_device, void *ctx)
{
}
static int
ut_part_setup(void)
{
spdk_io_device_register(&g_accel_io_device, ut_accel_ch_create_cb,
ut_accel_ch_destroy_cb, 0, NULL);
return 0;
}
static int
ut_part_teardown(void)
{
spdk_io_device_unregister(&g_accel_io_device, NULL);
return 0;
}
static void static void
_part_cleanup(struct spdk_bdev_part *part) _part_cleanup(struct spdk_bdev_part *part)
{ {
@ -358,7 +392,7 @@ main(int argc, char **argv)
CU_set_error_action(CUEA_ABORT); CU_set_error_action(CUEA_ABORT);
CU_initialize_registry(); CU_initialize_registry();
suite = CU_add_suite("bdev_part", NULL, NULL); suite = CU_add_suite("bdev_part", ut_part_setup, ut_part_teardown);
CU_ADD_TEST(suite, part_test); CU_ADD_TEST(suite, part_test);
CU_ADD_TEST(suite, part_free_test); CU_ADD_TEST(suite, part_free_test);