From 36a9b684472b6f4148cc1e135434f20b07ecfcae Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Mon, 28 Dec 2015 17:00:53 -0800
Subject: [PATCH] burst_buffer/cray: Remove vestitial GRES variables

---
 slurm/slurm.h.in                              |  2 -
 src/api/burst_buffer_info.c                   | 14 ------
 src/common/slurm_protocol_defs.c              | 14 +-----
 src/common/slurm_protocol_pack.c              | 29 +++----------
 .../burst_buffer/common/burst_buffer_common.c | 43 +++----------------
 .../burst_buffer/common/burst_buffer_common.h |  4 --
 src/sview/bb_info.c                           | 43 ++++++-------------
 7 files changed, 27 insertions(+), 122 deletions(-)

diff --git a/slurm/slurm.h.in b/slurm/slurm.h.in
index bff85496a19..89b57b71167 100644
--- a/slurm/slurm.h.in
+++ b/slurm/slurm.h.in
@@ -4727,8 +4727,6 @@ typedef struct {
 	uint32_t array_job_id;
 	uint32_t array_task_id;
 	time_t create_time;	/* Time of creation */
-	uint32_t gres_cnt;	/* Count of records in gres_ptr */
-	burst_buffer_gres_t *gres_ptr;
 	uint32_t job_id;
 	char *name;		/* Name of persistent burst buffer */
 	char *partition;	/* Associated partition (for limits) */
diff --git a/src/api/burst_buffer_info.c b/src/api/burst_buffer_info.c
index c295767ab8c..3554eddf853 100644
--- a/src/api/burst_buffer_info.c
+++ b/src/api/burst_buffer_info.c
@@ -166,7 +166,6 @@ static void _print_burst_buffer_resv(FILE *out,
 {
 	char sz_buf[32], time_buf[64], tmp_line[512];
 	char *out_buf = NULL;
-	int i;
 
 	/****** Line 1 ******/
 	if (burst_buffer_ptr->job_id &&
@@ -212,19 +211,6 @@ static void _print_burst_buffer_resv(FILE *out,
 	}
 	xstrcat(out_buf, tmp_line);
 
-	/* Gres includes "nodes" on Cray systems */
-	for (i = 0; i < burst_buffer_ptr->gres_cnt; i++) {
-		if (i == 0)
-			xstrcat(out_buf, " Gres=");
-		else
-			xstrcat(out_buf, ",");
-		_get_size_str(sz_buf, sizeof(sz_buf),
-			      burst_buffer_ptr->gres_ptr[i].used_cnt);
-		snprintf(tmp_line, sizeof(tmp_line), "%s:%s",
-			 burst_buffer_ptr->gres_ptr[i].name, sz_buf);
-		xstrcat(out_buf, tmp_line);
-	}
-
 	xstrcat(out_buf, "\n");
 	fprintf(out, "%s", out_buf);
 	xfree(out_buf);
diff --git a/src/common/slurm_protocol_defs.c b/src/common/slurm_protocol_defs.c
index 01a6a98411e..da93906fb56 100644
--- a/src/common/slurm_protocol_defs.c
+++ b/src/common/slurm_protocol_defs.c
@@ -3207,8 +3207,7 @@ extern void slurm_free_topo_info_msg(topo_info_response_msg_t *msg)
  */
 extern void slurm_free_burst_buffer_info_msg(burst_buffer_info_msg_t *msg)
 {
-	int i, j, k;
-	burst_buffer_gres_t *bb_gres_ptr;
+	int i, j;
 	burst_buffer_info_t *bb_info_ptr;
 	burst_buffer_resv_t *bb_resv_ptr;
 
@@ -3220,11 +3219,6 @@ extern void slurm_free_burst_buffer_info_msg(burst_buffer_info_msg_t *msg)
 			xfree(bb_info_ptr->deny_users);
 			xfree(bb_info_ptr->destroy_buffer);
 			xfree(bb_info_ptr->get_sys_state);
-			for (k = 0, bb_gres_ptr = bb_info_ptr->gres_ptr;
-			     k < bb_info_ptr->gres_cnt; k++, bb_gres_ptr++) {
-				xfree(bb_info_ptr->name);
-			}
-			xfree(bb_info_ptr->gres_ptr);
 			xfree(bb_info_ptr->name);
 			xfree(bb_info_ptr->start_stage_in);
 			xfree(bb_info_ptr->start_stage_out);
@@ -3234,13 +3228,7 @@ extern void slurm_free_burst_buffer_info_msg(burst_buffer_info_msg_t *msg)
 			     bb_resv_ptr = bb_info_ptr->burst_buffer_resv_ptr;
 			     j < bb_info_ptr->buffer_count;
 			     j++, bb_resv_ptr++) {
-				for (k = 0, bb_gres_ptr = bb_resv_ptr->gres_ptr;
-				     k < bb_resv_ptr->gres_cnt;
-				     k++, bb_gres_ptr++) {
-					xfree(bb_gres_ptr->name);
-				}
 				xfree(bb_resv_ptr->account);
-				xfree(bb_resv_ptr->gres_ptr);
 				xfree(bb_resv_ptr->name);
 				xfree(bb_resv_ptr->partition);
 				xfree(bb_resv_ptr->pool);
diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c
index e362427403e..ff152547e3c 100644
--- a/src/common/slurm_protocol_pack.c
+++ b/src/common/slurm_protocol_pack.c
@@ -10500,18 +10500,6 @@ static int _unpack_burst_buffer_info_msg(
 					      buffer);
 				safe_unpack_time(&bb_resv_ptr->create_time,
 						 buffer);
-				safe_unpack32(&bb_resv_ptr->gres_cnt, buffer);
-				bb_resv_ptr->gres_ptr =
-					xmalloc(bb_resv_ptr->gres_cnt *
-						sizeof(burst_buffer_gres_t));
-				for (k = 0; k < bb_resv_ptr->gres_cnt; k++) {
-					safe_unpackstr_xmalloc(
-						&bb_resv_ptr->gres_ptr[k].name,
-						&uint32_tmp, buffer);
-					safe_unpack64(
-						&bb_resv_ptr->gres_ptr[k].
-						used_cnt, buffer);
-				}
 				safe_unpack32(&bb_resv_ptr->job_id, buffer);
 				safe_unpackstr_xmalloc(&bb_resv_ptr->name,
 						       &uint32_tmp, buffer);
@@ -10538,6 +10526,9 @@ static int _unpack_burst_buffer_info_msg(
 			}
 		}
 	} else {
+		uint32_t gres_cnt = 0;
+		uint64_t used_cnt = 0;
+		char *gres_name = NULL;
 		for (i = 0, bb_info_ptr = bb_msg_ptr->burst_buffer_array;
 		     i < bb_msg_ptr->record_count; i++, bb_info_ptr++) {
 			safe_unpackstr_xmalloc(&bb_info_ptr->name, &uint32_tmp,
@@ -10598,17 +10589,11 @@ static int _unpack_burst_buffer_info_msg(
 					      buffer);
 				safe_unpack_time(&bb_resv_ptr->create_time,
 						 buffer);
-				safe_unpack32(&bb_resv_ptr->gres_cnt, buffer);
-				bb_resv_ptr->gres_ptr =
-					xmalloc(bb_resv_ptr->gres_cnt *
-						sizeof(burst_buffer_gres_t));
-				for (k = 0; k < bb_resv_ptr->gres_cnt; k++) {
-					safe_unpackstr_xmalloc(
-						&bb_resv_ptr->gres_ptr[k].name,
+				safe_unpack32(&gres_cnt, buffer);
+				for (k = 0; k < gres_cnt; k++) {
+					safe_unpackmem_ptr(&gres_name,
 						&uint32_tmp, buffer);
-					safe_unpack64(
-						&bb_resv_ptr->gres_ptr[k].
-						used_cnt, buffer);
+					safe_unpack64(&used_cnt, buffer);
 				}
 				safe_unpack32(&bb_resv_ptr->job_id, buffer);
 				safe_unpackstr_xmalloc(&bb_resv_ptr->name,
diff --git a/src/plugins/burst_buffer/common/burst_buffer_common.c b/src/plugins/burst_buffer/common/burst_buffer_common.c
index 8a8720f84d0..6a632b09a89 100644
--- a/src/plugins/burst_buffer/common/burst_buffer_common.c
+++ b/src/plugins/burst_buffer/common/burst_buffer_common.c
@@ -576,18 +576,11 @@ extern void bb_load_config(bb_state_t *state_ptr, char *plugin_type)
 static void _pack_alloc(struct bb_alloc *bb_alloc, Buf buffer,
 			uint16_t protocol_version)
 {
-	int i;
-
 	if (protocol_version >= SLURM_16_05_PROTOCOL_VERSION) {
 		packstr(bb_alloc->account,      buffer);
 		pack32(bb_alloc->array_job_id,  buffer);
 		pack32(bb_alloc->array_task_id, buffer);
 		pack_time(bb_alloc->create_time, buffer);
-		pack32(bb_alloc->gres_cnt, buffer);
-		for (i = 0; i < bb_alloc->gres_cnt; i++) {
-			packstr(bb_alloc->gres_ptr[i].name, buffer);
-			pack64(bb_alloc->gres_ptr[i].used_cnt, buffer);
-		}
 		pack32(bb_alloc->job_id,        buffer);
 		packstr(bb_alloc->name,         buffer);
 		packstr(bb_alloc->partition,    buffer);
@@ -597,15 +590,12 @@ static void _pack_alloc(struct bb_alloc *bb_alloc, Buf buffer,
 		pack16(bb_alloc->state,         buffer);
 		pack32(bb_alloc->user_id,       buffer);
 	} else {
+		uint32_t gres_cnt = 0;
 		packstr(bb_alloc->account,      buffer);
 		pack32(bb_alloc->array_job_id,  buffer);
 		pack32(bb_alloc->array_task_id, buffer);
 		pack_time(bb_alloc->create_time, buffer);
-		pack32(bb_alloc->gres_cnt, buffer);
-		for (i = 0; i < bb_alloc->gres_cnt; i++) {
-			packstr(bb_alloc->gres_ptr[i].name, buffer);
-			pack64(bb_alloc->gres_ptr[i].used_cnt, buffer);
-		}
+		pack32(gres_cnt, buffer);
 		pack32(bb_alloc->job_id,        buffer);
 		packstr(bb_alloc->name,         buffer);
 		packstr(bb_alloc->partition,    buffer);
@@ -978,15 +968,6 @@ extern bb_alloc_t *bb_alloc_job_rec(bb_state_t *state_ptr,
 	bb_alloc->array_job_id = job_ptr->array_job_id;
 	bb_alloc->array_task_id = job_ptr->array_task_id;
 	bb_alloc->assoc_ptr = job_ptr->assoc_ptr;
-	bb_alloc->gres_cnt = bb_job->gres_cnt;
-	if (bb_alloc->gres_cnt) {
-		bb_alloc->gres_ptr = xmalloc(sizeof(burst_buffer_gres_t) *
-					     bb_alloc->gres_cnt);
-	}
-	for (i = 0; i < bb_alloc->gres_cnt; i++) {
-		bb_alloc->gres_ptr[i].used_cnt = bb_job->gres_ptr[i].count;
-		bb_alloc->gres_ptr[i].name = xstrdup(bb_job->gres_ptr[i].name);
-	}
 	bb_alloc->job_id = job_ptr->job_id;
 	xassert((bb_alloc->magic = BB_ALLOC_MAGIC));	/* Sets value */
 	i = job_ptr->user_id % BB_HASH_SIZE;
@@ -1024,16 +1005,11 @@ extern bb_alloc_t *bb_alloc_job(bb_state_t *state_ptr,
  * maintaining linked list */
 extern void bb_free_alloc_buf(bb_alloc_t *bb_alloc)
 {
-	int i;
-
 	if (bb_alloc) {
 		xassert(bb_alloc->magic == BB_ALLOC_MAGIC);
 		bb_alloc->magic = 0;
 		xfree(bb_alloc->account);
 		xfree(bb_alloc->assocs);
-		for (i = 0; i < bb_alloc->gres_cnt; i++)
-			xfree(bb_alloc->gres_ptr[i].name);
-		xfree(bb_alloc->gres_ptr);
 		xfree(bb_alloc->name);
 		xfree(bb_alloc->partition);
 		xfree(bb_alloc->pool);
@@ -1329,9 +1305,6 @@ static void _bb_job_del2(bb_job_t *bb_job)
 			xfree(bb_job->buf_ptr[i].type);
 		}
 		xfree(bb_job->buf_ptr);
-		for (i = 0; i < bb_job->gres_cnt; i++)
-			xfree(bb_job->gres_ptr[i].name);
-		xfree(bb_job->gres_ptr);
 		xfree(bb_job->job_pool);
 		xfree(bb_job->partition);
 		xfree(bb_job->qos);
@@ -1349,11 +1322,6 @@ extern void bb_job_log(bb_state_t *state_ptr, bb_job_t *bb_job)
 	if (bb_job) {
 		xstrfmtcat(out_buf, "%s: Job:%u UserID:%u ",
 			   state_ptr->name, bb_job->job_id, bb_job->user_id);
-		for (i = 0; i < bb_job->gres_cnt; i++) {
-			xstrfmtcat(out_buf, "Gres[%d]:%s:%"PRIu64" ",
-				   i, bb_job->gres_ptr[i].name,
-				   bb_job->gres_ptr[i].count);
-		}
 		xstrfmtcat(out_buf, "Swap:%ux%u ", bb_job->swap_size,
 			   bb_job->swap_nodes);
 		xstrfmtcat(out_buf, "TotalSize:%"PRIu64"", bb_job->total_size);
@@ -1362,10 +1330,11 @@ extern void bb_job_log(bb_state_t *state_ptr, bb_job_t *bb_job)
 		for (i = 0, buf_ptr = bb_job->buf_ptr; i < bb_job->buf_cnt;
 		     i++, buf_ptr++) {
 			if (buf_ptr->create) {
-				info("  Create  Name:%s Size:%"PRIu64
+				info("  Create  Name:%s Pool:%s Size:%"PRIu64
 				     " Access:%s Type:%s State:%s",
-				     buf_ptr->name, buf_ptr->size,
-				     buf_ptr->access, buf_ptr->type,
+				     buf_ptr->name, buf_ptr->pool,
+				     buf_ptr->size, buf_ptr->access,
+				     buf_ptr->type,
 				     bb_state_string(buf_ptr->state));
 			} else if (buf_ptr->destroy) {
 				info("  Destroy Name:%s Hurry:%d",
diff --git a/src/plugins/burst_buffer/common/burst_buffer_common.h b/src/plugins/burst_buffer/common/burst_buffer_common.h
index 3bcd240a022..6c016178170 100644
--- a/src/plugins/burst_buffer/common/burst_buffer_common.h
+++ b/src/plugins/burst_buffer/common/burst_buffer_common.h
@@ -99,8 +99,6 @@ typedef struct bb_alloc {
 	bool cancelled;
 	time_t create_time;	/* Time of creation */
 	time_t end_time;	/* Expected time when use will end */
-	uint32_t gres_cnt;	/* Count of records in gres_ptr */
-	burst_buffer_gres_t *gres_ptr;
 	uint32_t id;		/* ID for reservation/accounting */
 	uint32_t job_id;
 	uint32_t magic;
@@ -156,8 +154,6 @@ typedef struct bb_job {
 	char      *account;	/* Associated account (for limits) */
 	uint32_t   buf_cnt;	/* Number of records in buf_ptr */
 	bb_buf_t  *buf_ptr;	/* Buffer creation records */
-	uint32_t   gres_cnt;	/* number of records in gres_ptr */
-	bb_gres_t *gres_ptr;
 	uint32_t   job_id;
 	char      *job_pool;	/* Pool in which to create job buffers */
 	uint32_t   magic;
diff --git a/src/sview/bb_info.c b/src/sview/bb_info.c
index 31ab295964f..d9f9502ed53 100644
--- a/src/sview/bb_info.c
+++ b/src/sview/bb_info.c
@@ -53,10 +53,10 @@ enum {
 	SORTID_COLOR,
 	SORTID_COLOR_INX,
 	SORTID_CREATE_TIME,
-	SORTID_GRES,
 	SORTID_NAME,
 	SORTID_PARTITION,
 	SORTID_PLUGIN,
+	SORTID_POOL,
 	SORTID_QOS,
 	SORTID_SIZE,
 	SORTID_STATE,
@@ -73,7 +73,7 @@ enum {
 /*these are the settings to apply for the user
  * on the first startup after a fresh slurm install.
  * s/b a const probably*/
-static char *_initial_page_opts = "Plugin,Name/JobID,Gres,Size,State,StateTime,UserID";
+static char *_initial_page_opts = "Plugin,Name/JobID,Pool,Size,State,StateTime,UserID";
 
 static display_data_t display_data_bb[] = {
 	{G_TYPE_INT, SORTID_POS, NULL, FALSE, EDIT_NONE,
@@ -90,10 +90,10 @@ static display_data_t display_data_bb[] = {
 	 refresh_bb, create_model_bb, admin_edit_bb},
 	{G_TYPE_STRING, SORTID_CREATE_TIME, "CreateTime", FALSE, EDIT_NONE,
 	 refresh_bb, create_model_bb, admin_edit_bb},
-	{G_TYPE_STRING, SORTID_GRES, "Gres", FALSE, EDIT_NONE,
-	 refresh_bb, create_model_bb, admin_edit_bb},
 	{G_TYPE_STRING, SORTID_PARTITION, "Partition", FALSE, EDIT_NONE,
 	 refresh_bb, create_model_bb, admin_edit_bb},
+	{G_TYPE_STRING, SORTID_POOL, "Pool", FALSE, EDIT_NONE,
+	 refresh_bb, create_model_bb, admin_edit_bb},
 	{G_TYPE_STRING, SORTID_QOS, "QOS", FALSE, EDIT_NONE,
 	 refresh_bb, create_model_bb, admin_edit_bb},
 	{G_TYPE_STRING, SORTID_SIZE, "Size", FALSE, EDIT_NONE,
@@ -193,12 +193,11 @@ static void _layout_bb_record(GtkTreeView *treeview,
 			      sview_bb_info_t *sview_bb_info, int update)
 {
 	GtkTreeIter iter;
-	char time_buf[20], *tmp_gres = NULL, tmp_user_id[60], tmp_size[20];
+	char time_buf[20], tmp_user_id[60], tmp_size[20];
 	char bb_name_id[32];
-	char *tmp_state, *tmp_user_name, *sep;
+	char *tmp_state, *tmp_user_name;
 	burst_buffer_resv_t *bb_ptr = sview_bb_info->bb_ptr;
 	GtkTreeStore *treestore;
-	int i;
 
 	treestore = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
 
@@ -235,6 +234,11 @@ static void _layout_bb_record(GtkTreeView *treeview,
 						 SORTID_PARTITION),
 				   bb_ptr->partition);
 
+	add_display_treestore_line(update, treestore, &iter,
+				   find_col_name(display_data_bb,
+						 SORTID_POOL),
+				   bb_ptr->pool);
+
 	add_display_treestore_line(update, treestore, &iter,
 				   find_col_name(display_data_bb,
 						 SORTID_QOS),
@@ -252,18 +256,6 @@ static void _layout_bb_record(GtkTreeView *treeview,
 						 SORTID_SIZE),
 				   tmp_size);
 
-	sep = "";
-	for (i = 0; i < bb_ptr->gres_cnt; i++) {
-		xstrfmtcat(tmp_gres, "%s%s:%"PRIu64"", sep,
-			   bb_ptr->gres_ptr->name, bb_ptr->gres_ptr->used_cnt);
-		sep = ",";
-	}
-	add_display_treestore_line(update, treestore, &iter,
-				   find_col_name(display_data_bb,
-						 SORTID_GRES),
-				   tmp_gres);
-	xfree(tmp_gres);
-
 	if (bb_ptr->create_time) {
 		slurm_make_time_str((time_t *)&bb_ptr->create_time, time_buf,
 				    sizeof(time_buf));
@@ -324,16 +316,8 @@ static void _update_bb_record(sview_bb_info_t *sview_bb_info_ptr,
 {
 	char tmp_create_time[40];
 	char tmp_size[20], tmp_user_id[60], bb_name_id[32];
-	char *tmp_gres = NULL, *tmp_state, *tmp_user_name, *sep;
+	char *tmp_state, *tmp_user_name;
 	burst_buffer_resv_t *bb_ptr = sview_bb_info_ptr->bb_ptr;
-	int i;
-
-	sep = "";
-	for (i = 0; i < bb_ptr->gres_cnt; i++) {
-		xstrfmtcat(tmp_gres, "%s%s:%"PRIu64"", sep,
-			   bb_ptr->gres_ptr->name, bb_ptr->gres_ptr->used_cnt);
-		sep = ",";
-	}
 
 	if (bb_ptr->name) {
 		strncpy(bb_name_id, bb_ptr->name, sizeof(bb_name_id));
@@ -375,16 +359,15 @@ static void _update_bb_record(sview_bb_info_t *sview_bb_info_ptr,
 			   SORTID_PLUGIN,        sview_bb_info_ptr->plugin,
 			   SORTID_ACCOUNT,       bb_ptr->account,
 			   SORTID_CREATE_TIME,   tmp_create_time,
-			   SORTID_GRES,          tmp_gres,
 			   SORTID_NAME,          bb_name_id,
 			   SORTID_PARTITION,     bb_ptr->partition,
+			   SORTID_POOL,          bb_ptr->pool,
 			   SORTID_QOS,           bb_ptr->qos,
 			   SORTID_SIZE,          tmp_size,
 			   SORTID_STATE,         tmp_state,
 			   SORTID_UPDATED,       1,
 			   SORTID_USERID,        tmp_user_id,
 			   -1);
-	xfree(tmp_gres);
 
 	return;
 }
-- 
GitLab