From df21a3b9eb01621de92940e441cd557913d1cd05 Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Tue, 24 Sep 2019 19:20:48 +0800 Subject: [PATCH] LU-12790 obdclass: print jobid error message properly Modify unlikely() condition to print error message properly when (rc == -EOVERFLOW). Signed-off-by: Emoly Liu Change-Id: I19bfb353c71b55a0dfb6eec78c1af915494acd71 Reviewed-on: https://review.whamcloud.com/36272 Tested-by: jenkins Reviewed-by: Andreas Dilger Reviewed-by: Ben Evans Tested-by: Maloo --- lustre/obdclass/jobid.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lustre/obdclass/jobid.c b/lustre/obdclass/jobid.c index 58f03b3..e1b5ff4 100644 --- a/lustre/obdclass/jobid.c +++ b/lustre/obdclass/jobid.c @@ -221,14 +221,13 @@ static void jobid_prune_expedite(void) */ 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, @@ -236,16 +235,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: -- 1.8.3.1