From 451f462ba5527631ec7714f8dfbf83ff692d1213 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Wed, 1 May 2013 11:57:30 -0700
Subject: [PATCH] Accounting - fix for packing tasks instead of packing cpus. 
 It used to be we used cpus erroneously but now we use tasks.  The cpus
 variable will be taken out in 2.6.

---
 src/common/slurmdbd_defs.c                    |  4 +--
 .../slurmdbd/accounting_storage_slurmdbd.c    | 28 +++++++++----------
 src/slurmdbd/proc_req.c                       |  1 -
 3 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/src/common/slurmdbd_defs.c b/src/common/slurmdbd_defs.c
index ec1c24f25e9..c027dd0b140 100644
--- a/src/common/slurmdbd_defs.c
+++ b/src/common/slurmdbd_defs.c
@@ -3814,7 +3814,7 @@ slurmdbd_pack_step_complete_msg(dbd_step_comp_msg_t *msg,
 	pack_time(msg->start_time, buffer);
 	pack_time(msg->job_submit_time, buffer);
 	pack32(msg->step_id, buffer);
-	pack32(msg->total_cpus, buffer);
+	pack32(msg->total_tasks, buffer);
 }
 
 extern int
@@ -3834,7 +3834,7 @@ slurmdbd_unpack_step_complete_msg(dbd_step_comp_msg_t **msg,
 	safe_unpack_time(&msg_ptr->start_time, buffer);
 	safe_unpack_time(&msg_ptr->job_submit_time, buffer);
 	safe_unpack32(&msg_ptr->step_id, buffer);
-	safe_unpack32(&msg_ptr->total_cpus, buffer);
+	safe_unpack32(&msg_ptr->total_tasks, buffer);
 	return SLURM_SUCCESS;
 
 unpack_error:
diff --git a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c
index c69bb40e226..7b17bf90dc0 100644
--- a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c
+++ b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c
@@ -2246,26 +2246,25 @@ extern int jobacct_storage_p_step_start(void *db_conn,
 extern int jobacct_storage_p_step_complete(void *db_conn,
 					   struct step_record *step_ptr)
 {
-	uint32_t cpus = 0, tasks = 0;
+	uint32_t tasks = 0;
 	slurmdbd_msg_t msg;
 	dbd_step_comp_msg_t req;
 
+	if (step_ptr->step_id == SLURM_BATCH_SCRIPT)
+		tasks = 1;
+	else {
 #ifdef HAVE_BG_L_P
-	if (step_ptr->job_ptr->details)
-		tasks = cpus = step_ptr->job_ptr->details->min_cpus;
-	else
-		tasks = cpus = step_ptr->job_ptr->cpu_cnt;
+		if (step_ptr->job_ptr->details)
+			tasks = step_ptr->job_ptr->details->min_cpus;
+		else
+			tasks = step_ptr->job_ptr->cpu_cnt;
 #else
-	if (!step_ptr->step_layout || !step_ptr->step_layout->task_cnt) {
-		cpus = tasks = step_ptr->job_ptr->total_cpus;
-	} else {
-		cpus = step_ptr->cpu_count;
-		tasks = step_ptr->step_layout->task_cnt;
-	}
+		if (!step_ptr->step_layout || !step_ptr->step_layout->task_cnt)
+			tasks = step_ptr->job_ptr->total_cpus;
+		else
+			tasks = step_ptr->step_layout->task_cnt;
 #endif
-
-	if (step_ptr->step_id == SLURM_BATCH_SCRIPT)
-		cpus = tasks = 1;
+	}
 
 	if (!step_ptr->job_ptr->db_index
 	    && ((!step_ptr->job_ptr->details
@@ -2295,7 +2294,6 @@ extern int jobacct_storage_p_step_complete(void *db_conn,
 	else if (step_ptr->job_ptr->details)
 		req.job_submit_time   = step_ptr->job_ptr->details->submit_time;
 	req.step_id     = step_ptr->step_id;
-	req.total_cpus = cpus;
 	req.total_tasks = tasks;
 
 	msg.msg_type    = DBD_STEP_COMPLETE;
diff --git a/src/slurmdbd/proc_req.c b/src/slurmdbd/proc_req.c
index 3a04453ea94..c83383c7527 100644
--- a/src/slurmdbd/proc_req.c
+++ b/src/slurmdbd/proc_req.c
@@ -3504,7 +3504,6 @@ static int  _step_complete(slurmdbd_conn_t *slurmdbd_conn,
 	job.start_time = step_comp_msg->start_time;
 	details.submit_time = step_comp_msg->job_submit_time;
 	step.step_id = step_comp_msg->step_id;
-	step.cpu_count = step_comp_msg->total_cpus;
 	details.num_tasks = step_comp_msg->total_tasks;
 
 	job.details = &details;
-- 
GitLab