Whamcloud - gitweb
LU-11468 lnet: set recovery interval from lnetctl
[fs/lustre-release.git] / lnet / utils / lnetconfig / liblnetconfig.c
index 4978c42..a194ce0 100644 (file)
@@ -2529,6 +2529,28 @@ int ioctl_set_value(__u32 val, int ioc, char *name,
        return rc;
 }
 
+int lustre_lnet_config_recov_intrv(int intrv, int seq_no, struct cYAML **err_rc)
+{
+       int rc = LUSTRE_CFG_RC_NO_ERR;
+       char err_str[LNET_MAX_STR_LEN];
+       char val[LNET_MAX_STR_LEN];
+
+       snprintf(err_str, sizeof(err_str), "\"success\"");
+
+       snprintf(val, sizeof(val), "%d", intrv);
+
+       rc = write_sysfs_file(modparam_path, "lnet_recovery_interval", val,
+                             1, strlen(val) + 1);
+       if (rc)
+               snprintf(err_str, sizeof(err_str),
+                        "\"cannot configure recovery interval: %s\"",
+                        strerror(errno));
+
+       cYAML_build_error(rc, seq_no, ADD_CMD, "recovery_interval", err_str, err_rc);
+
+       return rc;
+}
+
 int lustre_lnet_config_hsensitivity(int sen, int seq_no, struct cYAML **err_rc)
 {
        int rc = LUSTRE_CFG_RC_NO_ERR;
@@ -3382,6 +3404,31 @@ static int ioctl_show_global_values(int ioc, int seq_no, char *name,
                                       data.sv_value, show_rc, err_rc, l_errno);
 }
 
+int lustre_lnet_show_recov_intrv(int seq_no, struct cYAML **show_rc,
+                                struct cYAML **err_rc)
+{
+       int rc = LUSTRE_CFG_RC_OUT_OF_MEM;
+       char val[LNET_MAX_STR_LEN];
+       int intrv = -1, l_errno = 0;
+       char err_str[LNET_MAX_STR_LEN];
+
+       snprintf(err_str, sizeof(err_str), "\"out of memory\"");
+
+       rc = read_sysfs_file(modparam_path, "lnet_recovery_interval", val,
+                            1, sizeof(val));
+       if (rc) {
+               l_errno = -errno;
+               snprintf(err_str, sizeof(err_str),
+                        "\"cannot get recovery interval: %d\"", rc);
+       } else {
+               intrv = atoi(val);
+       }
+
+       return build_global_yaml_entry(err_str, sizeof(err_str), seq_no,
+                                      "recovery_interval", intrv, show_rc,
+                                      err_rc, l_errno);
+}
+
 int lustre_lnet_show_hsensitivity(int seq_no, struct cYAML **show_rc,
                                  struct cYAML **err_rc)
 {
@@ -3476,6 +3523,9 @@ int show_recovery_queue(enum lnet_health_type type, char *name, int seq_no,
                goto out;
        }
 
+       if (nid_list.rlst_num_nids == 0)
+               goto out;
+
        root = cYAML_create_object(NULL, NULL);
        if (root == NULL)
                goto out;
@@ -4509,7 +4559,7 @@ static int handle_yaml_config_global_settings(struct cYAML *tree,
                                              struct cYAML **err_rc)
 {
        struct cYAML *max_intf, *numa, *discovery, *retry, *tto, *seq_no,
-                    *sen;
+                    *sen, *recov;
        int rc = 0;
 
        seq_no = cYAML_get_object_item(tree, "seq_no");
@@ -4555,6 +4605,13 @@ static int handle_yaml_config_global_settings(struct cYAML *tree,
                                                        : -1,
                                                     err_rc);
 
+       recov = cYAML_get_object_item(tree, "recovery_interval");
+       if (recov)
+               rc = lustre_lnet_config_recov_intrv(recov->cy_valueint,
+                                                   seq_no ? seq_no->cy_valueint
+                                                       : -1,
+                                                   err_rc);
+
        return rc;
 }
 
@@ -4596,7 +4653,7 @@ static int handle_yaml_show_global_settings(struct cYAML *tree,
                                            struct cYAML **err_rc)
 {
        struct cYAML *max_intf, *numa, *discovery, *retry, *tto, *seq_no,
-                    *sen;
+                    *sen, *recov;
        int rc = 0;
 
        seq_no = cYAML_get_object_item(tree, "seq_no");
@@ -4636,6 +4693,12 @@ static int handle_yaml_show_global_settings(struct cYAML *tree,
                                                        : -1,
                                                     show_rc, err_rc);
 
+       recov = cYAML_get_object_item(tree, "recovery_interval");
+       if (recov)
+               rc = lustre_lnet_show_recov_intrv(seq_no ? seq_no->cy_valueint
+                                                       : -1,
+                                                 show_rc, err_rc);
+
        return rc;
 }