[lustre-devel] [PATCH 7/9] lustre: obdclass: add option %H for jobid
James Simmons
jsimmons at infradead.org
Mon Feb 8 16:54:25 PST 2021
From: Yang Sheng <ys at whamcloud.com>
Add a option %H to avoid jobid too long in some cases.
WC-bug-id: https://jira.whamcloud.com/browse/LU-14339
Lustre-commit: cf72ee174bbf7e6 ("LU-14339 obdclass: add option %H for jobid")
Signed-off-by: Yang Sheng <ys at whamcloud.com>
Reviewed-on: https://review.whamcloud.com/41262
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Jian Yu <yujian at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
fs/lustre/obdclass/jobid.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/fs/lustre/obdclass/jobid.c b/fs/lustre/obdclass/jobid.c
index 3ee9d40..52ba398 100644
--- a/fs/lustre/obdclass/jobid.c
+++ b/fs/lustre/obdclass/jobid.c
@@ -206,6 +206,7 @@ static void jobid_prune_expedite(void)
* %e = executable
* %g = gid
* %h = hostname
+ * %H = short hostname
* %j = per-session
* %p = pid
* %u = uid
@@ -222,7 +223,7 @@ static int jobid_interpret_string(const char *jobfmt, char *jobid,
char c;
while ((c = *jobfmt++) && joblen > 1) {
- char f;
+ char f, *p;
int l;
if (isspace(c)) /* Don't allow embedded spaces */
@@ -232,6 +233,7 @@ static int jobid_interpret_string(const char *jobfmt, char *jobid,
*jobid = c;
joblen--;
jobid++;
+ *jobid = '\0';
continue;
}
@@ -247,6 +249,15 @@ static int jobid_interpret_string(const char *jobfmt, char *jobid,
l = snprintf(jobid, joblen, "%s",
init_utsname()->nodename);
break;
+ case 'H': /* short hostname. Cut at first dot */
+ l = snprintf(jobid, joblen, "%s",
+ init_utsname()->nodename);
+ p = strnchr(jobid, joblen, '.');
+ if (p) {
+ *p = '\0';
+ l = p - jobid;
+ }
+ break;
case 'j': /* jobid requested by process */
l = snprintf(jobid, joblen, "%s",
jobid_current() ?: "jobid");
--
1.8.3.1
More information about the lustre-devel
mailing list