From a00b7d1f74a76eca2371f8559358ead64da19768 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Thu, 20 Jan 2011 16:59:32 +0000
Subject: [PATCH] make sure all blocks are removed from all lists when freeing
 the block

---
 src/plugins/select/bluegene/plugin/bluegene.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/plugins/select/bluegene/plugin/bluegene.c b/src/plugins/select/bluegene/plugin/bluegene.c
index 91af9df1071..9c882be20a3 100644
--- a/src/plugins/select/bluegene/plugin/bluegene.c
+++ b/src/plugins/select/bluegene/plugin/bluegene.c
@@ -1603,6 +1603,24 @@ static int _post_block_free(bg_record_t *bg_record, bool restore)
 		return SLURM_SUCCESS;
 	}
 
+	/* A bit of a sanity check to make sure blocks are being
+	   removed out of all the lists.
+	*/
+	if (blocks_are_created) {
+		if (remove_from_bg_list(bg_lists->booted, bg_record)
+		    == SLURM_SUCCESS)
+			error("block %s is being freed but hadn't been "
+			      "removed from the booted block list yet.",
+			      bg_record->bg_block_id);
+		if (remove_from_bg_list(bg_lists->job_running, bg_record)
+		    == SLURM_SUCCESS) {
+			num_unused_cpus += bg_record->cpu_cnt;
+			error("block %s is being freed but hadn't been "
+			      "removed from the running job block list yet.",
+			      bg_record->bg_block_id);
+		}
+	}
+
 	if (restore)
 		return SLURM_SUCCESS;
 
-- 
GitLab