From 6eb7ccfe00a40f9b23a235c3ea9c265b342fe2b6 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Tue, 28 May 2002 23:56:31 +0000
Subject: [PATCH] Changed job_id to 32 bits per DPCS requirement. Jobs without
 job_id specified at submit time start with a value of 1<<16 and DPCS uses
 values 1 to 0xffffffff. This preclude effective use of a max job_id in search
 function, which was able to quickly indicate that a job_id requested by DPCS
 was not already in use. I added a job_id hash table to restore quick job find
 operations.

---
 src/api/allocate.c |  9 ++++-----
 src/api/cancel.c   |  4 ++--
 src/api/job_info.c |  2 +-
 src/api/slurm.h    | 14 ++++++--------
 src/api/submit.c   |  6 +++---
 5 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/src/api/allocate.c b/src/api/allocate.c
index f30feb28790..75966c4c3b0 100644
--- a/src/api/allocate.c
+++ b/src/api/allocate.c
@@ -30,7 +30,7 @@ main (int argc, char *argv[])
 {
 	int error_code;
 	char *node_list;
-	uint16_t job_id;
+	uint32_t job_id;
 
 	error_code = slurm_allocate
 		("User=1500 JobName=job01 TotalNodes=400 TotalProcs=1000 ReqNodes=lx[3000-3003] Partition=batch MinRealMemory=1024 MinTmpDisk=2034 Groups=students,employee MinProcs=4 Contiguous=YES Key=1234",
@@ -94,7 +94,7 @@ main (int argc, char *argv[])
  * NOTE: the calling function must free the allocated storage at node_list[0]
  */
 int
-slurm_allocate (char *spec, char **node_list, uint16_t *job_id) 
+slurm_allocate (char *spec, char **node_list, uint32_t *job_id) 
 {
 	int buffer_offset, buffer_size, in_size;
 	char *request_msg, *buffer, *job_id_ptr;
@@ -161,9 +161,8 @@ slurm_allocate (char *spec, char **node_list, uint16_t *job_id)
 		return EINVAL;
 	}
 	job_id_ptr = strchr(buffer, (int) ' ');
-	if (job_id_ptr != NULL) {
-		*job_id = (uint16_t) atoi (&job_id_ptr[1]);
-	}
+	if (job_id_ptr != NULL) 
+		*job_id = (uint32_t) strtol (&job_id_ptr[1], (char **)NULL, 10);
 	node_list[0] = buffer;
 	return 0;
 }
diff --git a/src/api/cancel.c b/src/api/cancel.c
index 79e7ee4c7f6..8c241e21799 100644
--- a/src/api/cancel.c
+++ b/src/api/cancel.c
@@ -36,7 +36,7 @@ main (int argc, char *argv[])
 	}
 
 	for (i=1; i<argc; i++) {
-		error_code = slurm_cancel ((uint16_t) atoi(argv[i]));
+		error_code = slurm_cancel ((uint32_t) atoi(argv[i]));
 		if (error_code != 0)
 			printf ("slurm_cancel error %d for job %s\n", 
 				error_code, argv[i]);
@@ -54,7 +54,7 @@ main (int argc, char *argv[])
  *			EAGAIN if the request can not be satisfied at present
  */
 int
-slurm_cancel (uint16_t job_id) 
+slurm_cancel (uint32_t job_id) 
 {
 	int buffer_offset, buffer_size, in_size;
 	char *request_msg, *buffer, id_str[20];
diff --git a/src/api/job_info.c b/src/api/job_info.c
index 96a91d2b5ba..06b646cfcf2 100644
--- a/src/api/job_info.c
+++ b/src/api/job_info.c
@@ -213,7 +213,7 @@ slurm_load_job (time_t update_time, struct job_buffer **job_buffer_ptr)
 			free (buffer);
 			return ENOMEM;
 		}
-		unpack16  (&job[i].job_id, &buf_ptr, &buffer_size);
+		unpack32  (&job[i].job_id, &buf_ptr, &buffer_size);
 		unpack32  (&job[i].user_id, &buf_ptr, &buffer_size);
 		unpack16  (&job[i].job_state, &buf_ptr, &buffer_size);
 		unpack32  (&job[i].time_limit, &buf_ptr, &buffer_size);
diff --git a/src/api/slurm.h b/src/api/slurm.h
index 234629d8efa..4f68997a9b4 100644
--- a/src/api/slurm.h
+++ b/src/api/slurm.h
@@ -84,7 +84,7 @@ struct build_buffer {
 };
 
 struct job_table {
-	uint16_t job_id;	/* job ID */
+	uint32_t job_id;	/* job ID */
 	char *name;		/* name of the job */
 	uint32_t user_id;	/* user the job runs as */
 	uint16_t job_state;	/* state of the job, see enum job_states */
@@ -176,7 +176,7 @@ struct part_buffer {
  *	TotalProcs=<count>
  * NOTE: the calling function must free the allocated storage at node_list[0]
  */
-extern int slurm_allocate (char *spec, char **node_list, uint16_t *job_id);
+extern int slurm_allocate (char *spec, char **node_list, uint32_t *job_id);
 
 /*
  * slurm_cancel - cancel the specified job 
@@ -184,7 +184,7 @@ extern int slurm_allocate (char *spec, char **node_list, uint16_t *job_id);
  * output: returns 0 if no error, EINVAL if the request is invalid, 
  *			EAGAIN if the request can not be satisfied at present
  */
-extern int slurm_cancel (uint16_t job_id);
+extern int slurm_cancel (uint32_t job_id);
 
 /*
  * slurm_free_build_info - free the build information buffer (if allocated)
@@ -284,17 +284,15 @@ extern int slurm_load_part (time_t update_time, struct part_buffer **part_buffer
  *	Shared=<YES|NO> TimeLimit=<minutes> TotalNodes=<count>
  *	TotalProcs=<count> Immediate=<YES|NO>
  */
-extern int slurm_submit (char *spec, uint16_t *job_id);
+extern int slurm_submit (char *spec, uint32_t *job_id);
 
 /*
  * slurm_will_run - determine if a job would execute immediately 
  *	if submitted. 
  * input: spec - specification of the job's constraints
- *	job_id - place to store id of submitted job
  * output: returns 0 if job would run now, EINVAL if the request 
  *		would never run, EAGAIN if job would run later
- * NOTE: required specification include: Script=<script_path_name>
- *	User=<uid>
+ * NOTE: required specification include: User=<uid>
  * NOTE: optional specifications include: Contiguous=<YES|NO> 
  *	Features=<features> Groups=<groups>
  *	Key=<key> MinProcs=<count> 
@@ -303,7 +301,7 @@ extern int slurm_submit (char *spec, uint16_t *job_id);
  *	Shared=<YES|NO> TimeLimit=<minutes> TotalNodes=<count>
  *	TotalProcs=<count>
  */
-extern int slurm_will_run (char *spec, uint16_t *job_id);
+extern int slurm_will_run (char *spec);
 
 /* 
  * parse_node_name - parse the node name for regular expressions and return a sprintf format 
diff --git a/src/api/submit.c b/src/api/submit.c
index 0722513a3f5..7c29d9447fd 100644
--- a/src/api/submit.c
+++ b/src/api/submit.c
@@ -29,7 +29,7 @@ int
 main (int argc, char *argv[]) 
 {
 	int error_code, i, count;
-	uint16_t job_id;
+	uint32_t job_id;
 
 	error_code = slurm_submit
 		("User=1500 Script=/bin/hostname JobName=job01 TotalNodes=400 TotalProcs=1000 ReqNodes=lx[3000-3003] Partition=batch MinRealMemory=1024 MinTmpDisk=2034 Groups=students,employee MinProcs=4 Contiguous=YES Key=1234",
@@ -81,7 +81,7 @@ main (int argc, char *argv[])
  *	TotalProcs=<count> Immediate=<YES|NO>
  */
 int
-slurm_submit (char *spec, uint16_t *job_id)
+slurm_submit (char *spec, uint32_t *job_id)
 {
 	int buffer_offset, buffer_size, in_size;
 	char *request_msg, *buffer;
@@ -146,6 +146,6 @@ slurm_submit (char *spec, uint16_t *job_id)
 		free (buffer);
 		return EINVAL;
 	}
-	*job_id = (uint16_t) atoi (buffer);
+	*job_id = (uint32_t) strtol (buffer, (char **)NULL, 10);
 	return 0;
 }
-- 
GitLab