Skip to content
Snippets Groups Projects
Commit d1af81a0 authored by Moe Jette's avatar Moe Jette
Browse files

Fix BlueGene hostlist processing for non-rectangular prisms and

add string length checking.
parent c283f20f
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,8 @@ documents those changes that are of interest to users and admins. ...@@ -10,6 +10,8 @@ documents those changes that are of interest to users and admins.
its maps). its maps).
-- Added module to parse time string (src/common/parse_time.c) for -- Added module to parse time string (src/common/parse_time.c) for
future use. future use.
-- Fix BlueGene hostlist processing for non-rectangular prisms and
add string length checking.
* Changes in SLURM 0.6.0-pre4 * Changes in SLURM 0.6.0-pre4
============================= =============================
......
...@@ -166,7 +166,7 @@ bool axis[10][10][10]; ...@@ -166,7 +166,7 @@ bool axis[10][10][10];
int axis_min_x, axis_min_y, axis_min_z; int axis_min_x, axis_min_y, axis_min_z;
int axis_max_x, axis_max_y, axis_max_z; int axis_max_x, axis_max_y, axis_max_z;
static int _get_boxes(char *buf); static int _get_boxes(char *buf, int max_len);
static void _clear_grid(void); static void _clear_grid(void);
static void _set_grid(unsigned long start, unsigned long end); static void _set_grid(unsigned long start, unsigned long end);
static bool _test_box(void); static bool _test_box(void);
...@@ -2198,46 +2198,51 @@ _get_bracketed_list(hostlist_t hl, int *start, const size_t n, char *buf) ...@@ -2198,46 +2198,51 @@ _get_bracketed_list(hostlist_t hl, int *start, const size_t n, char *buf)
* Assumes hostlist is locked. * Assumes hostlist is locked.
*/ */
static int static int
_get_boxes(char *buf) _get_boxes(char *buf, int max_len)
{ {
int len = 0; int i, j, k, len = 0;
int temp; int is_box, start_box=-1, end_box=-1;
int x1;
int x2 = -1; /* scan each X-plane for a box then match across X values */
int found = 0; for (i=axis_min_x; i<=axis_max_x; i++) {
is_box = 1;
x1 = axis_min_x; for (j=axis_min_y; j<=axis_max_y; j++) {
while(x1<=axis_max_x) { for (k=axis_min_z; k<=axis_max_z; k++) {
found = 0; if (!axis[i][j][k]) {
for (temp = x1; temp<=axis_max_x; temp++) { is_box = 0;
if(axis[temp][axis_min_y][axis_min_z] && !found) { break;
x1 = temp; }
found = 1;
} else if (!axis[temp][axis_min_y][axis_min_z]
&& found) {
x2 = temp-1;
break;
} }
} }
if(found) { if (is_box) {
found = 0; if (start_box == -1)
start_box = i;
if(x2 == -1) end_box = i;
x2 = axis_max_x; }
if (((len+8) < max_len) && (start_box != -1)
&& ((is_box == 0) || (i == axis_max_x))) {
sprintf(buf+len,"%d%d%dx%d%d%d,", sprintf(buf+len,"%d%d%dx%d%d%d,",
x1,axis_min_y,axis_min_z, start_box, axis_min_y, axis_min_z,
x2,axis_max_y,axis_max_z); end_box, axis_min_y, axis_min_z);
len += 8;
len+=8; start_box = -1;
} else if(x2 == -1) end_box = -1;
break; }
x1 = x2+1; if (is_box == 0) {
x2 = -1; for (j=axis_min_y; j<=axis_max_y; j++) {
for (k=axis_min_z; k<=axis_max_z; k++) {
if (!axis[i][j][k])
continue;
if ((len+4) >= max_len)
break;
sprintf(buf+len,"%d%d%d,",
i, j, k);
len += 4;
}
}
}
} }
buf[len - 1] = ']'; buf[len - 1] = ']';
/* NUL terminate for safety, but do not add terminator to len */ /* NUL terminate for safety, but do not add terminator to len */
...@@ -2340,7 +2345,7 @@ size_t hostlist_ranged_string(hostlist_t hl, size_t n, char *buf) ...@@ -2340,7 +2345,7 @@ size_t hostlist_ranged_string(hostlist_t hl, size_t n, char *buf)
if (!_test_box()) { if (!_test_box()) {
sprintf(buf, "%s[", hl->hr[0]->prefix); sprintf(buf, "%s[", hl->hr[0]->prefix);
len = strlen(hl->hr[0]->prefix) + 1; len = strlen(hl->hr[0]->prefix) + 1;
len += _get_boxes(buf + len); len += _get_boxes(buf + len, (n-len));
} else { } else {
len += snprintf(buf, n, "%s[%d%d%dx%d%d%d]", len += snprintf(buf, n, "%s[%d%d%dx%d%d%d]",
hl->hr[0]->prefix, hl->hr[0]->prefix,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment