Whamcloud - gitweb
LU-8178 lproc: fix negative recovery_duration
[fs/lustre-release.git] / lustre / obdclass / lprocfs_status_server.c
index 6bb6c27..2790deb 100644 (file)
@@ -578,7 +578,9 @@ int lprocfs_recovery_status_seq_show(struct seq_file *m, void *data)
                seq_printf(m, "COMPLETE\n");
                seq_printf(m, "recovery_start: %lu\n", obd->obd_recovery_start);
                seq_printf(m, "recovery_duration: %lu\n",
-                          obd->obd_recovery_end - obd->obd_recovery_start);
+                          obd->obd_recovery_end ?
+                          obd->obd_recovery_end - obd->obd_recovery_start :
+                          cfs_time_current_sec() - obd->obd_recovery_start);
                /* Number of clients that have completed recovery */
                seq_printf(m, "completed_clients: %d/%d\n",
                           obd->obd_max_recoverable_clients -
@@ -642,10 +644,11 @@ lprocfs_ir_factor_seq_write(struct file *file, const char __user *buffer,
 {
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
-       int val, rc;
+       int rc;
+       __s64 val;
 
        LASSERT(obd != NULL);
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = lprocfs_str_to_s64(buffer, count, &val);
        if (rc)
                return rc;
 
@@ -674,12 +677,15 @@ lprocfs_recovery_time_soft_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
-       int val, rc;
+       int rc;
+       __s64 val;
 
        LASSERT(obd != NULL);
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = lprocfs_str_to_s64(buffer, count, &val);
        if (rc)
                return rc;
+       if (val < 0 || val > INT_MAX)
+               return -ERANGE;
 
        obd->obd_recovery_timeout = val;
        return count;
@@ -703,12 +709,15 @@ lprocfs_recovery_time_hard_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
-       int val, rc;
+       int rc;
+       __s64 val;
 
        LASSERT(obd != NULL);
-       rc = lprocfs_write_helper(buffer, count, &val);
+       rc = lprocfs_str_to_s64(buffer, count, &val);
        if (rc)
                return rc;
+       if (val < 0 || val > INT_MAX)
+               return -ERANGE;
 
        obd->obd_recovery_time_hard = val;
        return count;