Skip to content

Commit

Permalink
Merge fixes/NFSE-4253-hse-cli-tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Tomlinson committed Jul 2, 2020
2 parents 288f81a + d9a0f63 commit 8e334c5
Show file tree
Hide file tree
Showing 10 changed files with 267 additions and 660 deletions.
26 changes: 17 additions & 9 deletions cli/cli_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ hse_kvdb_params(const char *kvdb, bool get)
char * buf;
size_t bufsz = (32 * 1024);
int allc, i;
struct mpool_params *allv;
struct mpool_params *allv = 0;
struct mpool_devrpt ei;

err = mpool_list(&allc, &allv, &ei);
Expand All @@ -540,6 +540,10 @@ hse_kvdb_params(const char *kvdb, bool get)
}
}

/* free mem allocated in mpool_list() */
free(allv);
allv = 0;

if (!match) {
err = mpool_scan(&allc, &allv, &ei);
if (err) {
Expand All @@ -548,20 +552,24 @@ hse_kvdb_params(const char *kvdb, bool get)
}

for (i = 0; i < allc; ++i) {

if (!strcmp(allv[i].mp_name, kvdb)) {
match = true;
break;
}
}

/* free mem allocated n mpool_scan() */
free(allv);
allv = 0;

if (!match) {
fprintf(stderr, "kvdb:%s not found\n", kvdb);
fprintf(stderr, "KVDB '%s' not found\n", kvdb);
} else {
fprintf(
stderr,
"kvdb:%s is inactive. Ensure kvdb is active and open in a process before querying "
"its params.\n",
kvdb);
fprintf(stderr,
"Mpool '%s' is inactive. Must activate the mpool prior to accessing the KVDB.\n"
"Try: mpool activate '%s'\n",
kvdb, kvdb);
}

return -EINVAL;
Expand All @@ -576,8 +584,8 @@ hse_kvdb_params(const char *kvdb, bool get)
if (err) {
fprintf(
stderr,
"rest_kvdb_params failed: %s. Ensure that KVDB:%s is open in a process before "
"querying its params.\n",
"rest_kvdb_params failed: %s\n"
"Ensure that KVDB '%s' is open in a process before querying its params.\n",
merr_info(err, &info),
kvdb);
goto err_out;
Expand Down
Loading

0 comments on commit 8e334c5

Please sign in to comment.