Skip to content

Commit 3b2f53f

Browse files
committed
plugins: replace nvme_scan with nvme_scan_topology
nvme_scan creates first a root object and then does a scan. Because the root object is usually already created the parse_and_open helper we don't need to create another object (and leak the first one). Thus call directly nvme_scan_topology. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 52e47fd commit 3b2f53f

4 files changed

Lines changed: 55 additions & 52 deletions

File tree

plugins/sandisk/sandisk-nvme.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static int sndk_capabilities(int argc, char **argv,
146146
return ret;
147147

148148
/* get capabilities */
149-
r = nvme_scan(NULL);
149+
nvme_scan_topology(r, NULL, NULL);
150150
sndk_check_device(r, l);
151151
capabilities = sndk_get_drive_capabilities(r, l);
152152

plugins/solidigm/solidigm-get-drive-info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int sldgm_get_drive_info(int argc, char **argv, struct command *cmd, struct plug
4040
return err;
4141
}
4242

43-
r = nvme_scan(NULL);
43+
nvme_scan_topology(r, NULL, NULL);
4444
c = nvme_scan_ctrl(r, nvme_link_get_name(l));
4545
n = c ? nvme_ctrl_first_ns(c) : nvme_scan_namespace(nvme_link_get_name(l));
4646
if (!n) {

plugins/wdc/wdc-nvme.c

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,7 +3148,7 @@ static int wdc_do_dump_e6(nvme_link_t l, __u32 opcode, __u32 data_len,
31483148
return ret;
31493149
}
31503150

3151-
static int wdc_do_cap_telemetry_log(nvme_link_t l, const char *file,
3151+
static int wdc_do_cap_telemetry_log(nvme_root_t r, nvme_link_t l, const char *file,
31523152
__u32 bs, int type, int data_area)
31533153
{
31543154
struct nvme_telemetry_log *log;
@@ -3162,7 +3162,6 @@ static int wdc_do_cap_telemetry_log(nvme_link_t l, const char *file,
31623162
int data_written = 0, data_remaining = 0;
31633163
struct nvme_id_ctrl ctrl;
31643164
__u64 capabilities = 0;
3165-
nvme_root_t r;
31663165

31673166
memset(&ctrl, 0, sizeof(struct nvme_id_ctrl));
31683167
err = nvme_identify_ctrl(l, &ctrl);
@@ -3176,7 +3175,7 @@ static int wdc_do_cap_telemetry_log(nvme_link_t l, const char *file,
31763175
return -EINVAL;
31773176
}
31783177

3179-
r = nvme_scan(NULL);
3178+
nvme_scan_topology(r, NULL, NULL);
31803179
capabilities = wdc_get_drive_capabilities(r, l);
31813180

31823181
if (type == WDC_TELEMETRY_TYPE_HOST) {
@@ -3322,7 +3321,7 @@ static int wdc_do_cap_diag(nvme_root_t r, nvme_link_t l, char *file,
33223321
} else if ((type == WDC_TELEMETRY_TYPE_HOST) ||
33233322
(type == WDC_TELEMETRY_TYPE_CONTROLLER)) {
33243323
/* Get the desired telemetry log page */
3325-
ret = wdc_do_cap_telemetry_log(l, file, xfer_size, type, data_area);
3324+
ret = wdc_do_cap_telemetry_log(r, l, file, xfer_size, type, data_area);
33263325
} else {
33273326
fprintf(stderr, "%s: ERROR: Invalid type : %d\n", __func__, type);
33283327
}
@@ -3820,7 +3819,7 @@ static int wdc_cap_diag(int argc, char **argv, struct command *command,
38203819
if (ret)
38213820
return ret;
38223821

3823-
r = nvme_scan(NULL);
3822+
nvme_scan_topology(r, NULL, NULL);
38243823

38253824
if (cfg.file)
38263825
strncpy(f, cfg.file, PATH_MAX - 1);
@@ -4239,7 +4238,7 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command
42394238
if (ret)
42404239
return ret;
42414240

4242-
r = nvme_scan(NULL);
4241+
nvme_scan_topology(r, NULL, NULL);
42434242
if (!wdc_check_device(r, l))
42444243
goto out;
42454244

@@ -4401,7 +4400,7 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command
44014400
if (!telemetry_data_area)
44024401
telemetry_data_area = 3; /* Set the default DA to 3 if not specified */
44034402
/* Get the desired telemetry log page */
4404-
ret = wdc_do_cap_telemetry_log(l, f, xfer_size,
4403+
ret = wdc_do_cap_telemetry_log(r, l, f, xfer_size,
44054404
telemetry_type, telemetry_data_area);
44064405
goto out;
44074406
} else {
@@ -4424,7 +4423,7 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command
44244423
if (!telemetry_data_area)
44254424
telemetry_data_area = 3; /* Set the default DA to 3 if not specified */
44264425
/* Get the desired telemetry log page */
4427-
ret = wdc_do_cap_telemetry_log(l, f, xfer_size,
4426+
ret = wdc_do_cap_telemetry_log(r, l, f, xfer_size,
44284427
telemetry_type, telemetry_data_area);
44294428
goto out;
44304429
} else {
@@ -4603,7 +4602,7 @@ static int wdc_drive_log(int argc, char **argv, struct command *command,
46034602
if (ret)
46044603
return ret;
46054604

4606-
r = nvme_scan(NULL);
4605+
nvme_scan_topology(r, NULL, NULL);
46074606

46084607
if (!wdc_check_device(r, l))
46094608
return -1;
@@ -4652,7 +4651,7 @@ static int wdc_get_crash_dump(int argc, char **argv, struct command *command,
46524651
if (ret)
46534652
return ret;
46544653

4655-
r = nvme_scan(NULL);
4654+
nvme_scan_topology(r, NULL, NULL);
46564655

46574656
if (!wdc_check_device(r, l))
46584657
return -1;
@@ -4696,7 +4695,7 @@ static int wdc_get_pfail_dump(int argc, char **argv, struct command *command,
46964695
if (ret)
46974696
return ret;
46984697

4699-
r = nvme_scan(NULL);
4698+
nvme_scan_topology(r, NULL, NULL);
47004699

47014700
if (!wdc_check_device(r, l))
47024701
return -1;
@@ -4778,7 +4777,7 @@ static int wdc_purge(int argc, char **argv,
47784777
if (ret)
47794778
return ret;
47804779

4781-
r = nvme_scan(NULL);
4780+
nvme_scan_topology(r, NULL, NULL);
47824781

47834782
if (!wdc_check_device(r, l))
47844783
return -1;
@@ -4834,7 +4833,7 @@ static int wdc_purge_monitor(int argc, char **argv,
48344833
if (ret)
48354834
return ret;
48364835

4837-
r = nvme_scan(NULL);
4836+
nvme_scan_topology(r, NULL, NULL);
48384837
if (!wdc_check_device(r, l)) {
48394838
return -1;
48404839
}
@@ -8319,7 +8318,7 @@ static int wdc_vs_smart_add_log(int argc, char **argv, struct command *command,
83198318
if (ret)
83208319
return ret;
83218320

8322-
r = nvme_scan(NULL);
8321+
nvme_scan_topology(r, NULL, NULL);
83238322
if (!cfg.log_page_version) {
83248323
uuid_index = 0;
83258324
} else if (cfg.log_page_version == 1) {
@@ -8448,7 +8447,7 @@ static int wdc_vs_cloud_log(int argc, char **argv, struct command *command,
84488447
if (ret)
84498448
return ret;
84508449

8451-
r = nvme_scan(NULL);
8450+
nvme_scan_topology(r, NULL, NULL);
84528451

84538452
capabilities = wdc_get_drive_capabilities(r, l);
84548453

@@ -8517,7 +8516,7 @@ static int wdc_vs_hw_rev_log(int argc, char **argv, struct command *command,
85178516
if (ret)
85188517
return ret;
85198518

8520-
r = nvme_scan(NULL);
8519+
nvme_scan_topology(r, NULL, NULL);
85218520

85228521
capabilities = wdc_get_drive_capabilities(r, l);
85238522

@@ -8607,7 +8606,7 @@ static int wdc_vs_device_waf(int argc, char **argv, struct command *command,
86078606
if (ret)
86088607
return ret;
86098608

8610-
r = nvme_scan(NULL);
8609+
nvme_scan_topology(r, NULL, NULL);
86118610

86128611
capabilities = wdc_get_drive_capabilities(r, l);
86138612

@@ -8714,7 +8713,7 @@ static int wdc_get_latency_monitor_log(int argc, char **argv, struct command *co
87148713
if (ret)
87158714
return ret;
87168715

8717-
r = nvme_scan(NULL);
8716+
nvme_scan_topology(r, NULL, NULL);
87188717
capabilities = wdc_get_drive_capabilities(r, l);
87198718

87208719
if (!(capabilities & WDC_DRIVE_CAP_C3_LOG_PAGE)) {
@@ -8757,7 +8756,7 @@ static int wdc_get_error_recovery_log(int argc, char **argv, struct command *com
87578756
if (ret)
87588757
return ret;
87598758

8760-
r = nvme_scan(NULL);
8759+
nvme_scan_topology(r, NULL, NULL);
87618760
capabilities = wdc_get_drive_capabilities(r, l);
87628761

87638762
if (!(capabilities & WDC_DRIVE_CAP_OCP_C1_LOG_PAGE)) {
@@ -8800,7 +8799,7 @@ static int wdc_get_dev_capabilities_log(int argc, char **argv, struct command *c
88008799
if (ret)
88018800
return ret;
88028801

8803-
r = nvme_scan(NULL);
8802+
nvme_scan_topology(r, NULL, NULL);
88048803
capabilities = wdc_get_drive_capabilities(r, l);
88058804

88068805
if (!(capabilities & WDC_DRIVE_CAP_OCP_C4_LOG_PAGE)) {
@@ -8843,7 +8842,7 @@ static int wdc_get_unsupported_reqs_log(int argc, char **argv, struct command *c
88438842
if (ret)
88448843
return ret;
88458844

8846-
r = nvme_scan(NULL);
8845+
nvme_scan_topology(r, NULL, NULL);
88478846
capabilities = wdc_get_drive_capabilities(r, l);
88488847

88498848
if (!(capabilities & WDC_DRIVE_CAP_OCP_C5_LOG_PAGE)) {
@@ -8918,7 +8917,7 @@ static int wdc_clear_pcie_correctable_errors(int argc, char **argv, struct comma
89188917
if (ret)
89198918
return ret;
89208919

8921-
r = nvme_scan(NULL);
8920+
nvme_scan_topology(r, NULL, NULL);
89228921
if (!wdc_check_device(r, l)) {
89238922
ret = -1;
89248923
goto out;
@@ -8968,7 +8967,7 @@ static int wdc_drive_status(int argc, char **argv, struct command *command,
89688967
if (ret)
89698968
return ret;
89708969

8971-
r = nvme_scan(NULL);
8970+
nvme_scan_topology(r, NULL, NULL);
89728971
capabilities = wdc_get_drive_capabilities(r, l);
89738972
if ((capabilities & WDC_DRIVE_CAP_DRIVE_STATUS) != WDC_DRIVE_CAP_DRIVE_STATUS) {
89748973
fprintf(stderr, "ERROR: WDC: unsupported device for this command\n");
@@ -9102,7 +9101,7 @@ static int wdc_clear_assert_dump(int argc, char **argv, struct command *command,
91029101
if (ret)
91039102
return ret;
91049103

9105-
r = nvme_scan(NULL);
9104+
nvme_scan_topology(r, NULL, NULL);
91069105
capabilities = wdc_get_drive_capabilities(r, l);
91079106
if ((capabilities & WDC_DRIVE_CAP_CLEAR_ASSERT) != WDC_DRIVE_CAP_CLEAR_ASSERT) {
91089107
fprintf(stderr, "ERROR: WDC: unsupported device for this command\n");
@@ -9325,7 +9324,7 @@ static int wdc_vs_fw_activate_history(int argc, char **argv, struct command *com
93259324
if (ret)
93269325
return ret;
93279326

9328-
r = nvme_scan(NULL);
9327+
nvme_scan_topology(r, NULL, NULL);
93299328
capabilities = wdc_get_drive_capabilities(r, l);
93309329
if (!(capabilities & WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY_MASK)) {
93319330
fprintf(stderr, "ERROR: WDC: unsupported device for this command\n");
@@ -9406,7 +9405,7 @@ static int wdc_clear_fw_activate_history(int argc, char **argv, struct command *
94069405
if (ret)
94079406
return ret;
94089407

9409-
r = nvme_scan(NULL);
9408+
nvme_scan_topology(r, NULL, NULL);
94109409
capabilities = wdc_get_drive_capabilities(r, l);
94119410
if (!(capabilities & WDC_DRIVE_CAP_CLEAR_FW_ACT_HISTORY_MASK)) {
94129411
fprintf(stderr, "ERROR: WDC: unsupported device for this command\n");
@@ -9460,7 +9459,7 @@ static int wdc_vs_telemetry_controller_option(int argc, char **argv, struct comm
94609459
if (ret)
94619460
return ret;
94629461

9463-
r = nvme_scan(NULL);
9462+
nvme_scan_topology(r, NULL, NULL);
94649463
capabilities = wdc_get_drive_capabilities(r, l);
94659464
if ((capabilities & WDC_DRVIE_CAP_DISABLE_CTLR_TELE_LOG) != WDC_DRVIE_CAP_DISABLE_CTLR_TELE_LOG) {
94669465
fprintf(stderr, "ERROR: WDC: unsupported device for this command\n");
@@ -10253,7 +10252,7 @@ static int wdc_drive_essentials(int argc, char **argv, struct command *command,
1025310252
if (ret)
1025410253
return ret;
1025510254

10256-
r = nvme_scan(NULL);
10255+
nvme_scan_topology(r, NULL, NULL);
1025710256
capabilities = wdc_get_drive_capabilities(r, l);
1025810257
if ((capabilities & WDC_DRIVE_CAP_DRIVE_ESSENTIALS) != WDC_DRIVE_CAP_DRIVE_ESSENTIALS) {
1025910258
fprintf(stderr, "ERROR: WDC: unsupported device for this command\n");
@@ -10347,7 +10346,7 @@ static int wdc_drive_resize(int argc, char **argv,
1034710346
if (ret)
1034810347
return ret;
1034910348

10350-
r = nvme_scan(NULL);
10349+
nvme_scan_topology(r, NULL, NULL);
1035110350
wdc_check_device(r, l);
1035210351
capabilities = wdc_get_drive_capabilities(r, l);
1035310352
if ((capabilities & WDC_DRIVE_CAP_RESIZE) == WDC_DRIVE_CAP_RESIZE) {
@@ -10401,7 +10400,7 @@ static int wdc_namespace_resize(int argc, char **argv,
1040110400
return -1;
1040210401
}
1040310402

10404-
r = nvme_scan(NULL);
10403+
nvme_scan_topology(r, NULL, NULL);
1040510404
wdc_check_device(r, l);
1040610405
capabilities = wdc_get_drive_capabilities(r, l);
1040710406
if ((capabilities & WDC_DRIVE_CAP_NS_RESIZE) == WDC_DRIVE_CAP_NS_RESIZE) {
@@ -10455,7 +10454,7 @@ static int wdc_reason_identifier(int argc, char **argv,
1045510454
if (ret)
1045610455
return ret;
1045710456

10458-
r = nvme_scan(NULL);
10457+
nvme_scan_topology(r, NULL, NULL);
1045910458

1046010459
if (cfg.log_id != NVME_LOG_LID_TELEMETRY_HOST &&
1046110460
cfg.log_id != NVME_LOG_LID_TELEMETRY_CTRL) {
@@ -10719,7 +10718,7 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *command
1071910718
return ret;
1072010719
}
1072110720

10722-
r = nvme_scan(NULL);
10721+
nvme_scan_topology(r, NULL, NULL);
1072310722
capabilities = wdc_get_drive_capabilities(r, l);
1072410723

1072510724
if (!(capabilities & WDC_DRIVE_CAP_LOG_PAGE_DIR)) {
@@ -11455,7 +11454,7 @@ static int wdc_vs_nand_stats(int argc, char **argv, struct command *command,
1145511454
if (ret)
1145611455
return ret;
1145711456

11458-
r = nvme_scan(NULL);
11457+
nvme_scan_topology(r, NULL, NULL);
1145911458
capabilities = wdc_get_drive_capabilities(r, l);
1146011459

1146111460
if (!(capabilities & WDC_DRIVE_CAP_NAND_STATS)) {
@@ -11532,7 +11531,7 @@ static int wdc_vs_pcie_stats(int argc, char **argv, struct command *command,
1153211531
if (ret)
1153311532
return ret;
1153411533

11535-
r = nvme_scan(NULL);
11534+
nvme_scan_topology(r, NULL, NULL);
1153611535
ret = validate_output_format(cfg.output_format, &fmt);
1153711536
if (ret < 0) {
1153811537
fprintf(stderr, "ERROR: WDC: invalid output format\n");
@@ -11633,7 +11632,7 @@ static int wdc_vs_drive_info(int argc, char **argv,
1163311632
return ret;
1163411633
}
1163511634

11636-
r = nvme_scan(NULL);
11635+
nvme_scan_topology(r, NULL, NULL);
1163711636
wdc_check_device(r, l);
1163811637
capabilities = wdc_get_drive_capabilities(r, l);
1163911638
if ((capabilities & WDC_DRIVE_CAP_INFO) == WDC_DRIVE_CAP_INFO) {
@@ -11870,7 +11869,7 @@ static int wdc_vs_temperature_stats(int argc, char **argv,
1187011869
if (ret)
1187111870
return ret;
1187211871

11873-
r = nvme_scan(NULL);
11872+
nvme_scan_topology(r, NULL, NULL);
1187411873
ret = validate_output_format(cfg.output_format, &fmt);
1187511874
if (ret < 0) {
1187611875
fprintf(stderr, "ERROR: WDC: invalid output format\n");
@@ -11972,7 +11971,7 @@ static int wdc_capabilities(int argc, char **argv, struct command *command, stru
1197211971
return ret;
1197311972

1197411973
/* get capabilities */
11975-
r = nvme_scan(NULL);
11974+
nvme_scan_topology(r, NULL, NULL);
1197611975
wdc_check_device(r, l);
1197711976
capabilities = wdc_get_drive_capabilities(r, l);
1197811977

@@ -12077,7 +12076,7 @@ static int wdc_cloud_ssd_plugin_version(int argc, char **argv, struct command *c
1207712076
return ret;
1207812077

1207912078
/* get capabilities */
12080-
r = nvme_scan(NULL);
12079+
nvme_scan_topology(r, NULL, NULL);
1208112080
wdc_check_device(r, l);
1208212081
capabilities = wdc_get_drive_capabilities(r, l);
1208312082

@@ -12122,7 +12121,7 @@ static int wdc_cloud_boot_SSD_version(int argc, char **argv, struct command *com
1212212121
return ret;
1212312122

1212412123
/* get capabilities */
12125-
r = nvme_scan(NULL);
12124+
nvme_scan_topology(r, NULL, NULL);
1212612125
wdc_check_device(r, l);
1212712126
capabilities = wdc_get_drive_capabilities(r, l);
1212812127

@@ -12507,7 +12506,7 @@ int wdc_set_latency_monitor_feature(int argc, char **argv, struct command *cmd,
1250712506
return ret;
1250812507

1250912508
/* get capabilities */
12510-
r = nvme_scan(NULL);
12509+
nvme_scan_topology(r, NULL, NULL);
1251112510
wdc_check_device(r, l);
1251212511
capabilities = wdc_get_drive_capabilities(r, l);
1251312512

0 commit comments

Comments
 (0)