From 16e9399d4f588c98ce2a2a2005e1e51b4fbe7fa4 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Mon, 21 Sep 2015 09:52:38 -0700
Subject: [PATCH] Addition to last commit b404c3af5d6 to do the same thing for
 removing.

Also a very minor sanity check in job_mgr.c to make sure we at least have
a task count.  This shouldn't matter, but just to be as robust as possible.
---
 src/slurmctld/acct_policy.c | 6 +++---
 src/slurmctld/job_mgr.c     | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/slurmctld/acct_policy.c b/src/slurmctld/acct_policy.c
index ab447b77449..8294d53d945 100644
--- a/src/slurmctld/acct_policy.c
+++ b/src/slurmctld/acct_policy.c
@@ -187,14 +187,14 @@ static void _adjust_limit_usage(int type, struct job_record *job_ptr)
 			break;
 		case ACCT_POLICY_REM_SUBMIT:
 			if (qos_ptr->usage->grp_used_submit_jobs)
-				qos_ptr->usage->grp_used_submit_jobs--;
+				qos_ptr->usage->grp_used_submit_jobs -= job_cnt;
 			else
 				debug2("acct_policy_remove_job_submit: "
 				       "grp_submit_jobs underflow for qos %s",
 				       qos_ptr->name);
 
 			if (used_limits->submit_jobs)
-				used_limits->submit_jobs--;
+				used_limits->submit_jobs -= job_cnt;
 			else
 				debug2("acct_policy_remove_job_submit: "
 				       "used_submit_jobs underflow for "
@@ -283,7 +283,7 @@ static void _adjust_limit_usage(int type, struct job_record *job_ptr)
 			break;
 		case ACCT_POLICY_REM_SUBMIT:
 			if (assoc_ptr->usage->used_submit_jobs)
-				assoc_ptr->usage->used_submit_jobs--;
+				assoc_ptr->usage->used_submit_jobs -= job_cnt;
 			else
 				debug2("acct_policy_remove_job_submit: "
 				       "used_submit_jobs underflow for "
diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c
index 5acb40216d1..9853a8ee229 100644
--- a/src/slurmctld/job_mgr.c
+++ b/src/slurmctld/job_mgr.c
@@ -3912,7 +3912,7 @@ extern int job_allocate(job_desc_msg_t * job_specs, int immediate,
 	_create_job_array(job_ptr, job_specs);
 
 	slurmctld_diag_stats.jobs_submitted +=
-		job_ptr->array_recs ?
+		(job_ptr->array_recs && job_ptr->array_recs->task_cnt) ?
 		job_ptr->array_recs->task_cnt : 1;
 
 	acct_policy_add_job_submit(job_ptr);
-- 
GitLab