Whamcloud - gitweb
LU-12790 obdclass: print jobid error message properly 78/36378/2
authorEmoly Liu <emoly@whamcloud.com>
Tue, 24 Sep 2019 11:20:48 +0000 (19:20 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Oct 2019 13:25:57 +0000 (13:25 +0000)
Modify unlikely() condition to print error message properly when
(rc == -EOVERFLOW).

Lustre-change: https://review.whamcloud.com/36272
Lustre-commit: df21a3b9eb01621de92940e441cd557913d1cd05

Signed-off-by: Emoly Liu <emoly@whamcloud.com>
Change-Id: I19bfb353c71b55a0dfb6eec78c1af915494acd71
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Ben Evans <bevans@cray.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/36378
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/obdclass/jobid.c

index 7aba58e..b7a08d4 100644 (file)
@@ -76,14 +76,13 @@ struct jobid_pid_map {
  */
 int jobid_get_from_environ(char *jobid_var, char *jobid, int *jobid_len)
 {
-       static bool printed;
        int rc;
 
        rc = cfs_get_environ(jobid_var, jobid, jobid_len);
        if (!rc)
                goto out;
 
-       if (unlikely(rc == -EOVERFLOW && !printed)) {
+       if (rc == -EOVERFLOW) {
                /* For the PBS_JOBID and LOADL_STEP_ID keys (which are
                 * variable length strings instead of just numbers), it
                 * might make sense to keep the unique parts for JobID,
@@ -91,16 +90,23 @@ int jobid_get_from_environ(char *jobid_var, char *jobid, int *jobid_len)
                 * larger temp buffer for cfs_get_environ(), then
                 * truncating the string at some separator to fit into
                 * the specified jobid_len.  Fix later if needed. */
-               LCONSOLE_WARN("jobid: '%s' value too large (%d)\n",
-                             obd_jobid_var, *jobid_len);
-               printed = true;
+               static ktime_t printed;
+
+               if (unlikely(ktime_to_ns(printed) == 0 ||
+                            ktime_after(ktime_get(),
+                                        ktime_add_ns(printed,
+                                                     3600*24*NSEC_PER_SEC)))) {
+                       LCONSOLE_WARN("jobid: '%s' value too large (%d)\n",
+                                     obd_jobid_var, *jobid_len);
+                       printed = ktime_get();
+               }
+
                rc = 0;
-       }
-       if (rc) {
-               CDEBUG((rc == -ENOENT || rc == -EINVAL ||
-                       rc == -EDEADLK) ? D_INFO : D_ERROR,
-                      "jobid: get '%s' failed: rc = %d\n",
-                      obd_jobid_var, rc);
+       } else {
+               CDEBUG_LIMIT((rc == -ENOENT || rc == -EINVAL ||
+                             rc == -EDEADLK) ? D_INFO : D_ERROR,
+                            "jobid: get '%s' failed: rc = %d\n",
+                            obd_jobid_var, rc);
        }
 
 out: