Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LU-8926 llite: reduce jobstats race window
[fs/lustre-release.git]
/
lustre
/
obdclass
/
class_obd.c
diff --git
a/lustre/obdclass/class_obd.c
b/lustre/obdclass/class_obd.c
index
293b559
..
cf38cde
100644
(file)
--- a/
lustre/obdclass/class_obd.c
+++ b/
lustre/obdclass/class_obd.c
@@
-126,29
+126,29
@@
char obd_jobid_node[LUSTRE_JOBID_SIZE + 1];
int lustre_get_jobid(char *jobid)
{
int jobid_len = LUSTRE_JOBID_SIZE;
int lustre_get_jobid(char *jobid)
{
int jobid_len = LUSTRE_JOBID_SIZE;
+ char tmp_jobid[LUSTRE_JOBID_SIZE] = { 0 };
int rc = 0;
ENTRY;
int rc = 0;
ENTRY;
- memset(jobid, 0, LUSTRE_JOBID_SIZE);
/* Jobstats isn't enabled */
if (strcmp(obd_jobid_var, JOBSTATS_DISABLE) == 0)
/* Jobstats isn't enabled */
if (strcmp(obd_jobid_var, JOBSTATS_DISABLE) == 0)
-
RETURN(
0);
+
GOTO(out, rc =
0);
/* Whole node dedicated to single job */
if (strcmp(obd_jobid_var, JOBSTATS_NODELOCAL) == 0) {
/* Whole node dedicated to single job */
if (strcmp(obd_jobid_var, JOBSTATS_NODELOCAL) == 0) {
- memcpy(jobid, obd_jobid_node, LUSTRE_JOBID_SIZE);
-
RETURN(
0);
+ memcpy(
tmp_
jobid, obd_jobid_node, LUSTRE_JOBID_SIZE);
+
GOTO(out, rc =
0);
}
/* Use process name + fsuid as jobid */
if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) {
}
/* Use process name + fsuid as jobid */
if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) {
- snprintf(jobid, LUSTRE_JOBID_SIZE, "%s.%u",
+ snprintf(
tmp_
jobid, LUSTRE_JOBID_SIZE, "%s.%u",
current_comm(),
from_kuid(&init_user_ns, current_fsuid()));
current_comm(),
from_kuid(&init_user_ns, current_fsuid()));
-
RETURN(
0);
+
GOTO(out, rc =
0);
}
}
- rc = cfs_get_environ(obd_jobid_var, jobid, &jobid_len);
+ rc = cfs_get_environ(obd_jobid_var,
tmp_
jobid, &jobid_len);
if (rc) {
if (rc == -EOVERFLOW) {
/* For the PBS_JOBID and LOADL_STEP_ID keys (which are
if (rc) {
if (rc == -EOVERFLOW) {
/* For the PBS_JOBID and LOADL_STEP_ID keys (which are
@@
-172,7
+172,16
@@
int lustre_get_jobid(char *jobid)
obd_jobid_var, rc);
}
}
obd_jobid_var, rc);
}
}
- RETURN(rc);
+
+out:
+ if (rc != 0)
+ RETURN(rc);
+
+ /* Only replace the job ID if it changed. */
+ if (strcmp(jobid, tmp_jobid) != 0)
+ memcpy(jobid, tmp_jobid, jobid_len);
+
+ RETURN(0);
}
EXPORT_SYMBOL(lustre_get_jobid);
}
EXPORT_SYMBOL(lustre_get_jobid);