Skip to content

Commit f68416e

Browse files
committed
libnvme: drop nvme_subsystem accessors from tree.c
The accessor functions already have implementations for the various nvme subsystem accessors, so drop them from tree.c Signed-off-by: Hannes Reinecke <[email protected]>
1 parent f33fec3 commit f68416e

13 files changed

Lines changed: 43 additions & 144 deletions

File tree

fabrics.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ static void nvmf_disconnect_nqn(struct nvme_global_ctx *ctx, char *nqn)
716716
continue;
717717
nvme_for_each_host(ctx, h) {
718718
nvme_for_each_subsystem(h, s) {
719-
if (strcmp(nvme_subsystem_get_nqn(s), p))
719+
if (strcmp(nvme_subsystem_get_subsysnqn(s), p))
720720
continue;
721721
nvme_subsystem_for_each_ctrl(s, c) {
722722
if (!nvme_disconnect_ctrl(c))
@@ -1062,7 +1062,7 @@ int fabrics_dim(const char *desc, int argc, char **argv)
10621062
continue;
10631063
nvme_for_each_host(ctx, h) {
10641064
nvme_for_each_subsystem(h, s) {
1065-
if (strcmp(nvme_subsystem_get_nqn(s), p))
1065+
if (strcmp(nvme_subsystem_get_subsysnqn(s), p))
10661066
continue;
10671067
nvme_subsystem_for_each_ctrl(s, c)
10681068
ret = dim_operation(c, tas, p);

libnvme/examples/display-columnar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int main()
4242
nvme_for_each_subsystem(h, s) {
4343
bool first = true;
4444
printf("%-16s %-96s ", nvme_subsystem_get_name(s),
45-
nvme_subsystem_get_nqn(s));
45+
nvme_subsystem_get_subsysnqn(s));
4646

4747
nvme_subsystem_for_each_ctrl(s, c) {
4848
printf("%s%s", first ? "": ", ",

libnvme/examples/display-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int main()
3939
nvme_for_each_subsystem_safe(h, s, _s) {
4040
printf("%c-- %s - NQN=%s\n", _s ? '|' : '`',
4141
nvme_subsystem_get_name(s),
42-
nvme_subsystem_get_nqn(s));
42+
nvme_subsystem_get_subsysnqn(s));
4343

4444
nvme_subsystem_for_each_ns_safe(s, n, _n) {
4545
printf("%c |-- %s lba size:%d lba max:%" PRIu64 "\n",

libnvme/libnvme/nvme.i

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ struct nvme_ns {
897897
}
898898

899899
bool nvme_ctrl_persistent_get(struct nvme_ctrl *c) {
900-
return nvme_ctrl_is_persistent(c);
900+
return nvme_ctrl_get_persistent(c);
901901
}
902902
void nvme_ctrl_persistent_set(struct nvme_ctrl *c, bool persistent) {
903903
nvme_ctrl_set_persistent(c, persistent);
@@ -956,14 +956,14 @@ struct nvme_ns {
956956
}
957957

958958
bool nvme_ctrl_discovery_ctrl_get(struct nvme_ctrl *c) {
959-
return nvme_ctrl_is_discovery_ctrl(c);
959+
return nvme_ctrl_get_discovery_ctrl(c);
960960
}
961961
void nvme_ctrl_discovery_ctrl_set(struct nvme_ctrl *c, bool discovery) {
962962
nvme_ctrl_set_discovery_ctrl(c, discovery);
963963
}
964964

965965
bool nvme_ctrl_unique_discovery_ctrl_get(nvme_ctrl_t c) {
966-
return nvme_ctrl_is_unique_discovery_ctrl(c);
966+
return nvme_ctrl_get_unique_discovery_ctrl(c);
967967
}
968968
void nvme_ctrl_unique_discovery_ctrl_set(nvme_ctrl_t c, bool unique) {
969969
nvme_ctrl_set_unique_discovery_ctrl(c, unique);

libnvme/src/libnvme.ld

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ LIBNVME_3 {
1717
nvme_ctrl_get_subsystem;
1818
nvme_ctrl_get_transport_handle;
1919
nvme_ctrl_identify;
20-
nvme_ctrl_is_discovery_ctrl;
21-
nvme_ctrl_is_persistent;
22-
nvme_ctrl_is_unique_discovery_ctrl;
2320
nvme_ctrl_next_ns;
2421
nvme_ctrl_next_path;
2522
nvme_ctrl_release_transport_handle;
@@ -187,10 +184,7 @@ LIBNVME_3 {
187184
nvme_subsystem_first_ctrl;
188185
nvme_subsystem_first_ns;
189186
nvme_get_subsystem;
190-
nvme_subsystem_get_fw_rev;
191187
nvme_subsystem_get_host;
192-
nvme_subsystem_get_nqn;
193-
nvme_subsystem_get_type;
194188
nvme_subsystem_lookup_namespace;
195189
nvme_subsystem_next_ctrl;
196190
nvme_subsystem_next_ns;

libnvme/src/nvme/fabrics.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr)
703703
discovery_nqn = true;
704704
}
705705

706-
if (nvme_ctrl_is_discovery_ctrl(c))
706+
if (nvme_ctrl_get_discovery_ctrl(c))
707707
discover = true;
708708

709709
hostnqn = nvme_host_get_hostnqn(h);
@@ -1040,7 +1040,7 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,
10401040
root_app = nvme_get_application(h->ctx);
10411041
if (root_app) {
10421042
app = nvme_subsystem_get_application(s);
1043-
if (!app && nvme_ctrl_is_discovery_ctrl(c))
1043+
if (!app && nvme_ctrl_get_discovery_ctrl(c))
10441044
app = lookup_context(h->ctx, c);
10451045

10461046
/*
@@ -1051,7 +1051,7 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,
10511051
*/
10521052
if (app && strcmp(app, root_app)) {
10531053
nvme_msg(h->ctx, LOG_INFO, "skip %s, not managed by %s\n",
1054-
nvme_subsystem_get_nqn(s), root_app);
1054+
nvme_subsystem_get_subsysnqn(s), root_app);
10551055
return -ENVME_CONNECT_IGNORED;
10561056
}
10571057
}
@@ -1182,7 +1182,7 @@ static int nvmf_connect_disc_entry(nvme_host_t h,
11821182
break;
11831183
}
11841184

1185-
if (nvme_ctrl_is_discovered(c)) {
1185+
if (nvme_ctrl_get_discovered(c)) {
11861186
nvme_free_ctrl(c);
11871187
return -EAGAIN;
11881188
}
@@ -2050,7 +2050,7 @@ const char *nvmf_get_default_trsvcid(const char *transport,
20502050
static bool is_persistent_discovery_ctrl(nvme_host_t h, nvme_ctrl_t c)
20512051
{
20522052
if (nvme_host_is_pdc_enabled(h, DEFAULT_PDC_ENABLED))
2053-
return nvme_ctrl_is_unique_discovery_ctrl(c);
2053+
return nvme_ctrl_get_unique_discovery_ctrl(c);
20542054

20552055
return false;
20562056
}
@@ -2090,7 +2090,7 @@ static int __create_discovery_ctrl(struct nvme_global_ctx *ctx,
20902090
strcmp(trcfg->subsysnqn, NVME_DISC_SUBSYS_NAME));
20912091
tmo = set_discovery_kato(fctx, cfg);
20922092

2093-
if (nvme_ctrl_is_unique_discovery_ctrl(c) && fctx->hostkey) {
2093+
if (nvme_ctrl_get_unique_discovery_ctrl(c) && fctx->hostkey) {
20942094
nvme_ctrl_set_dhchap_host_key(c, fctx->hostkey);
20952095
if (fctx->ctrlkey)
20962096
nvme_ctrl_set_dhchap_ctrl_key(c, fctx->ctrlkey);
@@ -2121,7 +2121,7 @@ static int nvmf_create_discovery_ctrl(struct nvme_global_ctx *ctx,
21212121
if (ret)
21222122
return ret;
21232123

2124-
if (nvme_ctrl_is_unique_discovery_ctrl(c)) {
2124+
if (nvme_ctrl_get_unique_discovery_ctrl(c)) {
21252125
*ctrl = c;
21262126
return 0;
21272127
}
@@ -2220,7 +2220,7 @@ int _discovery_config_json(struct nvme_global_ctx *ctx,
22202220
else
22212221
subsysnqn = NVME_DISC_SUBSYS_NAME;
22222222

2223-
if (nvme_ctrl_is_persistent(c))
2223+
if (nvme_ctrl_get_persistent(c))
22242224
fctx->persistent = true;
22252225

22262226
memcpy(&cfg, fctx->cfg, sizeof(cfg));
@@ -2971,7 +2971,7 @@ int nvmf_discovery(struct nvme_global_ctx *ctx, struct nvmf_context *fctx,
29712971
fctx->device);
29722972
}
29732973

2974-
if (!nvme_ctrl_is_discovery_ctrl(c)) {
2974+
if (!nvme_ctrl_get_discovery_ctrl(c)) {
29752975
nvme_msg(
29762976
ctx, LOG_ERR,
29772977
"ctrl device %s found, ignoring non discovery controller\n",

libnvme/src/nvme/json.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ static void json_update_attributes(nvme_ctrl_t c,
6060
JSON_UPDATE_BOOL_OPTION(cfg, key_str,
6161
concat, val_obj);
6262
if (!strcmp("persistent", key_str) &&
63-
!nvme_ctrl_is_persistent(c))
63+
!nvme_ctrl_get_persistent(c))
6464
nvme_ctrl_set_persistent(c, true);
6565
if (!strcmp("discovery", key_str) &&
66-
!nvme_ctrl_is_discovery_ctrl(c))
66+
!nvme_ctrl_get_discovery_ctrl(c))
6767
nvme_ctrl_set_discovery_ctrl(c, true);
6868
if (!strcmp("keyring", key_str))
6969
nvme_ctrl_set_keyring(c,
@@ -342,10 +342,10 @@ static void json_update_port(struct json_object *ctrl_array, nvme_ctrl_t c)
342342
JSON_BOOL_OPTION(cfg, port_obj, hdr_digest);
343343
JSON_BOOL_OPTION(cfg, port_obj, data_digest);
344344
JSON_BOOL_OPTION(cfg, port_obj, concat);
345-
if (nvme_ctrl_is_persistent(c))
345+
if (nvme_ctrl_get_persistent(c))
346346
json_object_object_add(port_obj, "persistent",
347347
json_object_new_boolean(true));
348-
if (nvme_ctrl_is_discovery_ctrl(c))
348+
if (nvme_ctrl_get_discovery_ctrl(c))
349349
json_object_object_add(port_obj, "discovery",
350350
json_object_new_boolean(true));
351351

@@ -356,7 +356,7 @@ static void json_update_subsys(struct json_object *subsys_array,
356356
nvme_subsystem_t s)
357357
{
358358
nvme_ctrl_t c;
359-
const char *subsysnqn = nvme_subsystem_get_nqn(s), *app;
359+
const char *subsysnqn = nvme_subsystem_get_subsysnqn(s), *app;
360360
struct json_object *subsys_obj = json_object_new_object();
361361
struct json_object *port_array;
362362

@@ -512,10 +512,10 @@ static void json_dump_ctrl(struct json_object *ctrl_array, nvme_ctrl_t c)
512512
json_object_new_string(value));
513513
}
514514
JSON_BOOL_OPTION(cfg, ctrl_obj, concat);
515-
if (nvme_ctrl_is_persistent(c))
515+
if (nvme_ctrl_get_persistent(c))
516516
json_object_object_add(ctrl_obj, "persistent",
517517
json_object_new_boolean(true));
518-
if (nvme_ctrl_is_discovery_ctrl(c))
518+
if (nvme_ctrl_get_discovery_ctrl(c))
519519
json_object_object_add(ctrl_obj, "discovery",
520520
json_object_new_boolean(true));
521521
json_object_array_add(ctrl_array, ctrl_obj);
@@ -602,7 +602,7 @@ static void json_dump_subsys(struct json_object *subsys_array,
602602
json_object_object_add(subsys_obj, "name",
603603
json_object_new_string(nvme_subsystem_get_name(s)));
604604
json_object_object_add(subsys_obj, "nqn",
605-
json_object_new_string(nvme_subsystem_get_nqn(s)));
605+
json_object_new_string(nvme_subsystem_get_subsysnqn(s)));
606606

607607
ns_array = json_object_new_array();
608608
if (!json_dump_subsys_multipath(s, ns_array))

libnvme/src/nvme/tree.c

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -429,21 +429,6 @@ void nvme_root_release_fds(struct nvme_global_ctx *ctx)
429429
nvme_host_release_fds(h);
430430
}
431431

432-
const char *nvme_subsystem_get_nqn(nvme_subsystem_t s)
433-
{
434-
return s->subsysnqn;
435-
}
436-
437-
const char *nvme_subsystem_get_type(nvme_subsystem_t s)
438-
{
439-
return s->subsystype;
440-
}
441-
442-
const char *nvme_subsystem_get_fw_rev(nvme_subsystem_t s)
443-
{
444-
return s->firmware;
445-
}
446-
447432
nvme_ctrl_t nvme_subsystem_first_ctrl(nvme_subsystem_t s)
448433
{
449434
return list_top(&s->ctrls, struct nvme_ctrl, entry);
@@ -955,26 +940,6 @@ struct nvme_fabrics_config *nvme_ctrl_get_config(nvme_ctrl_t c)
955940
return &c->cfg;
956941
}
957942

958-
bool nvme_ctrl_is_discovered(nvme_ctrl_t c)
959-
{
960-
return c->discovered;
961-
}
962-
963-
bool nvme_ctrl_is_persistent(nvme_ctrl_t c)
964-
{
965-
return c->persistent;
966-
}
967-
968-
bool nvme_ctrl_is_discovery_ctrl(nvme_ctrl_t c)
969-
{
970-
return c->discovery_ctrl;
971-
}
972-
973-
bool nvme_ctrl_is_unique_discovery_ctrl(nvme_ctrl_t c)
974-
{
975-
return c->unique_discovery_ctrl;
976-
}
977-
978943
int nvme_ctrl_identify(nvme_ctrl_t c, struct nvme_id_ctrl *id)
979944
{
980945
struct nvme_transport_handle *hdl = nvme_ctrl_get_transport_handle(c);
@@ -1363,7 +1328,7 @@ static bool _tcp_match_ctrl(struct nvme_ctrl *c, struct candidate_args *candidat
13631328
if (!candidate->addreq(c->traddr, candidate->traddr))
13641329
return false;
13651330

1366-
if (candidate->well_known_nqn && !nvme_ctrl_is_discovery_ctrl(c))
1331+
if (candidate->well_known_nqn && !nvme_ctrl_get_discovery_ctrl(c))
13671332
return false;
13681333

13691334
if (candidate->subsysnqn && !streq0(c->subsysnqn, candidate->subsysnqn))
@@ -1409,7 +1374,7 @@ static bool _match_ctrl(struct nvme_ctrl *c, struct candidate_args *candidate)
14091374
!streq0(c->trsvcid, candidate->trsvcid))
14101375
return false;
14111376

1412-
if (candidate->well_known_nqn && !nvme_ctrl_is_discovery_ctrl(c))
1377+
if (candidate->well_known_nqn && !nvme_ctrl_get_discovery_ctrl(c))
14131378
return false;
14141379

14151380
if (candidate->subsysnqn && !streq0(c->subsysnqn, candidate->subsysnqn))

libnvme/src/nvme/tree.h

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -775,41 +775,6 @@ const char *nvme_ns_head_get_sysfs_dir(nvme_ns_head_t head);
775775
*/
776776
struct nvme_fabrics_config *nvme_ctrl_get_config(nvme_ctrl_t c);
777777

778-
/**
779-
* nvme_ctrl_is_discovered() - Returns the value of the 'discovered' flag
780-
* @c: Controller instance
781-
*
782-
* Return: Value of the 'discovered' flag of @c
783-
*/
784-
bool nvme_ctrl_is_discovered(nvme_ctrl_t c);
785-
786-
/**
787-
* nvme_ctrl_is_persistent() - Returns the value of the 'persistent' flag
788-
* @c: Controller instance
789-
*
790-
* Return: Value of the 'persistent' flag of @c
791-
*/
792-
bool nvme_ctrl_is_persistent(nvme_ctrl_t c);
793-
794-
/**
795-
* nvme_ctrl_is_discovery_ctrl() - Check the 'discovery_ctrl' flag
796-
* @c: Controller to be checked
797-
*
798-
* Returns the value of the 'discovery_ctrl' flag which specifies whether
799-
* @c connects to a discovery subsystem.
800-
*
801-
* Return: Value of the 'discover_ctrl' flag
802-
*/
803-
bool nvme_ctrl_is_discovery_ctrl(nvme_ctrl_t c);
804-
805-
/**
806-
* nvme_ctrl_is_unique_discovery_ctrl() - Check the 'unique_discovery_ctrl' flag
807-
* @c: Controller to be checked
808-
*
809-
* Return: Value of the 'unique_discovery_ctrl' flag
810-
*/
811-
bool nvme_ctrl_is_unique_discovery_ctrl(nvme_ctrl_t c);
812-
813778
/**
814779
* nvme_ctrl_identify() - Issues an 'identify controller' command
815780
* @c: Controller instance
@@ -872,32 +837,6 @@ void nvme_free_ctrl(struct nvme_ctrl *c);
872837
*/
873838
void nvme_unlink_ctrl(struct nvme_ctrl *c);
874839

875-
/**
876-
* nvme_subsystem_get_nqn() - Retrieve NQN from subsystem
877-
* @s: nvme_subsystem_t object
878-
*
879-
* Return: NQN of subsystem
880-
*/
881-
const char *nvme_subsystem_get_nqn(nvme_subsystem_t s);
882-
883-
/**
884-
* nvme_subsystem_get_type() - Returns the type of a subsystem
885-
* @s: nvme_subsystem_t object
886-
*
887-
* Returns the subsystem type of @s.
888-
*
889-
* Return: 'nvm' or 'discovery'
890-
*/
891-
const char *nvme_subsystem_get_type(nvme_subsystem_t s);
892-
893-
/**
894-
* nvme_subsystem_get_fw_rev() - Return the firmware rev of subsystem
895-
* @s: nvme_subsystem_t object
896-
*
897-
* Return: Firmware revision of the current subsystem
898-
*/
899-
const char *nvme_subsystem_get_fw_rev(nvme_subsystem_t s);
900-
901840
/**
902841
* nvme_scan_topology() - Scan NVMe topology and apply filter
903842
* @ctx: struct nvme_global_ctx object

libnvme/test/cpp.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ int main()
3434
nvme_for_each_host(ctx, h) {
3535
nvme_for_each_subsystem(h, s) {
3636
std::cout << nvme_subsystem_get_name(s)
37-
<< " - NQN=" << nvme_subsystem_get_nqn(s)
37+
<< " - NQN=" << nvme_subsystem_get_subsysnqn(s)
3838
<< "\n";
3939
nvme_subsystem_for_each_ctrl(s, c) {
4040
std::cout << " `- " << nvme_ctrl_get_name(c)

0 commit comments

Comments
 (0)