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
b6f08418
Commit
b6f08418
authored
8 years ago
by
Tim Wickberg
Browse files
Options
Downloads
Patches
Plain Diff
Simplify code now that try_lock_slurmctld() is gone.
parent
13cd94c2
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/slurmctld/locks.c
+14
-27
14 additions, 27 deletions
src/slurmctld/locks.c
with
14 additions
and
27 deletions
src/slurmctld/locks.c
+
14
−
27
View file @
b6f08418
...
@@ -52,9 +52,9 @@ static pthread_mutex_t state_mutex = PTHREAD_MUTEX_INITIALIZER;
...
@@ -52,9 +52,9 @@ static pthread_mutex_t state_mutex = PTHREAD_MUTEX_INITIALIZER;
static
slurmctld_lock_flags_t
slurmctld_locks
;
static
slurmctld_lock_flags_t
slurmctld_locks
;
static
int
kill_thread
=
0
;
static
int
kill_thread
=
0
;
static
bool
_wr_rdlock
(
lock_datatype_t
datatype
,
bool
wait_lock
);
static
void
_wr_rdlock
(
lock_datatype_t
datatype
);
static
void
_wr_rdunlock
(
lock_datatype_t
datatype
);
static
void
_wr_rdunlock
(
lock_datatype_t
datatype
);
static
bool
_wr_wrlock
(
lock_datatype_t
datatype
,
bool
wait_lock
);
static
void
_wr_wrlock
(
lock_datatype_t
datatype
);
static
void
_wr_wrunlock
(
lock_datatype_t
datatype
);
static
void
_wr_wrunlock
(
lock_datatype_t
datatype
);
/* init_locks - create locks used for slurmctld data structure access
/* init_locks - create locks used for slurmctld data structure access
...
@@ -69,29 +69,29 @@ void init_locks(void)
...
@@ -69,29 +69,29 @@ void init_locks(void)
extern
void
lock_slurmctld
(
slurmctld_lock_t
lock_levels
)
extern
void
lock_slurmctld
(
slurmctld_lock_t
lock_levels
)
{
{
if
(
lock_levels
.
config
==
READ_LOCK
)
if
(
lock_levels
.
config
==
READ_LOCK
)
(
void
)
_wr_rdlock
(
CONFIG_LOCK
,
true
);
_wr_rdlock
(
CONFIG_LOCK
);
else
if
(
lock_levels
.
config
==
WRITE_LOCK
)
else
if
(
lock_levels
.
config
==
WRITE_LOCK
)
(
void
)
_wr_wrlock
(
CONFIG_LOCK
,
true
);
_wr_wrlock
(
CONFIG_LOCK
);
if
(
lock_levels
.
job
==
READ_LOCK
)
if
(
lock_levels
.
job
==
READ_LOCK
)
(
void
)
_wr_rdlock
(
JOB_LOCK
,
true
);
_wr_rdlock
(
JOB_LOCK
);
else
if
(
lock_levels
.
job
==
WRITE_LOCK
)
else
if
(
lock_levels
.
job
==
WRITE_LOCK
)
(
void
)
_wr_wrlock
(
JOB_LOCK
,
true
);
_wr_wrlock
(
JOB_LOCK
);
if
(
lock_levels
.
node
==
READ_LOCK
)
if
(
lock_levels
.
node
==
READ_LOCK
)
(
void
)
_wr_rdlock
(
NODE_LOCK
,
true
);
_wr_rdlock
(
NODE_LOCK
);
else
if
(
lock_levels
.
node
==
WRITE_LOCK
)
else
if
(
lock_levels
.
node
==
WRITE_LOCK
)
(
void
)
_wr_wrlock
(
NODE_LOCK
,
true
);
_wr_wrlock
(
NODE_LOCK
);
if
(
lock_levels
.
partition
==
READ_LOCK
)
if
(
lock_levels
.
partition
==
READ_LOCK
)
(
void
)
_wr_rdlock
(
PART_LOCK
,
true
);
_wr_rdlock
(
PART_LOCK
);
else
if
(
lock_levels
.
partition
==
WRITE_LOCK
)
else
if
(
lock_levels
.
partition
==
WRITE_LOCK
)
(
void
)
_wr_wrlock
(
PART_LOCK
,
true
);
_wr_wrlock
(
PART_LOCK
);
if
(
lock_levels
.
federation
==
READ_LOCK
)
if
(
lock_levels
.
federation
==
READ_LOCK
)
(
void
)
_wr_rdlock
(
FED_LOCK
,
true
);
_wr_rdlock
(
FED_LOCK
);
else
if
(
lock_levels
.
federation
==
WRITE_LOCK
)
else
if
(
lock_levels
.
federation
==
WRITE_LOCK
)
(
void
)
_wr_wrlock
(
FED_LOCK
,
true
);
_wr_wrlock
(
FED_LOCK
);
}
}
/* unlock_slurmctld - Issue the required unlock requests in a well
/* unlock_slurmctld - Issue the required unlock requests in a well
...
@@ -130,10 +130,8 @@ extern void unlock_slurmctld(slurmctld_lock_t lock_levels)
...
@@ -130,10 +130,8 @@ extern void unlock_slurmctld(slurmctld_lock_t lock_levels)
*
*
* NOTE: Always favoring write locks could result in starvation for
* NOTE: Always favoring write locks could result in starvation for
* read locks. */
* read locks. */
static
bool
_wr_rdlock
(
lock_datatype_t
datatype
,
bool
wait_lock
)
static
void
_wr_rdlock
(
lock_datatype_t
datatype
)
{
{
bool
success
=
true
;
slurm_mutex_lock
(
&
locks_mutex
);
slurm_mutex_lock
(
&
locks_mutex
);
while
(
1
)
{
while
(
1
)
{
if
((
slurmctld_locks
.
entity
[
write_lock
(
datatype
)]
==
0
)
&&
if
((
slurmctld_locks
.
entity
[
write_lock
(
datatype
)]
==
0
)
&&
...
@@ -141,9 +139,6 @@ static bool _wr_rdlock(lock_datatype_t datatype, bool wait_lock)
...
@@ -141,9 +139,6 @@ static bool _wr_rdlock(lock_datatype_t datatype, bool wait_lock)
slurmctld_locks
.
entity
[
read_lock
(
datatype
)]
++
;
slurmctld_locks
.
entity
[
read_lock
(
datatype
)]
++
;
slurmctld_locks
.
entity
[
write_cnt_lock
(
datatype
)]
=
0
;
slurmctld_locks
.
entity
[
write_cnt_lock
(
datatype
)]
=
0
;
break
;
break
;
}
else
if
(
!
wait_lock
)
{
success
=
false
;
break
;
}
else
{
/* wait for state change and retry */
}
else
{
/* wait for state change and retry */
slurm_cond_wait
(
&
locks_cond
,
&
locks_mutex
);
slurm_cond_wait
(
&
locks_cond
,
&
locks_mutex
);
if
(
kill_thread
)
if
(
kill_thread
)
...
@@ -151,7 +146,6 @@ static bool _wr_rdlock(lock_datatype_t datatype, bool wait_lock)
...
@@ -151,7 +146,6 @@ static bool _wr_rdlock(lock_datatype_t datatype, bool wait_lock)
}
}
}
}
slurm_mutex_unlock
(
&
locks_mutex
);
slurm_mutex_unlock
(
&
locks_mutex
);
return
success
;
}
}
/* _wr_rdunlock - Issue a read unlock on the specified data type */
/* _wr_rdunlock - Issue a read unlock on the specified data type */
...
@@ -164,10 +158,8 @@ static void _wr_rdunlock(lock_datatype_t datatype)
...
@@ -164,10 +158,8 @@ static void _wr_rdunlock(lock_datatype_t datatype)
}
}
/* _wr_wrlock - Issue a write lock on the specified data type */
/* _wr_wrlock - Issue a write lock on the specified data type */
static
bool
_wr_wrlock
(
lock_datatype_t
datatype
,
bool
wait_lock
)
static
void
_wr_wrlock
(
lock_datatype_t
datatype
)
{
{
bool
success
=
true
;
slurm_mutex_lock
(
&
locks_mutex
);
slurm_mutex_lock
(
&
locks_mutex
);
slurmctld_locks
.
entity
[
write_wait_lock
(
datatype
)]
++
;
slurmctld_locks
.
entity
[
write_wait_lock
(
datatype
)]
++
;
...
@@ -178,10 +170,6 @@ static bool _wr_wrlock(lock_datatype_t datatype, bool wait_lock)
...
@@ -178,10 +170,6 @@ static bool _wr_wrlock(lock_datatype_t datatype, bool wait_lock)
slurmctld_locks
.
entity
[
write_wait_lock
(
datatype
)]
--
;
slurmctld_locks
.
entity
[
write_wait_lock
(
datatype
)]
--
;
slurmctld_locks
.
entity
[
write_cnt_lock
(
datatype
)]
++
;
slurmctld_locks
.
entity
[
write_cnt_lock
(
datatype
)]
++
;
break
;
break
;
}
else
if
(
!
wait_lock
)
{
slurmctld_locks
.
entity
[
write_wait_lock
(
datatype
)]
--
;
success
=
false
;
break
;
}
else
{
/* wait for state change and retry */
}
else
{
/* wait for state change and retry */
slurm_cond_wait
(
&
locks_cond
,
&
locks_mutex
);
slurm_cond_wait
(
&
locks_cond
,
&
locks_mutex
);
if
(
kill_thread
)
if
(
kill_thread
)
...
@@ -189,7 +177,6 @@ static bool _wr_wrlock(lock_datatype_t datatype, bool wait_lock)
...
@@ -189,7 +177,6 @@ static bool _wr_wrlock(lock_datatype_t datatype, bool wait_lock)
}
}
}
}
slurm_mutex_unlock
(
&
locks_mutex
);
slurm_mutex_unlock
(
&
locks_mutex
);
return
success
;
}
}
/* _wr_wrunlock - Issue a write unlock on the specified data type */
/* _wr_wrunlock - Issue a write unlock on the specified data type */
...
...
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