The level of verbosity is high when exporting the YAML configuration
for the purposes of storing it to reconfigure a node. This patch
eliminates the unnecessary YAML lines which are not needed when
reconfiguring a node, such as statistics, status, etc.
Test-Parameters: trivial
Signed-off-by: Amir Shehata <amir.shehata@intel.com>
Change-Id: Ie57c761415cfb0ceee8b2dbc0b293e85ae415685
Reviewed-on: https://review.whamcloud.com/30845
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Doug Oucharek <dougso@me.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
int lustre_lnet_show_route(char *nw, char *gw, int hops, int prio, int detail,
int seq_no, struct cYAML **show_rc,
int lustre_lnet_show_route(char *nw, char *gw, int hops, int prio, int detail,
int seq_no, struct cYAML **show_rc,
+ struct cYAML **err_rc, bool backup)
{
struct lnet_ioctl_config_data data;
lnet_nid_t gateway_nid;
{
struct lnet_ioctl_config_data data;
lnet_nid_t gateway_nid;
cfg_route.rtr_priority) == NULL)
goto out;
cfg_route.rtr_priority) == NULL)
goto out;
- if (cYAML_create_string(item, "state",
+ if (!backup &&
+ cYAML_create_string(item, "state",
data.cfg_config_u.cfg_route.
rtr_flags ?
"up" : "down") == NULL)
data.cfg_config_u.cfg_route.
rtr_flags ?
"up" : "down") == NULL)
}
int lustre_lnet_show_net(char *nw, int detail, int seq_no,
}
int lustre_lnet_show_net(char *nw, int detail, int seq_no,
- struct cYAML **show_rc, struct cYAML **err_rc)
+ struct cYAML **show_rc, struct cYAML **err_rc,
+ bool backup)
{
char *buf;
struct lnet_ioctl_config_ni *ni_data;
{
char *buf;
struct lnet_ioctl_config_ni *ni_data;
+ /* if we're backing up don't store lo */
+ if (backup && LNET_NETTYP(rc_net) == LOLND)
+ continue;
+
/* default rc to -1 in case we hit the goto */
rc = -1;
exist = true;
/* default rc to -1 in case we hit the goto */
rc = -1;
exist = true;
if (first_seq == NULL)
first_seq = item;
if (first_seq == NULL)
first_seq = item;
- if (cYAML_create_string(item, "nid",
+ if (!backup &&
+ cYAML_create_string(item, "nid",
libcfs_nid2str(ni_data->lic_nid)) == NULL)
goto out;
libcfs_nid2str(ni_data->lic_nid)) == NULL)
goto out;
- if (cYAML_create_string(item,
+ if (!backup &&
+ cYAML_create_string(item,
"status",
(ni_data->lic_status ==
LNET_NI_STATUS_UP) ?
"status",
(ni_data->lic_status ==
LNET_NI_STATUS_UP) ?
+ if (backup)
+ goto continue_without_msg_stats;
+
statistics = cYAML_create_object(item, "statistics");
if (statistics == NULL)
goto out;
statistics = cYAML_create_object(item, "statistics");
if (statistics == NULL)
goto out;
if (rc != LUSTRE_CFG_RC_NO_ERR)
goto out;
if (rc != LUSTRE_CFG_RC_NO_ERR)
goto out;
- tunables = cYAML_create_object(item, "lnd tunables");
- if (tunables == NULL)
- goto out;
-
rc = lustre_ni_show_tunables(tunables, LNET_NETTYP(rc_net),
&lnd->lt_tun);
rc = lustre_ni_show_tunables(tunables, LNET_NETTYP(rc_net),
&lnd->lt_tun);
- if (rc != LUSTRE_CFG_RC_NO_ERR)
+ if (rc != LUSTRE_CFG_RC_NO_ERR &&
+ rc != LUSTRE_CFG_RC_NO_MATCH)
- if (cYAML_create_number(item, "tcp bonding",
- ni_data->lic_tcp_bonding)
- == NULL)
- goto out;
+ if (rc != LUSTRE_CFG_RC_NO_MATCH) {
+ tunables = cYAML_create_object(item,
+ "lnd tunables");
+ if (tunables == NULL)
+ goto out;
+ }
- if (cYAML_create_number(item, "dev cpt",
+ if (!backup &&
+ cYAML_create_number(item, "dev cpt",
ni_data->lic_dev_cpt) == NULL)
goto out;
ni_data->lic_dev_cpt) == NULL)
goto out;
+ if (!backup &&
+ cYAML_create_number(item, "tcp bonding",
+ ni_data->lic_tcp_bonding)
+ == NULL)
+ goto out;
+
/* out put the CPTs in the format: "[x,x,x,...]" */
limit = str_buf + str_buf_len - 3;
pos += snprintf(pos, limit - pos, "\"[");
/* out put the CPTs in the format: "[x,x,x,...]" */
limit = str_buf + str_buf_len - 3;
pos += snprintf(pos, limit - pos, "\"[");
}
int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
}
int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
+ struct cYAML **err_rc, bool backup)
{
struct lnet_ioctl_config_data *data;
struct lnet_ioctl_pool_cfg *pool_cfg = NULL;
{
struct lnet_ioctl_config_data *data;
struct lnet_ioctl_pool_cfg *pool_cfg = NULL;
if (root == NULL)
goto out;
if (root == NULL)
goto out;
- pools_node = cYAML_create_seq(root, "routing");
+ if (backup)
+ pools_node = cYAML_create_object(root, "routing");
+ else
+ pools_node = cYAML_create_seq(root, "routing");
if (pools_node == NULL)
goto out;
if (pools_node == NULL)
goto out;
pool_cfg = (struct lnet_ioctl_pool_cfg *)data->cfg_bulk;
pool_cfg = (struct lnet_ioctl_pool_cfg *)data->cfg_bulk;
+ if (backup)
+ goto calculate_buffers;
+
snprintf(node_name, sizeof(node_name), "cpt[%d]", i);
item = cYAML_create_seq_item(pools_node);
if (item == NULL)
snprintf(node_name, sizeof(node_name), "cpt[%d]", i);
item = cYAML_create_seq_item(pools_node);
if (item == NULL)
if (cpt == NULL)
goto out;
if (cpt == NULL)
goto out;
/* create the tree and print */
for (j = 0; j < LNET_NRBPOOLS; j++) {
/* create the tree and print */
for (j = 0; j < LNET_NRBPOOLS; j++) {
- type_node = cYAML_create_object(cpt, pools[j]);
- if (type_node == NULL)
- goto out;
- if (cYAML_create_number(type_node, "npages",
+ if (!backup) {
+ type_node = cYAML_create_object(cpt, pools[j]);
+ if (type_node == NULL)
+ goto out;
+ }
+ if (!backup &&
+ cYAML_create_number(type_node, "npages",
pool_cfg->pl_pools[j].pl_npages)
== NULL)
goto out;
pool_cfg->pl_pools[j].pl_npages)
== NULL)
goto out;
- if (cYAML_create_number(type_node, "nbuffers",
+ if (!backup &&
+ cYAML_create_number(type_node, "nbuffers",
pool_cfg->pl_pools[j].
pl_nbuffers) == NULL)
goto out;
pool_cfg->pl_pools[j].
pl_nbuffers) == NULL)
goto out;
- if (cYAML_create_number(type_node, "credits",
+ if (!backup &&
+ cYAML_create_number(type_node, "credits",
pool_cfg->pl_pools[j].
pl_credits) == NULL)
goto out;
pool_cfg->pl_pools[j].
pl_credits) == NULL)
goto out;
- if (cYAML_create_number(type_node, "mincredits",
+ if (!backup &&
+ cYAML_create_number(type_node, "mincredits",
pool_cfg->pl_pools[j].
pl_mincredits) == NULL)
goto out;
pool_cfg->pl_pools[j].
pl_mincredits) == NULL)
goto out;
}
if (pool_cfg != NULL) {
}
if (pool_cfg != NULL) {
+ if (backup) {
+ if (cYAML_create_number(pools_node, "enable",
+ pool_cfg->pl_routing) ==
+ NULL)
+ goto out;
+
+ goto add_buffer_section;
+ }
+
item = cYAML_create_seq_item(pools_node);
if (item == NULL)
goto out;
item = cYAML_create_seq_item(pools_node);
if (item == NULL)
goto out;
/* create a buffers entry in the show. This is necessary so that
* if the YAML output is used to configure a node, the buffer
* configuration takes hold */
/* create a buffers entry in the show. This is necessary so that
* if the YAML output is used to configure a node, the buffer
* configuration takes hold */
}
int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
}
int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
- struct cYAML **show_rc, struct cYAML **err_rc)
+ struct cYAML **show_rc, struct cYAML **err_rc,
+ bool backup)
{
/*
* TODO: This function is changing in a future patch to accommodate
{
/*
* TODO: This function is changing in a future patch to accommodate
* requested
*/
if (detail >= 3) {
* requested
*/
if (detail >= 3) {
- if (cYAML_create_number(peer, "peer state",
+ if (!backup &&
+ cYAML_create_number(peer, "peer state",
peer_info.prcfg_state)
== NULL)
goto out;
peer_info.prcfg_state)
== NULL)
goto out;
+ if (backup)
+ continue;
+
if (cYAML_create_string(peer_ni, "state",
lpni_cri->cr_aliveness)
== NULL)
if (cYAML_create_string(peer_ni, "state",
lpni_cri->cr_aliveness)
== NULL)
(prio) ? prio->cy_valueint : -1,
(detail) ? detail->cy_valueint : 0,
(seq_no) ? seq_no->cy_valueint : -1,
(prio) ? prio->cy_valueint : -1,
(detail) ? detail->cy_valueint : 0,
(seq_no) ? seq_no->cy_valueint : -1,
+ show_rc, err_rc, false);
}
static int handle_yaml_show_net(struct cYAML *tree, struct cYAML **show_rc,
}
static int handle_yaml_show_net(struct cYAML *tree, struct cYAML **show_rc,
return lustre_lnet_show_net((net) ? net->cy_valuestring : NULL,
(detail) ? detail->cy_valueint : 0,
(seq_no) ? seq_no->cy_valueint : -1,
return lustre_lnet_show_net((net) ? net->cy_valuestring : NULL,
(detail) ? detail->cy_valueint : 0,
(seq_no) ? seq_no->cy_valueint : -1,
+ show_rc, err_rc, false);
}
static int handle_yaml_show_routing(struct cYAML *tree, struct cYAML **show_rc,
}
static int handle_yaml_show_routing(struct cYAML *tree, struct cYAML **show_rc,
seq_no = cYAML_get_object_item(tree, "seq_no");
return lustre_lnet_show_routing((seq_no) ? seq_no->cy_valueint : -1,
seq_no = cYAML_get_object_item(tree, "seq_no");
return lustre_lnet_show_routing((seq_no) ? seq_no->cy_valueint : -1,
+ show_rc, err_rc, false);
}
static int handle_yaml_show_peers(struct cYAML *tree, struct cYAML **show_rc,
}
static int handle_yaml_show_peers(struct cYAML *tree, struct cYAML **show_rc,
return lustre_lnet_show_peer((nid) ? nid->cy_valuestring : NULL,
(detail) ? detail->cy_valueint : 0,
(seq_no) ? seq_no->cy_valueint : -1,
return lustre_lnet_show_peer((nid) ? nid->cy_valuestring : NULL,
(detail) ? detail->cy_valueint : 0,
(seq_no) ? seq_no->cy_valueint : -1,
+ show_rc, err_rc, false);
}
static int handle_yaml_show_stats(struct cYAML *tree, struct cYAML **show_rc,
}
static int handle_yaml_show_stats(struct cYAML *tree, struct cYAML **show_rc,
* seq_no - sequence number of the request
* show_rc - [OUT] The show output in YAML. Must be freed by caller.
* err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
* seq_no - sequence number of the request
* show_rc - [OUT] The show output in YAML. Must be freed by caller.
* err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
+ * backup - true to output only what's necessary for reconfiguring
+ * a node.
*/
int lustre_lnet_show_route(char *nw, char *gw,
int hops, int prio, int detail,
int seq_no, struct cYAML **show_rc,
*/
int lustre_lnet_show_route(char *nw, char *gw,
int hops, int prio, int detail,
int seq_no, struct cYAML **show_rc,
- struct cYAML **err_rc);
+ struct cYAML **err_rc, bool backup);
/*
* lustre_lnet_config_ni
/*
* lustre_lnet_config_ni
* seq_no - sequence number of the request
* show_rc - [OUT] The show output in YAML. Must be freed by caller.
* err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
* seq_no - sequence number of the request
* show_rc - [OUT] The show output in YAML. Must be freed by caller.
* err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
+ * backup - true to output only what's necessary for reconfiguring
+ * a node.
*/
int lustre_lnet_show_net(char *nw, int detail, int seq_no,
*/
int lustre_lnet_show_net(char *nw, int detail, int seq_no,
- struct cYAML **show_rc, struct cYAML **err_rc);
+ struct cYAML **show_rc, struct cYAML **err_rc,
+ bool backup);
/*
* lustre_lnet_enable_routing
/*
* lustre_lnet_enable_routing
* seq_no - sequence number of the request
* show_rc - [OUT] The show output in YAML. Must be freed by caller.
* err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
* seq_no - sequence number of the request
* show_rc - [OUT] The show output in YAML. Must be freed by caller.
* err_rc - [OUT] struct cYAML tree describing the error. Freed by caller
+ * backup - true to output only what's necessary for reconfiguring
+ * a node.
*/
int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
*/
int lustre_lnet_show_routing(int seq_no, struct cYAML **show_rc,
- struct cYAML **err_rc);
+ struct cYAML **err_rc, bool backup);
/*
* lustre_lnet_show_stats
/*
* lustre_lnet_show_stats
* seq_no - sequence number of the command
* show_rc - YAML structure of the resultant show
* err_rc - YAML strucutre of the resultant return code.
* seq_no - sequence number of the command
* show_rc - YAML structure of the resultant show
* err_rc - YAML strucutre of the resultant return code.
+ * backup - true to output only what's necessary for reconfiguring
+ * a node.
*
*/
int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
*
*/
int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
- struct cYAML **show_rc, struct cYAML **err_rc);
+ struct cYAML **show_rc, struct cYAML **err_rc,
+ bool backup);
/*
* lustre_lnet_list_peer
/*
* lustre_lnet_list_peer
__u32 net_type,
struct lnet_lnd_tunables *lnd)
{
__u32 net_type,
struct lnet_lnd_tunables *lnd)
{
- int rc = LUSTRE_CFG_RC_NO_ERR;
+ int rc = LUSTRE_CFG_RC_NO_MATCH;
if (net_type == O2IBLND)
rc = lustre_o2iblnd_show_tun(lnd_tunables,
if (net_type == O2IBLND)
rc = lustre_o2iblnd_show_tun(lnd_tunables,
}
rc = lustre_lnet_show_route(network, gateway, hop, prio, detail, -1,
}
rc = lustre_lnet_show_route(network, gateway, hop, prio, detail, -1,
+ &show_rc, &err_rc, false);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);
- rc = lustre_lnet_show_net(network, (int) detail, -1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_net(network, (int) detail, -1, &show_rc, &err_rc,
+ false);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);
- rc = lustre_lnet_show_routing(-1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_routing(-1, &show_rc, &err_rc, false);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);
int rc;
FILE *f = NULL;
int opt;
int rc;
FILE *f = NULL;
int opt;
+ bool backup = false;
+ char *file = NULL;
- const char *const short_options = "h";
+ const char *const short_options = "bh";
static const struct option long_options[] = {
static const struct option long_options[] = {
+ { .name = "backup", .has_arg = no_argument, .val = 'b' },
{ .name = "help", .has_arg = no_argument, .val = 'h' },
{ .name = NULL } };
while ((opt = getopt_long(argc, argv, short_options,
long_options, NULL)) != -1) {
switch (opt) {
{ .name = "help", .has_arg = no_argument, .val = 'h' },
{ .name = NULL } };
while ((opt = getopt_long(argc, argv, short_options,
long_options, NULL)) != -1) {
switch (opt) {
+ case 'b':
+ backup = true;
+ break;
printf("export > FILE.yaml : export configuration\n"
"\t--help: display this help\n");
return 0;
printf("export > FILE.yaml : export configuration\n"
"\t--help: display this help\n");
return 0;
- if (argc >= 2) {
- f = fopen(argv[1], "w");
+ if (backup && argc >= 3)
+ file = argv[2];
+ else if (!backup && argc >= 2)
+ file = argv[1];
+ else
+ f = stdout;
+
+ if (file) {
+ f = fopen(file, "w");
if (f == NULL)
return -1;
if (f == NULL)
return -1;
- rc = lustre_lnet_show_net(NULL, 2, -1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_net(NULL, 2, -1, &show_rc, &err_rc, backup);
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
cYAML_free_tree(err_rc);
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
cYAML_free_tree(err_rc);
}
rc = lustre_lnet_show_route(NULL, NULL, -1, -1, 1, -1, &show_rc,
}
rc = lustre_lnet_show_route(NULL, NULL, -1, -1, 1, -1, &show_rc,
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
cYAML_free_tree(err_rc);
err_rc = NULL;
}
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
cYAML_free_tree(err_rc);
err_rc = NULL;
}
- rc = lustre_lnet_show_routing(-1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_routing(-1, &show_rc, &err_rc, backup);
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
cYAML_free_tree(err_rc);
err_rc = NULL;
}
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
cYAML_free_tree(err_rc);
err_rc = NULL;
}
- rc = lustre_lnet_show_peer(NULL, 2, -1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_peer(NULL, 2, -1, &show_rc, &err_rc, backup);
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
cYAML_free_tree(err_rc);
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
cYAML_free_tree(err_rc);
- rc = lustre_lnet_show_peer(nid, (int) detail, -1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_peer(nid, (int) detail, -1, &show_rc, &err_rc,
+ false);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);