From abdbdd595d74e47157cfad0e2e1a849422b0df46 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Wed, 22 Jan 2014 11:57:31 -0800
Subject: [PATCH] Better logic to get the select_nodes_avail bitmap to work
 correctly.

---
 src/slurmctld/step_mgr.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/slurmctld/step_mgr.c b/src/slurmctld/step_mgr.c
index aaff8cefbe2..5c69b60abf0 100644
--- a/src/slurmctld/step_mgr.c
+++ b/src/slurmctld/step_mgr.c
@@ -1035,6 +1035,10 @@ _pick_step_nodes (struct job_record  *job_ptr,
 				bit_clear(nodes_avail, i);
 				bit_set(non_selected_nodes, i);
 				non_selected_tasks[i] = avail_tasks;
+			} else if (select_nodes_avail &&
+				   !bit_test(select_nodes_avail, i)) {
+				/* Select does not want you to use this */
+				bit_clear(nodes_avail, i);
 			} else {
 				nodes_picked_cnt++;
 				tasks_picked_cnt += avail_tasks;
@@ -1187,6 +1191,14 @@ _pick_step_nodes (struct job_record  *job_ptr,
 		return nodes_avail;
 	}
 
+	if (select_nodes_avail) {
+		/* The select plugin told us these were the
+		 * only ones we could choose from.  If it
+		 * doesn't fit here then defer request */
+		bit_and(nodes_avail, select_nodes_avail);
+		FREE_NULL_BITMAP(select_nodes_avail);
+	}
+
 	if (step_spec->node_list) {
 		bitstr_t *selected_nodes = NULL;
 		if (slurmctld_conf.debug_flags & DEBUG_FLAG_STEPS)
@@ -1521,19 +1533,6 @@ _pick_step_nodes (struct job_record  *job_ptr,
 		}
 	}
 
-	if (select_nodes_avail) {
-		/* The select plugin told us these were the
-		 * only ones we could choose from.  If it
-		 * doesn't fit here then defer request */
-		if (!bit_super_set(nodes_picked, select_nodes_avail)) {
-			*return_code = ESLURM_NODES_BUSY;
-			debug2("select plugin told us the nodes "
-			       "picked weren't all available");
-			goto cleanup;
-		}
-		FREE_NULL_BITMAP(select_nodes_avail);
-	}
-
 	FREE_NULL_BITMAP(nodes_avail);
 	FREE_NULL_BITMAP(select_nodes_avail);
 	FREE_NULL_BITMAP(nodes_idle);
-- 
GitLab