Skip to content

Commit a04a8c7

Browse files
authored
Merge pull request #556 from igaw/add-unique-disc-ctrl
Add setter and getter to track unique discovery controller
2 parents aa67023 + 4292901 commit a04a8c7

5 files changed

Lines changed: 40 additions & 2 deletions

File tree

src/libnvme.map

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
LIBNVME_1_3 {
44
global:
5-
nvme_io_mgmt_recv;
6-
nvme_io_mgmt_send;
75
nvme_fdp_reclaim_unit_handle_status;
86
nvme_fdp_reclaim_unit_handle_update;
7+
nvme_io_mgmt_recv;
8+
nvme_io_mgmt_send;
9+
nvme_ctrl_is_unique_discovery_ctrl;
10+
nvme_ctrl_set_unique_discovery_ctrl;
911
};
1012

1113
LIBNVME_1_2 {

src/nvme/fabrics.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr)
459459
}
460460
if (!strcmp(nvme_ctrl_get_subsysnqn(c), NVME_DISC_SUBSYS_NAME)) {
461461
nvme_ctrl_set_discovery_ctrl(c, true);
462+
nvme_ctrl_set_unique_discovery_ctrl(c, false);
462463
discovery_nqn = true;
463464
}
464465
if (nvme_ctrl_is_discovery_ctrl(c))
@@ -738,18 +739,23 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,
738739
switch (e->subtype) {
739740
case NVME_NQN_CURR:
740741
nvme_ctrl_set_discovered(c, true);
742+
nvme_ctrl_set_unique_discovery_ctrl(c,
743+
strcmp(e->subnqn, NVME_DISC_SUBSYS_NAME));
741744
break;
742745
case NVME_NQN_DISC:
743746
if (discover)
744747
*discover = true;
745748
nvme_ctrl_set_discovery_ctrl(c, true);
749+
nvme_ctrl_set_unique_discovery_ctrl(c,
750+
strcmp(e->subnqn, NVME_DISC_SUBSYS_NAME));
746751
break;
747752
default:
748753
nvme_msg(h->r, LOG_ERR, "unsupported subtype %d\n",
749754
e->subtype);
750755
fallthrough;
751756
case NVME_NQN_NVME:
752757
nvme_ctrl_set_discovery_ctrl(c, false);
758+
nvme_ctrl_set_unique_discovery_ctrl(c, false);
753759
break;
754760
}
755761

src/nvme/private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct nvme_ctrl {
8585
char *cntrltype;
8686
char *dctype;
8787
bool discovery_ctrl;
88+
bool unique_discovery_ctrl;
8889
bool discovered;
8990
bool persistent;
9091
struct nvme_fabrics_config cfg;

src/nvme/tree.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,16 @@ bool nvme_ctrl_is_discovery_ctrl(nvme_ctrl_t c)
870870
return c->discovery_ctrl;
871871
}
872872

873+
void nvme_ctrl_set_unique_discovery_ctrl(nvme_ctrl_t c, bool unique)
874+
{
875+
c->unique_discovery_ctrl = unique;
876+
}
877+
878+
bool nvme_ctrl_is_unique_discovery_ctrl(nvme_ctrl_t c)
879+
{
880+
return c->unique_discovery_ctrl;
881+
}
882+
873883
int nvme_ctrl_identify(nvme_ctrl_t c, struct nvme_id_ctrl *id)
874884
{
875885
return nvme_identify_ctrl(nvme_ctrl_get_fd(c), id);

src/nvme/tree.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,25 @@ void nvme_ctrl_set_discovery_ctrl(nvme_ctrl_t c, bool discovery);
968968
*/
969969
bool nvme_ctrl_is_discovery_ctrl(nvme_ctrl_t c);
970970

971+
/**
972+
* nvme_ctrl_set_unique_discovery_ctrl() - Set the 'unique_discovery_ctrl' flag
973+
* @c: Controller to be modified
974+
* @unique: value of the unique_disc_ctrl flag
975+
*
976+
* Sets the 'unique_discovery_ctrl' flag in @c to specify wheter
977+
* @c is a unique discovery controller
978+
*
979+
*/
980+
void nvme_ctrl_set_unique_discovery_ctrl(nvme_ctrl_t c, bool unique);
981+
982+
/**
983+
* nvme_ctrl_is_unique_discovery_ctrl() - Check the 'unique_discovery_ctrl' flag
984+
* @c: Controller to be checked
985+
*
986+
* Return: Value of the 'unique_discovery_ctrl' flag
987+
*/
988+
bool nvme_ctrl_is_unique_discovery_ctrl(nvme_ctrl_t c);
989+
971990
/**
972991
* nvme_ctrl_identify() - Issues an 'identify controller' command
973992
* @c: Controller instance

0 commit comments

Comments
 (0)