~ubuntu-branches/ubuntu/vivid/slurm-llnl/vivid

« back to all changes in this revision

Viewing changes to src/common/jobacct_common.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2009-09-24 23:28:15 UTC
  • mfrom: (1.1.11 upstream) (3.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090924232815-enh65jn32q1ebg07
Tags: 2.0.5-1
* New upstream release 
* Changed dependecy from lib-mysqlclient15 to lib-mysqlclient 
* Added Default-Start for runlevel 2 and 4 and $remote_fs requirement in
  init.d scripts (Closes: #541252)
* Postinst checks for wrong runlevels 2 and 4 links
* Upgraded to standard version 3.8.3
* Add lintian overrides for missing slurm-llnl-configurator.html in doc
  base registration
* modified postrm scripts to ignore pkill return value in order to avoid
  postrm failure when no slurm process is running
* Checking for slurmctld.pid before cancelling running and pending
  jobs during package removal 

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 *
5
5
 *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
6
6
 *  Written by Danny Auble, <da@llnl.gov>
7
 
 *  LLNL-CODE-402394.
 
7
 *  CODE-OCEC-09-009. All rights reserved.
8
8
 *  
9
9
 *  This file is part of SLURM, a resource management program.
10
 
 *  For details, see <http://www.llnl.gov/linux/slurm/>.
 
10
 *  For details, see <https://computing.llnl.gov/linux/slurm/>.
 
11
 *  Please also read the included file: DISCLAIMER.
11
12
 *  
12
13
 *  SLURM is free software; you can redistribute it and/or modify it under
13
14
 *  the terms of the GNU General Public License as published by the Free
146
147
        job->steps = list_create(destroy_jobacct_step_rec);
147
148
        job->requid = -1;
148
149
        job->lft = (uint32_t)NO_VAL;
 
150
        job->resvid = (uint32_t)NO_VAL;
149
151
 
150
152
        return job;
151
153
}
212
214
        jobacct_step_rec_t *step = NULL;
213
215
        uint32_t count = 0;
214
216
 
215
 
        if(rpc_version >= 4) {
 
217
        if(rpc_version >= 5) {
 
218
                pack32(job->alloc_cpus, buffer);
 
219
                pack32(job->alloc_nodes, buffer);
 
220
                pack32(job->associd, buffer);
 
221
                packstr(job->account, buffer);
 
222
                packstr(job->blockid, buffer);
 
223
                packstr(job->cluster, buffer);
 
224
                pack32(job->elapsed, buffer);
 
225
                pack_time(job->eligible, buffer);
 
226
                pack_time(job->end, buffer);
 
227
                pack32(job->exitcode, buffer);
 
228
                pack32(job->gid, buffer);
 
229
                pack32(job->jobid, buffer);
 
230
                packstr(job->jobname, buffer);
 
231
                pack32(job->lft, buffer);
 
232
                packstr(job->partition, buffer);
 
233
                packstr(job->nodes, buffer);
 
234
                pack32(job->priority, buffer);
 
235
                pack16(job->qos, buffer);
 
236
                pack32(job->resvid, buffer);
 
237
                pack32(job->req_cpus, buffer);
 
238
                pack32(job->requid, buffer);
 
239
                _pack_sacct(&job->sacct, buffer);
 
240
                pack32(job->show_full, buffer);
 
241
                pack_time(job->start, buffer);
 
242
                pack16((uint16_t)job->state, buffer);
 
243
                if(job->steps)
 
244
                        count = list_count(job->steps);
 
245
                pack32(count, buffer);
 
246
                if(count) {
 
247
                        itr = list_iterator_create(job->steps);
 
248
                        while((step = list_next(itr))) {
 
249
                                pack_jobacct_step_rec(step, rpc_version,
 
250
                                                      buffer);
 
251
                        }
 
252
                        list_iterator_destroy(itr);
 
253
                }
 
254
                pack_time(job->submit, buffer);
 
255
                pack32(job->suspended, buffer);
 
256
                pack32(job->sys_cpu_sec, buffer);
 
257
                pack32(job->sys_cpu_usec, buffer);
 
258
                pack32(job->timelimit, buffer);
 
259
                pack32(job->tot_cpu_sec, buffer);
 
260
                pack32(job->tot_cpu_usec, buffer);
 
261
                pack16(job->track_steps, buffer);
 
262
                pack32(job->uid, buffer);
 
263
                packstr(job->user, buffer);
 
264
                pack32(job->user_cpu_sec, buffer);
 
265
                pack32(job->user_cpu_usec, buffer);
 
266
                packstr(job->wckey, buffer); /* added for rpc_version 4 */
 
267
                pack32(job->wckeyid, buffer); /* added for rpc_version 4 */
 
268
        } else if(rpc_version >= 4) {
216
269
                pack32(job->alloc_cpus, buffer);
217
270
                pack32(job->associd, buffer);
218
271
                packstr(job->account, buffer);
320
373
 
321
374
        *job = job_ptr;
322
375
 
323
 
        if(rpc_version >= 4) {
324
 
                safe_unpack32(&job_ptr->alloc_cpus, buffer);
325
 
                safe_unpack32(&job_ptr->associd, buffer);
326
 
                safe_unpackstr_xmalloc(&job_ptr->account, &uint32_tmp, buffer);
327
 
                safe_unpackstr_xmalloc(&job_ptr->blockid, &uint32_tmp, buffer);
328
 
                safe_unpackstr_xmalloc(&job_ptr->cluster, &uint32_tmp, buffer);
329
 
                safe_unpack32(&job_ptr->elapsed, buffer);
330
 
                safe_unpack_time(&job_ptr->eligible, buffer);
331
 
                safe_unpack_time(&job_ptr->end, buffer);
332
 
                safe_unpack32(&uint32_tmp, buffer);
333
 
                job_ptr->exitcode = (int32_t)uint32_tmp;
334
 
                safe_unpack32(&job_ptr->gid, buffer);
335
 
                safe_unpack32(&job_ptr->jobid, buffer);
336
 
                safe_unpackstr_xmalloc(&job_ptr->jobname, &uint32_tmp, buffer);
337
 
                safe_unpack32(&job_ptr->lft, buffer);
338
 
                safe_unpackstr_xmalloc(&job_ptr->partition, &uint32_tmp,
339
 
                                       buffer);
340
 
                safe_unpackstr_xmalloc(&job_ptr->nodes, &uint32_tmp, buffer);
341
 
                safe_unpack32(&uint32_tmp, buffer);
342
 
                job_ptr->priority = (int32_t)uint32_tmp;
343
 
                safe_unpack16(&job_ptr->qos, buffer);
344
 
                safe_unpack32(&job_ptr->req_cpus, buffer);
345
 
                safe_unpack32(&job_ptr->requid, buffer);
346
 
                _pack_sacct(&job_ptr->sacct, buffer);
347
 
                safe_unpack32(&job_ptr->show_full, buffer);
348
 
                safe_unpack_time(&job_ptr->start, buffer);
349
 
                safe_unpack16(&uint16_tmp, buffer);
350
 
                job_ptr->state = uint16_tmp;
351
 
                safe_unpack32(&count, buffer);
352
 
 
353
 
                job_ptr->steps = list_create(destroy_jobacct_step_rec);
354
 
                for(i=0; i<count; i++) {
355
 
                        unpack_jobacct_step_rec(&step, rpc_version, buffer);
356
 
                        if(step)
357
 
                                list_append(job_ptr->steps, step);
 
376
        if(rpc_version >= 5) {
 
377
                safe_unpack32(&job_ptr->alloc_cpus, buffer);
 
378
                safe_unpack32(&job_ptr->alloc_nodes, buffer);
 
379
                safe_unpack32(&job_ptr->associd, buffer);
 
380
                safe_unpackstr_xmalloc(&job_ptr->account, &uint32_tmp, buffer);
 
381
                safe_unpackstr_xmalloc(&job_ptr->blockid, &uint32_tmp, buffer);
 
382
                safe_unpackstr_xmalloc(&job_ptr->cluster, &uint32_tmp, buffer);
 
383
                safe_unpack32(&job_ptr->elapsed, buffer);
 
384
                safe_unpack_time(&job_ptr->eligible, buffer);
 
385
                safe_unpack_time(&job_ptr->end, buffer);
 
386
                safe_unpack32(&uint32_tmp, buffer);
 
387
                job_ptr->exitcode = (int32_t)uint32_tmp;
 
388
                safe_unpack32(&job_ptr->gid, buffer);
 
389
                safe_unpack32(&job_ptr->jobid, buffer);
 
390
                safe_unpackstr_xmalloc(&job_ptr->jobname, &uint32_tmp, buffer);
 
391
                safe_unpack32(&job_ptr->lft, buffer);
 
392
                safe_unpackstr_xmalloc(&job_ptr->partition, &uint32_tmp,
 
393
                                       buffer);
 
394
                safe_unpackstr_xmalloc(&job_ptr->nodes, &uint32_tmp, buffer);
 
395
                safe_unpack32(&job_ptr->priority, buffer);
 
396
                safe_unpack16(&job_ptr->qos, buffer);
 
397
                safe_unpack32(&job_ptr->resvid, buffer);
 
398
                safe_unpack32(&job_ptr->req_cpus, buffer);
 
399
                safe_unpack32(&job_ptr->requid, buffer);
 
400
                _pack_sacct(&job_ptr->sacct, buffer);
 
401
                safe_unpack32(&job_ptr->show_full, buffer);
 
402
                safe_unpack_time(&job_ptr->start, buffer);
 
403
                safe_unpack16(&uint16_tmp, buffer);
 
404
                job_ptr->state = uint16_tmp;
 
405
                safe_unpack32(&count, buffer);
 
406
 
 
407
                job_ptr->steps = list_create(destroy_jobacct_step_rec);
 
408
                for(i=0; i<count; i++) {
 
409
                        unpack_jobacct_step_rec(&step, rpc_version, buffer);
 
410
                        if(step) {
 
411
                                step->job_ptr = job_ptr;
 
412
                                if(!job_ptr->first_step_ptr)
 
413
                                        job_ptr->first_step_ptr = step;
 
414
                                list_append(job_ptr->steps, step);
 
415
                        }
 
416
                }
 
417
 
 
418
                safe_unpack_time(&job_ptr->submit, buffer);
 
419
                safe_unpack32(&job_ptr->suspended, buffer);
 
420
                safe_unpack32(&job_ptr->sys_cpu_sec, buffer);
 
421
                safe_unpack32(&job_ptr->sys_cpu_usec, buffer);
 
422
                safe_unpack32(&job_ptr->timelimit, buffer);
 
423
                safe_unpack32(&job_ptr->tot_cpu_sec, buffer);
 
424
                safe_unpack32(&job_ptr->tot_cpu_usec, buffer);
 
425
                safe_unpack16(&job_ptr->track_steps, buffer);
 
426
                safe_unpack32(&job_ptr->uid, buffer);
 
427
                safe_unpackstr_xmalloc(&job_ptr->user, &uint32_tmp, buffer);
 
428
                safe_unpack32(&job_ptr->user_cpu_sec, buffer);
 
429
                safe_unpack32(&job_ptr->user_cpu_usec, buffer);
 
430
                safe_unpackstr_xmalloc(&job_ptr->wckey, &uint32_tmp, buffer);
 
431
                safe_unpack32(&job_ptr->wckeyid, buffer);
 
432
        } else if(rpc_version >= 4) {
 
433
                safe_unpack32(&job_ptr->alloc_cpus, buffer);
 
434
                safe_unpack32(&job_ptr->associd, buffer);
 
435
                safe_unpackstr_xmalloc(&job_ptr->account, &uint32_tmp, buffer);
 
436
                safe_unpackstr_xmalloc(&job_ptr->blockid, &uint32_tmp, buffer);
 
437
                safe_unpackstr_xmalloc(&job_ptr->cluster, &uint32_tmp, buffer);
 
438
                safe_unpack32(&job_ptr->elapsed, buffer);
 
439
                safe_unpack_time(&job_ptr->eligible, buffer);
 
440
                safe_unpack_time(&job_ptr->end, buffer);
 
441
                safe_unpack32(&uint32_tmp, buffer);
 
442
                job_ptr->exitcode = (int32_t)uint32_tmp;
 
443
                safe_unpack32(&job_ptr->gid, buffer);
 
444
                safe_unpack32(&job_ptr->jobid, buffer);
 
445
                safe_unpackstr_xmalloc(&job_ptr->jobname, &uint32_tmp, buffer);
 
446
                safe_unpack32(&job_ptr->lft, buffer);
 
447
                safe_unpackstr_xmalloc(&job_ptr->partition, &uint32_tmp,
 
448
                                       buffer);
 
449
                safe_unpackstr_xmalloc(&job_ptr->nodes, &uint32_tmp, buffer);
 
450
                safe_unpack32(&job_ptr->priority, buffer);
 
451
                safe_unpack16(&job_ptr->qos, buffer);
 
452
                safe_unpack32(&job_ptr->req_cpus, buffer);
 
453
                safe_unpack32(&job_ptr->requid, buffer);
 
454
                _pack_sacct(&job_ptr->sacct, buffer);
 
455
                safe_unpack32(&job_ptr->show_full, buffer);
 
456
                safe_unpack_time(&job_ptr->start, buffer);
 
457
                safe_unpack16(&uint16_tmp, buffer);
 
458
                job_ptr->state = uint16_tmp;
 
459
                safe_unpack32(&count, buffer);
 
460
 
 
461
                job_ptr->steps = list_create(destroy_jobacct_step_rec);
 
462
                for(i=0; i<count; i++) {
 
463
                        unpack_jobacct_step_rec(&step, rpc_version, buffer);
 
464
                        if(step) {
 
465
                                step->job_ptr = job_ptr;
 
466
                                if(!job_ptr->first_step_ptr)
 
467
                                        job_ptr->first_step_ptr = step;
 
468
                                list_append(job_ptr->steps, step);
 
469
                        }
358
470
                }
359
471
 
360
472
                safe_unpack_time(&job_ptr->submit, buffer);
399
511
                safe_unpack16(&uint16_tmp, buffer);
400
512
                job_ptr->state = uint16_tmp;
401
513
                safe_unpack32(&count, buffer);
402
 
 
403
514
                job_ptr->steps = list_create(destroy_jobacct_step_rec);
404
515
                for(i=0; i<count; i++) {
405
516
                        unpack_jobacct_step_rec(&step, rpc_version, buffer);
406
 
                        if(step)
 
517
                        if(step) {
 
518
                                step->job_ptr = job_ptr;
 
519
                                if(!job_ptr->first_step_ptr)
 
520
                                        job_ptr->first_step_ptr = step;
407
521
                                list_append(job_ptr->steps, step);
 
522
                        }
408
523
                }
409
524
 
410
525
                safe_unpack_time(&job_ptr->submit, buffer);
431
546
extern void pack_jobacct_step_rec(jobacct_step_rec_t *step, 
432
547
                                  uint16_t rpc_version, Buf buffer)
433
548
{
434
 
        pack32(step->elapsed, buffer);
435
 
        pack_time(step->end, buffer);
436
 
        pack32((uint32_t)step->exitcode, buffer);
437
 
        pack32(step->jobid, buffer);
438
 
        pack32(step->ncpus, buffer);
439
 
        packstr(step->nodes, buffer);
440
 
        pack32(step->requid, buffer);
441
 
        _pack_sacct(&step->sacct, buffer);
442
 
        pack_time(step->start, buffer);
443
 
        pack16(step->state, buffer);
444
 
        pack32(step->stepid, buffer);   /* job's step number */
445
 
        packstr(step->stepname, buffer);
446
 
        pack32(step->suspended, buffer);
447
 
        pack32(step->sys_cpu_sec, buffer);
448
 
        pack32(step->sys_cpu_usec, buffer);
449
 
        pack32(step->tot_cpu_sec, buffer);
450
 
        pack32(step->tot_cpu_usec, buffer);
451
 
        pack32(step->user_cpu_sec, buffer);
452
 
        pack32(step->user_cpu_usec, buffer);
 
549
        uint32_t uint32_tmp = NO_VAL;
 
550
 
 
551
        if(rpc_version >= 5) {
 
552
                pack32(step->elapsed, buffer);
 
553
                pack_time(step->end, buffer);
 
554
                pack32((uint32_t)step->exitcode, buffer);
 
555
                pack32(step->ncpus, buffer);
 
556
                pack32(step->nnodes, buffer);
 
557
                packstr(step->nodes, buffer);
 
558
                pack32(step->ntasks, buffer);
 
559
                pack32(step->requid, buffer);
 
560
                _pack_sacct(&step->sacct, buffer);
 
561
                pack_time(step->start, buffer);
 
562
                pack16(step->state, buffer);
 
563
                pack32(step->stepid, buffer);   /* job's step number */
 
564
                packstr(step->stepname, buffer);
 
565
                pack32(step->suspended, buffer);
 
566
                pack32(step->sys_cpu_sec, buffer);
 
567
                pack32(step->sys_cpu_usec, buffer);
 
568
                pack16(step->task_dist, buffer);
 
569
                pack32(step->tot_cpu_sec, buffer);
 
570
                pack32(step->tot_cpu_usec, buffer);
 
571
                pack32(step->user_cpu_sec, buffer);
 
572
                pack32(step->user_cpu_usec, buffer);
 
573
        } else {
 
574
                pack32(step->elapsed, buffer);
 
575
                pack_time(step->end, buffer);
 
576
                pack32((uint32_t)step->exitcode, buffer);
 
577
                pack32(uint32_tmp, buffer);
 
578
                pack32(step->ncpus, buffer);
 
579
                packstr(step->nodes, buffer);
 
580
                pack32(step->requid, buffer);
 
581
                _pack_sacct(&step->sacct, buffer);
 
582
                pack_time(step->start, buffer);
 
583
                pack16(step->state, buffer);
 
584
                pack32(step->stepid, buffer);   /* job's step number */
 
585
                packstr(step->stepname, buffer);
 
586
                pack32(step->suspended, buffer);
 
587
                pack32(step->sys_cpu_sec, buffer);
 
588
                pack32(step->sys_cpu_usec, buffer);
 
589
                pack32(step->tot_cpu_sec, buffer);
 
590
                pack32(step->tot_cpu_usec, buffer);
 
591
                pack32(step->user_cpu_sec, buffer);
 
592
                pack32(step->user_cpu_usec, buffer);
 
593
        }
453
594
}
454
595
 
455
596
extern int unpack_jobacct_step_rec(jobacct_step_rec_t **step, 
461
602
 
462
603
        *step = step_ptr;
463
604
 
464
 
        safe_unpack32(&step_ptr->elapsed, buffer);
465
 
        safe_unpack_time(&step_ptr->end, buffer);
466
 
        safe_unpack32(&uint32_tmp, buffer);
467
 
        step_ptr->exitcode = (int32_t)uint32_tmp;
468
 
        safe_unpack32(&step_ptr->jobid, buffer);
469
 
        safe_unpack32(&step_ptr->ncpus, buffer);
470
 
        safe_unpackstr_xmalloc(&step_ptr->nodes, &uint32_tmp, buffer);
471
 
        safe_unpack32(&step_ptr->requid, buffer);
472
 
        _unpack_sacct(&step_ptr->sacct, buffer);
473
 
        safe_unpack_time(&step_ptr->start, buffer);
474
 
        safe_unpack16(&uint16_tmp, buffer);
475
 
        step_ptr->state = uint16_tmp;
476
 
        safe_unpack32(&step_ptr->stepid, buffer);       /* job's step number */
477
 
        safe_unpackstr_xmalloc(&step_ptr->stepname, &uint32_tmp, buffer);
478
 
        safe_unpack32(&step_ptr->suspended, buffer);
479
 
        safe_unpack32(&step_ptr->sys_cpu_sec, buffer);
480
 
        safe_unpack32(&step_ptr->sys_cpu_usec, buffer);
481
 
        safe_unpack32(&step_ptr->tot_cpu_sec, buffer);
482
 
        safe_unpack32(&step_ptr->tot_cpu_usec, buffer);
483
 
        safe_unpack32(&step_ptr->user_cpu_sec, buffer);
484
 
        safe_unpack32(&step_ptr->user_cpu_usec, buffer);
485
 
 
 
605
        if(rpc_version >= 5) {
 
606
                safe_unpack32(&step_ptr->elapsed, buffer);
 
607
                safe_unpack_time(&step_ptr->end, buffer);
 
608
                safe_unpack32(&uint32_tmp, buffer);
 
609
                step_ptr->exitcode = (int32_t)uint32_tmp;
 
610
                safe_unpack32(&step_ptr->ncpus, buffer);
 
611
                safe_unpack32(&step_ptr->nnodes, buffer);
 
612
                safe_unpackstr_xmalloc(&step_ptr->nodes, &uint32_tmp, buffer);
 
613
                safe_unpack32(&step_ptr->ntasks, buffer);
 
614
                safe_unpack32(&step_ptr->requid, buffer);
 
615
                _unpack_sacct(&step_ptr->sacct, buffer);
 
616
                safe_unpack_time(&step_ptr->start, buffer);
 
617
                safe_unpack16(&uint16_tmp, buffer);
 
618
                step_ptr->state = uint16_tmp;
 
619
                safe_unpack32(&step_ptr->stepid, buffer);
 
620
                safe_unpackstr_xmalloc(&step_ptr->stepname,
 
621
                                       &uint32_tmp, buffer);
 
622
                safe_unpack32(&step_ptr->suspended, buffer);
 
623
                safe_unpack32(&step_ptr->sys_cpu_sec, buffer);
 
624
                safe_unpack32(&step_ptr->sys_cpu_usec, buffer);
 
625
                safe_unpack16(&step_ptr->task_dist, buffer);
 
626
                safe_unpack32(&step_ptr->tot_cpu_sec, buffer);
 
627
                safe_unpack32(&step_ptr->tot_cpu_usec, buffer);
 
628
                safe_unpack32(&step_ptr->user_cpu_sec, buffer);
 
629
                safe_unpack32(&step_ptr->user_cpu_usec, buffer);
 
630
        } else {
 
631
                safe_unpack32(&step_ptr->elapsed, buffer);
 
632
                safe_unpack_time(&step_ptr->end, buffer);
 
633
                safe_unpack32(&uint32_tmp, buffer);
 
634
                step_ptr->exitcode = (int32_t)uint32_tmp;
 
635
                safe_unpack32(&uint32_tmp, buffer);
 
636
                safe_unpack32(&step_ptr->ncpus, buffer);
 
637
                safe_unpackstr_xmalloc(&step_ptr->nodes, &uint32_tmp, buffer);
 
638
                safe_unpack32(&step_ptr->requid, buffer);
 
639
                _unpack_sacct(&step_ptr->sacct, buffer);
 
640
                safe_unpack_time(&step_ptr->start, buffer);
 
641
                safe_unpack16(&uint16_tmp, buffer);
 
642
                step_ptr->state = uint16_tmp;
 
643
                safe_unpack32(&step_ptr->stepid, buffer);       /* job's step number */
 
644
                safe_unpackstr_xmalloc(&step_ptr->stepname, &uint32_tmp, buffer);
 
645
                safe_unpack32(&step_ptr->suspended, buffer);
 
646
                safe_unpack32(&step_ptr->sys_cpu_sec, buffer);
 
647
                safe_unpack32(&step_ptr->sys_cpu_usec, buffer);
 
648
                safe_unpack32(&step_ptr->tot_cpu_sec, buffer);
 
649
                safe_unpack32(&step_ptr->tot_cpu_usec, buffer);
 
650
                safe_unpack32(&step_ptr->user_cpu_sec, buffer);
 
651
                safe_unpack32(&step_ptr->user_cpu_usec, buffer);
 
652
        }
486
653
        return SLURM_SUCCESS;
487
654
 
488
655
unpack_error: