bdevperf: Fix the display name issue.
This patch does the following work: 1 Fix the performance display name issue. When doing the io statistics, we call spdk_bdev_get_name, however this time, we are already calling spdk_app_stop, so we lost the name info. Currently code, we will not see the correct name. And this patch will help to fix this issue, by storing the name at the begining. 2 Fix memory leak issue. It seems that we do not free the target space. Change-Id: I716bda1a7340921e01f9f9ea28b2b908cd19e0af Signed-off-by: Ziye Yang <optimistyzy@gmail.com> Reviewed-on: https://review.gerrithub.io/385347 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
6238f566f5
commit
15c96c6601
@ -46,6 +46,7 @@
|
||||
#include "spdk/log.h"
|
||||
#include "spdk/util.h"
|
||||
#include "spdk/io_channel.h"
|
||||
#include "spdk/string.h"
|
||||
|
||||
struct bdevperf_task {
|
||||
struct iovec iov;
|
||||
@ -74,6 +75,7 @@ static void bdevperf_submit_single(struct io_target *target);
|
||||
#include "../common.c"
|
||||
|
||||
struct io_target {
|
||||
char *name;
|
||||
struct spdk_bdev *bdev;
|
||||
struct spdk_bdev_desc *bdev_desc;
|
||||
struct spdk_io_channel *ch;
|
||||
@ -116,6 +118,23 @@ blockdev_heads_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_heads_destroy(void)
|
||||
{
|
||||
uint32_t i;
|
||||
struct io_target *target, *next_target;
|
||||
|
||||
for (i = 0; i < RTE_MAX_LCORE; i++) {
|
||||
target = head[i];
|
||||
while (target != NULL) {
|
||||
next_target = target->next;
|
||||
free(target->name);
|
||||
free(target);
|
||||
target = next_target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bdevperf_construct_targets(void)
|
||||
{
|
||||
@ -141,6 +160,14 @@ bdevperf_construct_targets(void)
|
||||
return;
|
||||
}
|
||||
|
||||
target->name = strdup(spdk_bdev_get_name(bdev));
|
||||
if (!target->name) {
|
||||
fprintf(stderr, "Unable to allocate memory for target name.\n");
|
||||
free(target);
|
||||
/* Return immediately because all mallocs will presumably fail after this */
|
||||
return;
|
||||
}
|
||||
|
||||
rc = spdk_bdev_open(bdev, true, NULL, NULL, &target->bdev_desc);
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("Could not open leaf bdev %s, error=%d\n", spdk_bdev_get_name(bdev), rc);
|
||||
@ -507,8 +534,7 @@ performance_dump(int io_time)
|
||||
mb_per_second = io_per_second * g_io_size /
|
||||
(1024 * 1024);
|
||||
printf("\r %-20s: %10.2f IO/s %10.2f MB/s\n",
|
||||
spdk_bdev_get_name(target->bdev), io_per_second,
|
||||
mb_per_second);
|
||||
target->name, io_per_second, mb_per_second);
|
||||
total_io_per_second += io_per_second;
|
||||
total_mb_per_second += mb_per_second;
|
||||
target = target->next;
|
||||
@ -735,6 +761,7 @@ main(int argc, char **argv)
|
||||
spdk_app_start(&opts, bdevperf_run, NULL, NULL);
|
||||
|
||||
performance_dump(g_time_in_sec);
|
||||
blockdev_heads_destroy();
|
||||
spdk_app_fini();
|
||||
printf("done.\n");
|
||||
return g_run_failed;
|
||||
|
Loading…
Reference in New Issue
Block a user