Skip to content

Commit ecab21c

Browse files
ikegami-tigaw
authored andcommitted
nvme-print-binary: fix to output reachability groups log length
Previously only the log header output since the log length is changeable. The changes to output the changeable log length correctly. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent b5bb01a commit ecab21c

6 files changed

Lines changed: 19 additions & 15 deletions

File tree

nvme-print-binary.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ static void binary_dispersed_ns_psub_log(struct nvme_dispersed_ns_participating_
322322
d_raw((unsigned char *)log, sizeof(*log));
323323
}
324324

325-
static void binary_reachability_groups_log(struct nvme_reachability_groups_log *log)
325+
static void binary_reachability_groups_log(struct nvme_reachability_groups_log *log, __u64 len)
326326
{
327-
d_raw((unsigned char *)log, sizeof(*log));
327+
d_raw((unsigned char *)log, len);
328328
}
329329

330330
static void binary_reachability_associations_log(struct nvme_reachability_associations_log *log,

nvme-print-json.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4684,7 +4684,7 @@ static void json_dispersed_ns_psub_log(struct nvme_dispersed_ns_participating_ns
46844684
json_print(r);
46854685
}
46864686

4687-
static void json_reachability_groups_log(struct nvme_reachability_groups_log *log)
4687+
static void json_reachability_groups_log(struct nvme_reachability_groups_log *log, __u64 len UNUSED)
46884688
{
46894689
struct json_object *r = json_create_object();
46904690
__u16 i;

nvme-print-stdout.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5657,11 +5657,12 @@ static void stdout_dispersed_ns_psub_log(struct nvme_dispersed_ns_participating_
56575657
&log->participating_nss[i * NVME_NQN_LENGTH]);
56585658
}
56595659

5660-
static void stdout_reachability_groups_log(struct nvme_reachability_groups_log *log)
5660+
static void stdout_reachability_groups_log(struct nvme_reachability_groups_log *log, __u64 len)
56615661
{
56625662
__u16 i;
56635663
__u32 j;
56645664

5665+
print_debug("len: %"PRIu64"\n", (uint64_t)len);
56655666
printf("chngc: %"PRIu64"\n", le64_to_cpu(log->chngc));
56665667
printf("nrgd: %u\n", le16_to_cpu(log->nrgd));
56675668

nvme-print.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,9 +1510,9 @@ void nvme_show_dispersed_ns_psub_log(struct nvme_dispersed_ns_participating_nss_
15101510
}
15111511

15121512
void nvme_show_reachability_groups_log(struct nvme_reachability_groups_log *log,
1513-
nvme_print_flags_t flags)
1513+
__u64 len, nvme_print_flags_t flags)
15141514
{
1515-
nvme_print(reachability_groups_log, flags, log);
1515+
nvme_print(reachability_groups_log, flags, log, len);
15161516
}
15171517

15181518
void nvme_show_reachability_associations_log(struct nvme_reachability_associations_log *log,

nvme-print.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct print_ops {
9191
void (*mgmt_addr_list_log)(struct nvme_mgmt_addr_list_log *ma_log);
9292
void (*rotational_media_info_log)(struct nvme_rotational_media_info_log *info);
9393
void (*dispersed_ns_psub_log)(struct nvme_dispersed_ns_participating_nss_log *log);
94-
void (*reachability_groups_log)(struct nvme_reachability_groups_log *log);
94+
void (*reachability_groups_log)(struct nvme_reachability_groups_log *log, __u64 len);
9595
void (*reachability_associations_log)(struct nvme_reachability_associations_log *log,
9696
__u64 len);
9797

@@ -342,7 +342,7 @@ void nvme_show_rotational_media_info_log(struct nvme_rotational_media_info_log *
342342
void nvme_show_dispersed_ns_psub_log(struct nvme_dispersed_ns_participating_nss_log *log,
343343
nvme_print_flags_t flags);
344344
void nvme_show_reachability_groups_log(struct nvme_reachability_groups_log *log,
345-
nvme_print_flags_t flags);
345+
__u64 len, nvme_print_flags_t flags);
346346
void nvme_show_reachability_associations_log(struct nvme_reachability_associations_log *log,
347347
__u64 len, nvme_print_flags_t flags);
348348
#endif /* NVME_PRINT_H */

nvme.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10390,7 +10390,7 @@ static int get_log_offset(struct nvme_dev *dev, struct nvme_get_log_args *args,
1039010390
}
1039110391

1039210392
static int get_reachability_group_desc(struct nvme_dev *dev, struct nvme_get_log_args *args,
10393-
__u64 offset, struct nvme_reachability_groups_log **logp)
10393+
__u64 *offset, struct nvme_reachability_groups_log **logp)
1039410394
{
1039510395
int err;
1039610396
struct nvme_reachability_groups_log *log = *logp;
@@ -10399,11 +10399,11 @@ static int get_reachability_group_desc(struct nvme_dev *dev, struct nvme_get_log
1039910399

1040010400
for (i = 0; i < le16_to_cpu(log->nrgd); i++) {
1040110401
len = sizeof(*log->rgd);
10402-
err = get_log_offset(dev, args, &offset, len, (void **)&log);
10402+
err = get_log_offset(dev, args, offset, len, (void **)&log);
1040310403
if (err)
1040410404
goto err_free;
1040510405
len = le32_to_cpu(log->rgd[i].nnid) * sizeof(*log->rgd[i].nsid);
10406-
err = get_log_offset(dev, args, &offset, len, (void **)&log);
10406+
err = get_log_offset(dev, args, offset, len, (void **)&log);
1040710407
if (err)
1040810408
goto err_free;
1040910409
}
@@ -10418,7 +10418,8 @@ static int get_reachability_group_desc(struct nvme_dev *dev, struct nvme_get_log
1041810418
}
1041910419

1042010420
static int get_reachability_groups(struct nvme_dev *dev, bool rgo, bool rae,
10421-
struct nvme_reachability_groups_log **logp)
10421+
struct nvme_reachability_groups_log **logp,
10422+
__u64 *lenp)
1042210423
{
1042310424
int err;
1042410425
struct nvme_reachability_groups_log *log;
@@ -10441,11 +10442,12 @@ static int get_reachability_groups(struct nvme_dev *dev, bool rgo, bool rae,
1044110442
if (err)
1044210443
goto err_free;
1044310444

10444-
err = get_reachability_group_desc(dev, &args, log_len, &log);
10445+
err = get_reachability_group_desc(dev, &args, &log_len, &log);
1044510446
if (err)
1044610447
goto err_free;
1044710448

1044810449
*logp = log;
10450+
*lenp = log_len;
1044910451
return 0;
1045010452

1045110453
err_free:
@@ -10460,6 +10462,7 @@ static int get_reachability_groups_log(int argc, char **argv, struct command *cm
1046010462
const char *rgo = "Return Groups Only";
1046110463
nvme_print_flags_t flags;
1046210464
int err;
10465+
__u64 len = 0;
1046310466

1046410467
_cleanup_free_ struct nvme_reachability_groups_log *log = NULL;
1046510468

@@ -10489,9 +10492,9 @@ static int get_reachability_groups_log(int argc, char **argv, struct command *cm
1048910492
return err;
1049010493
}
1049110494

10492-
err = get_reachability_groups(dev, cfg.rgo, cfg.rae, &log);
10495+
err = get_reachability_groups(dev, cfg.rgo, cfg.rae, &log, &len);
1049310496
if (!err)
10494-
nvme_show_reachability_groups_log(log, flags);
10497+
nvme_show_reachability_groups_log(log, len, flags);
1049510498
else if (err > 0)
1049610499
nvme_show_status(err);
1049710500
else

0 commit comments

Comments
 (0)