From a53b587341ca6cd000f0e734d0a00c86b37e2621 Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez <alex@schedmd.com> Date: Mon, 3 Jul 2017 11:10:06 -0600 Subject: [PATCH] Continuation of commit 7e161809a50 for burst buffer size unit changes. _update_bb_resv() received a bb_spec whose units were originally always interpreted as powers of 1024 (IEC). This change supports both IEC/SI formats. Bug 3922 --- src/slurmctld/reservation.c | 47 +++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/src/slurmctld/reservation.c b/src/slurmctld/reservation.c index cd688218b7e..35b44ef854a 100644 --- a/src/slurmctld/reservation.c +++ b/src/slurmctld/reservation.c @@ -4518,7 +4518,7 @@ static void _add_bb_resv(burst_buffer_info_msg_t **bb_resv, char *plugin, static void _update_bb_resv(burst_buffer_info_msg_t **bb_resv, char *bb_spec) { uint64_t cnt; - char *end_ptr = NULL, *end_ptr2 = NULL; + char *end_ptr = NULL, *unit = NULL; char *sep, *tmp_spec, *tok, *plugin, *type; if ((bb_spec == NULL) || (bb_spec[0] == '\0')) @@ -4545,19 +4545,40 @@ static void _update_bb_resv(burst_buffer_info_msg_t **bb_resv, char *bb_spec) type = NULL; } - cnt = strtol(tok, &end_ptr2, 10); - if ((end_ptr2[0] == 'n') || (end_ptr2[0] == 'N')) { + cnt = (uint64_t) strtoull(tok, &unit, 10); + if (!xstrcasecmp(unit, "n") || + !xstrcasecmp(unit, "node") || + !xstrcasecmp(unit, "nodes")) { type = "nodes"; /* Cray node spec format */ - } else if ((end_ptr2[0] == 'k') || (end_ptr2[0] == 'K')) { - cnt *= ((uint64_t) 1024); - } else if ((end_ptr2[0] == 'm') || (end_ptr2[0] == 'M')) { - cnt *= ((uint64_t) 1024 * 1024); - } else if ((end_ptr2[0] == 'g') || (end_ptr2[0] == 'G')) { - cnt *= ((uint64_t) 1024 * 1024 * 1024); - } else if ((end_ptr2[0] == 't') || (end_ptr2[0] == 'T')) { - cnt *= ((uint64_t) 1024 * 1024 * 1024 * 1024); - } else if ((end_ptr2[0] == 'p') || (end_ptr2[0] == 'P')) { - cnt *= ((uint64_t) 1024 * 1024 * 1024 * 1024 * 1024); + } else if (!xstrcasecmp(unit, "k") || + !xstrcasecmp(unit, "kib")) { + cnt *= 1024; + } else if (!xstrcasecmp(unit, "kb")) { + cnt *= 1000; + + } else if (!xstrcasecmp(unit, "m") || + !xstrcasecmp(unit, "mib")) { + cnt *= ((uint64_t)1024 * 1024); + } else if (!xstrcasecmp(unit, "mb")) { + cnt *= ((uint64_t)1000 * 1000); + + } else if (!xstrcasecmp(unit, "g") || + !xstrcasecmp(unit, "gib")) { + cnt *= ((uint64_t)1024 * 1024 * 1024); + } else if (!xstrcasecmp(unit, "gb")) { + cnt *= ((uint64_t)1000 * 1000 * 1000); + + } else if (!xstrcasecmp(unit, "t") || + !xstrcasecmp(unit, "tib")) { + cnt *= ((uint64_t)1024 * 1024 * 1024 * 1024); + } else if (!xstrcasecmp(unit, "tb")) { + cnt *= ((uint64_t)1000 * 1000 * 1000 * 1000); + + } else if (!xstrcasecmp(unit, "p") || + !xstrcasecmp(unit, "pib")) { + cnt *= ((uint64_t)1024 * 1024 * 1024 * 1024 * 1024); + } else if (!xstrcasecmp(unit, "pb")) { + cnt *= ((uint64_t)1000 * 1000 * 1000 * 1000 * 1000); } if (cnt) -- GitLab