Skip to content
Snippets Groups Projects
Commit f752c736 authored by David Bigagli's avatar David Bigagli
Browse files

Fix indentation and remove spaces.

parent c6e1d4f3
No related branches found
No related tags found
No related merge requests found
...@@ -125,7 +125,7 @@ extern int task_cgroup_devices_fini(slurm_cgroup_conf_t *slurm_cgroup_conf) ...@@ -125,7 +125,7 @@ extern int task_cgroup_devices_fini(slurm_cgroup_conf_t *slurm_cgroup_conf)
xcgroup_destroy(&job_devices_cg); xcgroup_destroy(&job_devices_cg);
if ( jobstep_cgroup_path[0] != '\0' ) if ( jobstep_cgroup_path[0] != '\0' )
xcgroup_destroy(&step_devices_cg); xcgroup_destroy(&step_devices_cg);
user_cgroup_path[0] = '\0'; user_cgroup_path[0] = '\0';
job_cgroup_path[0] = '\0'; job_cgroup_path[0] = '\0';
jobstep_cgroup_path[0] = '\0'; jobstep_cgroup_path[0] = '\0';
...@@ -133,7 +133,7 @@ extern int task_cgroup_devices_fini(slurm_cgroup_conf_t *slurm_cgroup_conf) ...@@ -133,7 +133,7 @@ extern int task_cgroup_devices_fini(slurm_cgroup_conf_t *slurm_cgroup_conf)
cgroup_allowed_devices_file[0] = '\0'; cgroup_allowed_devices_file[0] = '\0';
xcgroup_ns_destroy(&devices_ns); xcgroup_ns_destroy(&devices_ns);
xcpuinfo_fini(); xcpuinfo_fini();
return SLURM_SUCCESS; return SLURM_SUCCESS;
} }
...@@ -143,9 +143,9 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job) ...@@ -143,9 +143,9 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job)
int f, k, rc, gres_conf_lines, allow_lines; int f, k, rc, gres_conf_lines, allow_lines;
int fstatus = SLURM_ERROR; int fstatus = SLURM_ERROR;
char *gres_name[PATH_MAX]; char *gres_name[PATH_MAX];
char *gres_cgroup[PATH_MAX], *dev_path[PATH_MAX]; char *gres_cgroup[PATH_MAX], *dev_path[PATH_MAX];
char *allowed_devices[PATH_MAX], *allowed_dev_major[PATH_MAX]; char *allowed_devices[PATH_MAX], *allowed_dev_major[PATH_MAX];
int *gres_bit_alloc = NULL; int *gres_bit_alloc = NULL;
int *gres_step_bit_alloc = NULL; int *gres_step_bit_alloc = NULL;
int *gres_count = NULL; int *gres_count = NULL;
...@@ -188,7 +188,7 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job) ...@@ -188,7 +188,7 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job)
return SLURM_ERROR; return SLURM_ERROR;
} }
} }
/* build job step cgroup relative path (should not be) */ /* build job step cgroup relative path (should not be) */
if ( *jobstep_cgroup_path == '\0' ) { if ( *jobstep_cgroup_path == '\0' ) {
if ( snprintf(jobstep_cgroup_path,PATH_MAX, "%s/step_%u", if ( snprintf(jobstep_cgroup_path,PATH_MAX, "%s/step_%u",
...@@ -203,11 +203,11 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job) ...@@ -203,11 +203,11 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job)
* create devices root cg and lock it * create devices root cg and lock it
* *
* we will keep the lock until the end to avoid the effect of a release * we will keep the lock until the end to avoid the effect of a release
* agent that would remove an existing cgroup hierarchy while we are * agent that would remove an existing cgroup hierarchy while we are
* setting it up. As soon as the step cgroup is created, we can release * setting it up. As soon as the step cgroup is created, we can release
* the lock. * the lock.
* Indeed, consecutive slurm steps could result in cg being removed * Indeed, consecutive slurm steps could result in cg being removed
* between the next EEXIST instanciation and the first addition of * between the next EEXIST instanciation and the first addition of
* a task. The release_agent will have to lock the root devices cgroup * a task. The release_agent will have to lock the root devices cgroup
* to avoid this scenario. * to avoid this scenario.
*/ */
...@@ -224,34 +224,34 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job) ...@@ -224,34 +224,34 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job)
info("task/cgroup: manage devices jor job '%u'",jobid); info("task/cgroup: manage devices jor job '%u'",jobid);
/* /*
* collect info concerning the gres.conf file * collect info concerning the gres.conf file
* the gres devices paths and the gres names * the gres devices paths and the gres names
*/ */
gres_conf_lines = gres_plugin_node_config_devices_path(dev_path, gres_conf_lines = gres_plugin_node_config_devices_path(dev_path,
gres_name, gres_name,
PATH_MAX, PATH_MAX,
job->node_name); job->node_name);
/* /*
* create the entry for cgroup devices subsystem with major minor * create the entry for cgroup devices subsystem with major minor
*/ */
_calc_device_major(dev_path,gres_cgroup,gres_conf_lines); _calc_device_major(dev_path,gres_cgroup,gres_conf_lines);
allow_lines = read_allowed_devices_file(allowed_devices); allow_lines = read_allowed_devices_file(allowed_devices);
/* /*
* create the entry with major minor for the default allowed devices * create the entry with major minor for the default allowed devices
* read from the file * read from the file
*/ */
_calc_device_major(allowed_devices,allowed_dev_major,allow_lines); _calc_device_major(allowed_devices,allowed_dev_major,allow_lines);
gres_count = xmalloc ( sizeof (int) * (gres_conf_lines) ); gres_count = xmalloc ( sizeof (int) * (gres_conf_lines) );
/* /*
* calculate the number of gres.conf records for each gres name * calculate the number of gres.conf records for each gres name
* *
*/ */
f = 0; f = 0;
gres_count[f] = 1; gres_count[f] = 1;
for (k = 0; k < gres_conf_lines; k++) { for (k = 0; k < gres_conf_lines; k++) {
...@@ -265,7 +265,7 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job) ...@@ -265,7 +265,7 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job)
} }
} }
/* /*
* create user cgroup in the devices ns (it could already exist) * create user cgroup in the devices ns (it could already exist)
*/ */
if ( xcgroup_create(&devices_ns,&user_devices_cg, if ( xcgroup_create(&devices_ns,&user_devices_cg,
...@@ -301,24 +301,24 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job) ...@@ -301,24 +301,24 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job)
} }
gres_bit_alloc = xmalloc ( sizeof (int) * (gres_conf_lines + 1)); gres_bit_alloc = xmalloc ( sizeof (int) * (gres_conf_lines + 1));
/* fetch information concerning the gres devices allocation for the job */ /* fetch information concerning the gres devices allocation for the job */
gres_plugin_job_state_file(job_gres_list, gres_bit_alloc, gres_count); gres_plugin_job_state_file(job_gres_list, gres_bit_alloc, gres_count);
/* /*
* with the current cgroup devices subsystem design (whitelist only supported) * with the current cgroup devices subsystem design (whitelist only supported)
* we need to allow all different devices that are supposed to be allowed by * we need to allow all different devices that are supposed to be allowed by
* default. * default.
*/ */
for (k = 0; k < allow_lines; k++) { for (k = 0; k < allow_lines; k++) {
info("Default access allowed to device %s", allowed_dev_major[k]); info("Default access allowed to device %s", allowed_dev_major[k]);
xcgroup_set_param(&job_devices_cg,"devices.allow", xcgroup_set_param(&job_devices_cg,"devices.allow",
allowed_dev_major[k]); allowed_dev_major[k]);
} }
/* /*
* allow or deny access to devices according to gres permissions for the job * allow or deny access to devices according to gres permissions for the job
*/ */
for (k = 0; k < gres_conf_lines; k++) { for (k = 0; k < gres_conf_lines; k++) {
if (gres_bit_alloc[k] == 1) { if (gres_bit_alloc[k] == 1) {
info("Allowing access to device %s", gres_cgroup[k]); info("Allowing access to device %s", gres_cgroup[k]);
...@@ -331,7 +331,7 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job) ...@@ -331,7 +331,7 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job)
} }
} }
/* /*
* create step cgroup in the devices ns (it should not exists) * create step cgroup in the devices ns (it should not exists)
* use job's user uid/gid to enable tasks cgroups creation by * use job's user uid/gid to enable tasks cgroups creation by
* the user inside the step cgroup owned by root * the user inside the step cgroup owned by root
...@@ -352,26 +352,26 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job) ...@@ -352,26 +352,26 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job)
goto error; goto error;
} }
gres_step_bit_alloc = xmalloc ( sizeof (int) * (gres_conf_lines + 1)); gres_step_bit_alloc = xmalloc ( sizeof (int) * (gres_conf_lines + 1));
/* fetch information concerning the gres devices allocation for the step */ /* fetch information concerning the gres devices allocation for the step */
gres_plugin_step_state_file(step_gres_list, gres_step_bit_alloc, gres_plugin_step_state_file(step_gres_list, gres_step_bit_alloc,
gres_count); gres_count);
/* /*
* with the current cgroup devices subsystem design (whitelist only supported) * with the current cgroup devices subsystem design (whitelist only supported)
* we need to allow all different devices that are supposed to be allowed by * we need to allow all different devices that are supposed to be allowed by
* default. * default.
*/ */
for (k = 0; k < allow_lines; k++) { for (k = 0; k < allow_lines; k++) {
info("Default access allowed to device %s", allowed_dev_major[k]); info("Default access allowed to device %s", allowed_dev_major[k]);
xcgroup_set_param(&step_devices_cg,"devices.allow", xcgroup_set_param(&step_devices_cg,"devices.allow",
allowed_dev_major[k]); allowed_dev_major[k]);
} }
/* /*
* allow or deny access to devices according to gres permissions for the step * allow or deny access to devices according to gres permissions for the step
*/ */
for (k = 0; k < gres_conf_lines; k++) { for (k = 0; k < gres_conf_lines; k++) {
...@@ -387,7 +387,7 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job) ...@@ -387,7 +387,7 @@ extern int task_cgroup_devices_create(stepd_step_rec_t *job)
gres_cgroup[k]); gres_cgroup[k]);
} }
} }
/* attach the slurmstepd to the step devices cgroup */ /* attach the slurmstepd to the step devices cgroup */
pid_t pid = getpid(); pid_t pid = getpid();
rc = xcgroup_add_pids(&step_devices_cg,&pid,1); rc = xcgroup_add_pids(&step_devices_cg,&pid,1);
...@@ -433,10 +433,10 @@ static void _calc_device_major(char *dev_path[PATH_MAX], ...@@ -433,10 +433,10 @@ static void _calc_device_major(char *dev_path[PATH_MAX],
lines = PATH_MAX; lines = PATH_MAX;
} }
for (k = 0; k < lines; k++) { for (k = 0; k < lines; k++) {
stat(dev_path[k], &fs); stat(dev_path[k], &fs);
major = (int)major(fs.st_rdev); major = (int)major(fs.st_rdev);
minor = (int)minor(fs.st_rdev); minor = (int)minor(fs.st_rdev);
debug3("device : %s major %d, minor %d\n", debug3("device : %s major %d, minor %d\n",
dev_path[k], major, minor); dev_path[k], major, minor);
if (S_ISBLK(fs.st_mode)) { if (S_ISBLK(fs.st_mode)) {
sprintf(str1, "b %d:", major); sprintf(str1, "b %d:", major);
...@@ -448,14 +448,14 @@ static void _calc_device_major(char *dev_path[PATH_MAX], ...@@ -448,14 +448,14 @@ static void _calc_device_major(char *dev_path[PATH_MAX],
} }
sprintf(str2, "%d rwm", minor); sprintf(str2, "%d rwm", minor);
strcat(str1, str2); strcat(str1, str2);
dev_major[k] = xstrdup((char *)str1); dev_major[k] = xstrdup((char *)str1);
} }
} }
static int read_allowed_devices_file(char **allowed_devices) static int read_allowed_devices_file(char **allowed_devices)
{ {
FILE *file = fopen (cgroup_allowed_devices_file, "r" ); FILE *file = fopen (cgroup_allowed_devices_file, "r" );
int i, l, num_lines = 0; int i, l, num_lines = 0;
char line[256]; char line[256];
...@@ -467,10 +467,10 @@ static int read_allowed_devices_file(char **allowed_devices) ...@@ -467,10 +467,10 @@ static int read_allowed_devices_file(char **allowed_devices)
if ( file != NULL ){ if ( file != NULL ){
while ( fgets ( line, sizeof line, file ) != NULL ){ while ( fgets ( line, sizeof line, file ) != NULL ){
line[strlen(line)-1] = '\0'; line[strlen(line)-1] = '\0';
/* global pattern matching and return the list of matches*/ /* global pattern matching and return the list of matches*/
if (glob(line, GLOB_NOSORT, NULL, &globbuf) != 0){ if (glob(line, GLOB_NOSORT, NULL, &globbuf) != 0){
debug3("Device %s does not exist", line); debug3("Device %s does not exist", line);
}else{ }else{
for(l=0; l < globbuf.gl_pathc; l++){ for(l=0; l < globbuf.gl_pathc; l++){
allowed_devices[num_lines] = allowed_devices[num_lines] =
...@@ -486,4 +486,3 @@ static int read_allowed_devices_file(char **allowed_devices) ...@@ -486,4 +486,3 @@ static int read_allowed_devices_file(char **allowed_devices)
return num_lines; return num_lines;
} }
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