diff --git a/src/common/job_resources.c b/src/common/job_resources.c index 4f9877ccff6a93b7e4d694e44bde4ff3a3677c17..e5a8f90e2e12263a890d5f38cee69328dc58f179 100644 --- a/src/common/job_resources.c +++ b/src/common/job_resources.c @@ -802,8 +802,8 @@ extern int get_job_resources_node(job_resources_t *job_resrcs_ptr, return 0; } -extern int set_job_resources_node(job_resources_t *job_resrcs_ptr, - uint32_t node_id) +static int _change_job_resources_node(job_resources_t *job_resrcs_ptr, + uint32_t node_id, bool new_value) { int i, bit_inx = 0, core_cnt = 0; @@ -825,23 +825,39 @@ extern int set_job_resources_node(job_resources_t *job_resrcs_ptr, } } if (core_cnt < 1) { - error("set_job_resources_node: core_cnt=0"); + error("_change_job_resources_node: core_cnt=0"); return SLURM_ERROR; } i = bit_size(job_resrcs_ptr->core_bitmap); if ((bit_inx + core_cnt) > i) { - error("set_job_resources_node: offset > bitmap size " + error("_change_job_resources_node: offset > bitmap size " "(%d >= %d)", (bit_inx + core_cnt), i); return SLURM_ERROR; } - for (i=0; i<core_cnt; i++) - bit_set(job_resrcs_ptr->core_bitmap, bit_inx++); + for (i=0; i<core_cnt; i++) { + if (new_value) + bit_set(job_resrcs_ptr->core_bitmap, bit_inx++); + else + bit_clear(job_resrcs_ptr->core_bitmap, bit_inx++); + } return SLURM_SUCCESS; } +extern int set_job_resources_node(job_resources_t *job_resrcs_ptr, + uint32_t node_id) +{ + return _change_job_resources_node(job_resrcs_ptr, node_id, true); +} + +extern int clear_job_resources_node(job_resources_t *job_resrcs_ptr, + uint32_t node_id) +{ + return _change_job_resources_node(job_resrcs_ptr, node_id, false); +} + extern int get_job_resources_cnt(job_resources_t *job_resrcs_ptr, uint32_t node_id, uint16_t *socket_cnt, uint16_t *cores_per_socket_cnt) diff --git a/src/common/job_resources.h b/src/common/job_resources.h index 8ae4ec617247dc96f9e239b019d5b340e02e4c9e..6f812b3fd9721e0e330e18bd91bddfaa8d78a92b 100644 --- a/src/common/job_resources.h +++ b/src/common/job_resources.h @@ -207,13 +207,15 @@ extern int set_job_resources_bit(job_resources_t *job_resrcs_ptr, uint32_t node_id, uint16_t socket_id, uint16_t core_id); -/* Get/set bit value at specified location for whole node allocations +/* Get/clear/set bit value at specified location for whole node allocations * get is for any socket/core on the specified node * set is for all sockets/cores on the specified node * fully comptabable with set/get_job_resources_bit() * node_id is all zero origin */ extern int get_job_resources_node(job_resources_t *job_resrcs_ptr, uint32_t node_id); +extern int clear_job_resources_node(job_resources_t *job_resrcs_ptr, + uint32_t node_id); extern int set_job_resources_node(job_resources_t *job_resrcs_ptr, uint32_t node_id);