Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
8c66b249
Commit
8c66b249
authored
9 years ago
by
Danny Auble
Browse files
Options
Downloads
Patches
Plain Diff
Minor fixes to last commit, formatting and removing extra/unneeded if
statements.
parent
7eff526c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scontrol/create_res.c
+34
-41
34 additions, 41 deletions
src/scontrol/create_res.c
with
34 additions
and
41 deletions
src/scontrol/create_res.c
+
34
−
41
View file @
8c66b249
...
@@ -75,7 +75,7 @@ static char * _process_plus_minus(char plus_or_minus, char *src)
...
@@ -75,7 +75,7 @@ static char * _process_plus_minus(char plus_or_minus, char *src)
}
}
static
int
_parse_resv_node_cnt
(
resv_desc_msg_t
*
resv_msg_ptr
,
char
*
val
,
static
int
_parse_resv_node_cnt
(
resv_desc_msg_t
*
resv_msg_ptr
,
char
*
val
,
bool
from_tres
)
bool
from_tres
)
{
{
char
*
endptr
=
NULL
,
*
node_cnt
,
*
tok
,
*
ptrptr
=
NULL
;
char
*
endptr
=
NULL
,
*
node_cnt
,
*
tok
,
*
ptrptr
=
NULL
;
int
node_inx
=
0
;
int
node_inx
=
0
;
...
@@ -89,13 +89,11 @@ static int _parse_resv_node_cnt(resv_desc_msg_t *resv_msg_ptr, char *val,
...
@@ -89,13 +89,11 @@ static int _parse_resv_node_cnt(resv_desc_msg_t *resv_msg_ptr, char *val,
if
((
endptr
!=
NULL
)
&&
if
((
endptr
!=
NULL
)
&&
((
endptr
[
0
]
==
'k'
)
||
((
endptr
[
0
]
==
'k'
)
||
(
endptr
[
0
]
==
'K'
)))
{
(
endptr
[
0
]
==
'K'
)))
{
resv_msg_ptr
->
node_cnt
[
node_inx
]
*=
resv_msg_ptr
->
node_cnt
[
node_inx
]
*=
1024
;
1024
;
}
else
if
((
endptr
!=
NULL
)
&&
}
else
if
((
endptr
!=
NULL
)
&&
((
endptr
[
0
]
==
'm'
)
||
((
endptr
[
0
]
==
'm'
)
||
(
endptr
[
0
]
==
'M'
)))
{
(
endptr
[
0
]
==
'M'
)))
{
resv_msg_ptr
->
node_cnt
[
node_inx
]
*=
resv_msg_ptr
->
node_cnt
[
node_inx
]
*=
1024
*
1024
;
1024
*
1024
;
}
else
if
((
endptr
==
NULL
)
||
}
else
if
((
endptr
==
NULL
)
||
(
endptr
[
0
]
!=
'\0'
)
||
(
endptr
[
0
]
!=
'\0'
)
||
(
tok
[
0
]
==
'\0'
))
{
(
tok
[
0
]
==
'\0'
))
{
...
@@ -116,7 +114,7 @@ static int _parse_resv_node_cnt(resv_desc_msg_t *resv_msg_ptr, char *val,
...
@@ -116,7 +114,7 @@ static int _parse_resv_node_cnt(resv_desc_msg_t *resv_msg_ptr, char *val,
}
}
static
int
_parse_resv_core_cnt
(
resv_desc_msg_t
*
resv_msg_ptr
,
char
*
val
,
static
int
_parse_resv_core_cnt
(
resv_desc_msg_t
*
resv_msg_ptr
,
char
*
val
,
bool
from_tres
)
bool
from_tres
)
{
{
char
*
endptr
=
NULL
,
*
core_cnt
,
*
tok
,
*
ptrptr
=
NULL
;
char
*
endptr
=
NULL
,
*
core_cnt
,
*
tok
,
*
ptrptr
=
NULL
;
...
@@ -136,12 +134,12 @@ static int _parse_resv_core_cnt(resv_desc_msg_t *resv_msg_ptr, char *val,
...
@@ -136,12 +134,12 @@ static int _parse_resv_core_cnt(resv_desc_msg_t *resv_msg_ptr, char *val,
return
SLURM_ERROR
;
return
SLURM_ERROR
;
}
}
}
else
if
(
strcasestr
(
type
,
"cons_res"
)
==
NULL
)
{
}
else
if
(
strcasestr
(
type
,
"cons_res"
)
==
NULL
)
{
error
(
"CoreCnt or CPUCnt is only "
error
(
"CoreCnt or CPUCnt is only "
"suported when "
"suported when "
"SelectType includes "
"SelectType includes "
"select/cons_res"
);
"select/cons_res"
);
xfree
(
type
);
xfree
(
type
);
return
SLURM_ERROR
;
return
SLURM_ERROR
;
}
}
xfree
(
type
);
xfree
(
type
);
...
@@ -153,8 +151,8 @@ static int _parse_resv_core_cnt(resv_desc_msg_t *resv_msg_ptr, char *val,
...
@@ -153,8 +151,8 @@ static int _parse_resv_core_cnt(resv_desc_msg_t *resv_msg_ptr, char *val,
resv_msg_ptr
->
core_cnt
[
node_inx
]
=
resv_msg_ptr
->
core_cnt
[
node_inx
]
=
strtol
(
tok
,
&
endptr
,
10
);
strtol
(
tok
,
&
endptr
,
10
);
if
((
endptr
==
NULL
)
||
if
((
endptr
==
NULL
)
||
(
endptr
[
0
]
!=
'\0'
)
||
(
endptr
[
0
]
!=
'\0'
)
||
(
tok
[
0
]
==
'\0'
))
{
(
tok
[
0
]
==
'\0'
))
{
exit_code
=
1
;
exit_code
=
1
;
if
(
from_tres
)
if
(
from_tres
)
error
(
"Invalid TRES core count %s"
,
val
);
error
(
"Invalid TRES core count %s"
,
val
);
...
@@ -206,10 +204,10 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
...
@@ -206,10 +204,10 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
{
{
int
i
,
ret
,
len
;
int
i
,
ret
,
len
;
char
*
tres_bb
=
NULL
,
*
tres_license
=
NULL
,
char
*
tres_bb
=
NULL
,
*
tres_license
=
NULL
,
*
tres_corecnt
=
NULL
,
*
tres_nodecnt
=
NULL
,
*
tres_corecnt
=
NULL
,
*
tres_nodecnt
=
NULL
,
*
token
,
*
type
=
NULL
,
*
saveptr1
=
NULL
,
*
token
,
*
type
=
NULL
,
*
saveptr1
=
NULL
,
*
value_str
=
NULL
,
*
name
=
NULL
,
*
compound
=
NULL
,
*
value_str
=
NULL
,
*
name
=
NULL
,
*
compound
=
NULL
,
*
tmp
;
*
tmp
;
bool
discard
,
first
;
bool
discard
,
first
;
*
free_tres_license
=
0
;
*
free_tres_license
=
0
;
...
@@ -223,8 +221,8 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
...
@@ -223,8 +221,8 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
compound
=
strtok_r
(
token
,
"="
,
&
value_str
);
compound
=
strtok_r
(
token
,
"="
,
&
value_str
);
if
(
!
value_str
||
!*
value_str
)
{
if
(
!
value_str
||
!*
value_str
)
{
error
(
"TRES component '%s' has an invalid value"
,
error
(
"TRES component '%s' has an invalid value
'%s'
"
,
token
);
type
,
token
);
goto
error
;
goto
error
;
}
}
...
@@ -239,7 +237,7 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
...
@@ -239,7 +237,7 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
if
(
!
strcasecmp
(
type
,
"license"
))
{
if
(
!
strcasecmp
(
type
,
"license"
))
{
if
(
tres_license
&&
tres_license
[
0
]
!=
'\0'
)
if
(
tres_license
&&
tres_license
[
0
]
!=
'\0'
)
xstrcatchar
(
tres_license
,
','
);
xstrcatchar
(
tres_license
,
','
);
xstrfmtcat
(
tres_license
,
"%s:%s"
,
name
,
value_str
);
xstrfmtcat
(
tres_license
,
"%s:%s"
,
name
,
value_str
);
token
=
strtok_r
(
NULL
,
","
,
&
saveptr1
);
token
=
strtok_r
(
NULL
,
","
,
&
saveptr1
);
if
(
tmp
)
if
(
tmp
)
...
@@ -247,7 +245,7 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
...
@@ -247,7 +245,7 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
}
else
if
(
strcasecmp
(
type
,
"bb"
)
==
0
)
{
}
else
if
(
strcasecmp
(
type
,
"bb"
)
==
0
)
{
if
(
tres_bb
&&
tres_bb
[
0
]
!=
'\0'
)
if
(
tres_bb
&&
tres_bb
[
0
]
!=
'\0'
)
xstrcatchar
(
tres_bb
,
','
);
xstrcatchar
(
tres_bb
,
','
);
xstrfmtcat
(
tres_bb
,
"%s:%s"
,
name
,
value_str
);
xstrfmtcat
(
tres_bb
,
"%s:%s"
,
name
,
value_str
);
token
=
strtok_r
(
NULL
,
","
,
&
saveptr1
);
token
=
strtok_r
(
NULL
,
","
,
&
saveptr1
);
if
(
tmp
)
if
(
tmp
)
...
@@ -267,14 +265,14 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
...
@@ -267,14 +265,14 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
goto
error
;
goto
error
;
}
else
}
else
discard
=
true
;
discard
=
true
;
break
;
break
;
}
}
}
}
first
=
false
;
first
=
false
;
if
(
!
discard
)
{
if
(
!
discard
)
{
if
(
tres_corecnt
&&
tres_corecnt
[
0
]
if
(
tres_corecnt
&&
tres_corecnt
[
0
]
!=
'\0'
)
!=
'\0'
)
xstrcatchar
(
tres_corecnt
,
','
);
xstrcatchar
(
tres_corecnt
,
','
);
xstrcat
(
tres_corecnt
,
value_str
);
xstrcat
(
tres_corecnt
,
value_str
);
token
=
strtok_r
(
NULL
,
","
,
&
saveptr1
);
token
=
strtok_r
(
NULL
,
","
,
&
saveptr1
);
...
@@ -284,7 +282,7 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
...
@@ -284,7 +282,7 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
}
else
if
(
strcasecmp
(
type
,
"node"
)
==
0
)
{
}
else
if
(
strcasecmp
(
type
,
"node"
)
==
0
)
{
if
(
tres_nodecnt
&&
tres_nodecnt
[
0
]
!=
'\0'
)
if
(
tres_nodecnt
&&
tres_nodecnt
[
0
]
!=
'\0'
)
xstrcatchar
(
tres_nodecnt
,
','
);
xstrcatchar
(
tres_nodecnt
,
','
);
xstrcat
(
tres_nodecnt
,
value_str
);
xstrcat
(
tres_nodecnt
,
value_str
);
token
=
strtok_r
(
NULL
,
","
,
&
saveptr1
);
token
=
strtok_r
(
NULL
,
","
,
&
saveptr1
);
}
else
{
}
else
{
...
@@ -296,17 +294,19 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
...
@@ -296,17 +294,19 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
}
}
if
(
tres_corecnt
&&
tres_corecnt
[
0
]
!=
'\0'
)
{
if
(
tres_corecnt
&&
tres_corecnt
[
0
]
!=
'\0'
)
{
*
free_tres_corecnt
=
1
;
ret
=
_parse_resv_core_cnt
(
resv_msg_ptr
,
tres_corecnt
,
true
);
ret
=
_parse_resv_core_cnt
(
resv_msg_ptr
,
tres_corecnt
,
true
);
if
(
ret
<
0
)
xfree
(
tres_corecnt
);
if
(
ret
!=
SLURM_SUCCESS
)
goto
error
;
goto
error
;
*
free_tres_corecnt
=
1
;
}
}
if
(
tres_nodecnt
&&
tres_nodecnt
[
0
]
!=
'\0'
)
{
if
(
tres_nodecnt
&&
tres_nodecnt
[
0
]
!=
'\0'
)
{
ret
=
_parse_resv_node_cnt
(
resv_msg_ptr
,
tres_nodecnt
,
true
);
ret
=
_parse_resv_node_cnt
(
resv_msg_ptr
,
tres_nodecnt
,
true
);
*
free
_
tres_nodecnt
=
1
;
x
free
(
tres_nodecnt
)
;
if
(
ret
<
0
)
if
(
ret
!=
SLURM_SUCCESS
)
goto
error
;
goto
error
;
*
free_tres_nodecnt
=
1
;
}
}
if
(
tres_license
&&
tres_license
[
0
]
!=
'\0'
)
{
if
(
tres_license
&&
tres_license
[
0
]
!=
'\0'
)
{
...
@@ -319,18 +319,11 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
...
@@ -319,18 +319,11 @@ static int _parse_resv_tres(char *val, resv_desc_msg_t *resv_msg_ptr,
*
free_tres_bb
=
1
;
*
free_tres_bb
=
1
;
}
}
if
(
tres_corecnt
);
xfree
(
tres_corecnt
);
if
(
tres_nodecnt
);
xfree
(
tres_nodecnt
);
return
SLURM_SUCCESS
;
return
SLURM_SUCCESS
;
error:
error:
if
(
tres_nodecnt
)
xfree
(
tres_nodecnt
);
xfree
(
tres_nodecnt
);
xfree
(
tres_corecnt
);
if
(
tres_corecnt
)
xfree
(
tres_corecnt
);
exit_code
=
1
;
exit_code
=
1
;
return
SLURM_ERROR
;
return
SLURM_ERROR
;
}
}
...
@@ -338,7 +331,7 @@ error:
...
@@ -338,7 +331,7 @@ error:
/*
/*
* scontrol_parse_res_options parse options for creating or updating a
* scontrol_parse_res_options parse options for creating or updating a
reservation
reservation
* IN argc - count of arguments
* IN argc - count of arguments
* IN argv - list of arguments
* IN argv - list of arguments
* IN msg - a string to append to any error message
* IN msg - a string to append to any error message
...
@@ -520,7 +513,7 @@ scontrol_update_res(int argc, char *argv[])
...
@@ -520,7 +513,7 @@ scontrol_update_res(int argc, char *argv[])
resv_desc_msg_t
resv_msg
;
resv_desc_msg_t
resv_msg
;
int
err
,
ret
=
0
;
int
err
,
ret
=
0
;
int
free_user_str
=
0
,
free_acct_str
=
0
,
free_tres_license
=
0
,
int
free_user_str
=
0
,
free_acct_str
=
0
,
free_tres_license
=
0
,
free_tres_bb
=
0
,
free_tres_corecnt
=
0
,
free_tres_nodecnt
=
0
;
free_tres_bb
=
0
,
free_tres_corecnt
=
0
,
free_tres_nodecnt
=
0
;
slurm_init_resv_desc_msg
(
&
resv_msg
);
slurm_init_resv_desc_msg
(
&
resv_msg
);
err
=
scontrol_parse_res_options
(
argc
,
argv
,
"No reservation update."
,
err
=
scontrol_parse_res_options
(
argc
,
argv
,
"No reservation update."
,
...
@@ -576,7 +569,7 @@ scontrol_create_res(int argc, char *argv[])
...
@@ -576,7 +569,7 @@ scontrol_create_res(int argc, char *argv[])
resv_desc_msg_t
resv_msg
;
resv_desc_msg_t
resv_msg
;
char
*
new_res_name
=
NULL
;
char
*
new_res_name
=
NULL
;
int
free_user_str
=
0
,
free_acct_str
=
0
,
free_tres_license
=
0
,
int
free_user_str
=
0
,
free_acct_str
=
0
,
free_tres_license
=
0
,
free_tres_bb
=
0
,
free_tres_corecnt
=
0
,
free_tres_nodecnt
=
0
;
free_tres_bb
=
0
,
free_tres_corecnt
=
0
,
free_tres_nodecnt
=
0
;
int
err
,
ret
=
0
;
int
err
,
ret
=
0
;
slurm_init_resv_desc_msg
(
&
resv_msg
);
slurm_init_resv_desc_msg
(
&
resv_msg
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment