nvmf: Keep a list of poll groups on each target
The plan is to push the logic that assigns qpairs to poll groups down into the nvmf library. To do that, we'll need to have a list of the poll groups. Signed-off-by: Ben Walker <benjamin.walker@intel.com> Change-Id: Iea59ac1a439dbd1bcae68fb2977a47a855884a15 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2811 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Seth Howell <seth.howell@intel.com>
This commit is contained in:
parent
03e3fc4f58
commit
9135a72cf8
@ -160,6 +160,8 @@ struct spdk_nvmf_poll_group {
|
||||
|
||||
spdk_nvmf_poll_group_destroy_done_fn destroy_cb_fn;
|
||||
void *destroy_cb_arg;
|
||||
|
||||
TAILQ_ENTRY(spdk_nvmf_poll_group) link;
|
||||
};
|
||||
|
||||
struct spdk_nvmf_listener {
|
||||
|
@ -142,6 +142,10 @@ nvmf_tgt_create_poll_group(void *io_device, void *ctx_buf)
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&tgt->mutex);
|
||||
TAILQ_INSERT_TAIL(&tgt->poll_groups, group, link);
|
||||
pthread_mutex_unlock(&tgt->mutex);
|
||||
|
||||
group->poller = SPDK_POLLER_REGISTER(nvmf_poll_group_poll, group, 0);
|
||||
group->thread = spdk_get_thread();
|
||||
|
||||
@ -151,11 +155,16 @@ nvmf_tgt_create_poll_group(void *io_device, void *ctx_buf)
|
||||
static void
|
||||
nvmf_tgt_destroy_poll_group(void *io_device, void *ctx_buf)
|
||||
{
|
||||
struct spdk_nvmf_tgt *tgt = io_device;
|
||||
struct spdk_nvmf_poll_group *group = ctx_buf;
|
||||
struct spdk_nvmf_transport_poll_group *tgroup, *tmp;
|
||||
struct spdk_nvmf_subsystem_poll_group *sgroup;
|
||||
uint32_t sid, nsid;
|
||||
|
||||
pthread_mutex_lock(&tgt->mutex);
|
||||
TAILQ_REMOVE(&tgt->poll_groups, group, link);
|
||||
pthread_mutex_unlock(&tgt->mutex);
|
||||
|
||||
TAILQ_FOREACH_SAFE(tgroup, &group->tgroups, link, tmp) {
|
||||
TAILQ_REMOVE(&group->tgroups, tgroup, link);
|
||||
nvmf_transport_poll_group_destroy(tgroup);
|
||||
@ -254,6 +263,7 @@ spdk_nvmf_tgt_create(struct spdk_nvmf_target_opts *opts)
|
||||
|
||||
tgt->discovery_genctr = 0;
|
||||
TAILQ_INIT(&tgt->transports);
|
||||
TAILQ_INIT(&tgt->poll_groups);
|
||||
|
||||
tgt->subsystems = calloc(tgt->max_subsystems, sizeof(struct spdk_nvmf_subsystem *));
|
||||
if (!tgt->subsystems) {
|
||||
@ -261,6 +271,8 @@ spdk_nvmf_tgt_create(struct spdk_nvmf_target_opts *opts)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pthread_mutex_init(&tgt->mutex, NULL);
|
||||
|
||||
TAILQ_INSERT_HEAD(&g_nvmf_tgts, tgt, link);
|
||||
|
||||
spdk_io_device_register(tgt,
|
||||
|
@ -62,6 +62,8 @@ enum spdk_nvmf_subsystem_state {
|
||||
struct spdk_nvmf_tgt {
|
||||
char name[NVMF_TGT_NAME_MAX_LENGTH];
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
uint64_t discovery_genctr;
|
||||
|
||||
uint32_t max_subsystems;
|
||||
@ -70,6 +72,7 @@ struct spdk_nvmf_tgt {
|
||||
struct spdk_nvmf_subsystem **subsystems;
|
||||
|
||||
TAILQ_HEAD(, spdk_nvmf_transport) transports;
|
||||
TAILQ_HEAD(, spdk_nvmf_poll_group) poll_groups;
|
||||
|
||||
spdk_nvmf_tgt_destroy_done_fn *destroy_cb_fn;
|
||||
void *destroy_cb_arg;
|
||||
|
Loading…
Reference in New Issue
Block a user