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

« back to all changes in this revision

Viewing changes to src/plugins/select/bluegene/plugin/bg_record_functions.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:
8
8
 *  Written by Danny Auble <da@llnl.gov>
9
9
 *  
10
10
 *  This file is part of SLURM, a resource management program.
11
 
 *  For details, see <http://www.llnl.gov/linux/slurm/>.
 
11
 *  For details, see <https://computing.llnl.gov/linux/slurm/>.
 
12
 *  Please also read the included file: DISCLAIMER.
12
13
 *  
13
14
 *  SLURM is free software; you can redistribute it and/or modify it under
14
15
 *  the terms of the GNU General Public License as published by the Free
44
45
#include "src/slurmctld/locks.h"
45
46
 
46
47
/* some local functions */
47
 
#ifdef HAVE_BG
48
48
static int  _addto_node_list(bg_record_t *bg_record, int *start, int *end);
49
49
static int  _ba_node_cmpf_inc(ba_node_t *node_a, ba_node_t *node_b);
50
 
#endif
51
50
 
52
51
extern void print_bg_record(bg_record_t* bg_record)
53
52
{
163
162
 
164
163
extern void process_nodes(bg_record_t *bg_record, bool startup)
165
164
{
166
 
#ifdef HAVE_BG
167
165
        int j=0, number;
168
166
        int diff=0;
169
167
        int largest_diff=-1;
170
168
        int best_start[BA_SYSTEM_DIMENSIONS];
171
169
        int start[BA_SYSTEM_DIMENSIONS];
172
170
        int end[BA_SYSTEM_DIMENSIONS];
 
171
        bool start_set=0;
173
172
        ListIterator itr;
174
173
        ba_node_t* ba_node = NULL;
175
174
        
182
181
                memset(&best_start, 0, sizeof(best_start));
183
182
                bg_record->bp_count = 0;
184
183
                if((bg_record->conn_type >= SELECT_SMALL) && (!startup))
185
 
                        error("We shouldn't be here there could be some "
 
184
                        error("process_nodes: "
 
185
                              "We shouldn't be here there could be some "
186
186
                              "badness if we use this logic %s",
187
187
                              bg_record->nodes);
188
188
                while (bg_record->nodes[j] != '\0') {
217
217
                                        best_start[X] = start[X];
218
218
                                        best_start[Y] = start[Y];
219
219
                                        best_start[Z] = start[Z];
220
 
                                        debug3("start is now %dx%dx%d",
 
220
                                        debug3("process_nodes: "
 
221
                                               "start is now %dx%dx%d",
221
222
                                               best_start[X],
222
223
                                               best_start[Y],
223
224
                                               best_start[Z]);
250
251
                                        best_start[X] = start[X];
251
252
                                        best_start[Y] = start[Y];
252
253
                                        best_start[Z] = start[Z];
253
 
                                        debug3("start is now %dx%dx%d",
 
254
                                        debug3("process_nodes: "
 
255
                                               "start is now %dx%dx%d",
254
256
                                               best_start[X],
255
257
                                               best_start[Y],
256
258
                                               best_start[Z]);
272
274
                bg_record->start[X] = best_start[X];
273
275
                bg_record->start[Y] = best_start[Y];
274
276
                bg_record->start[Z] = best_start[Z];
275
 
                debug2("start is %dx%dx%d",
 
277
                start_set = 1;
 
278
                debug2("process_nodes: "
 
279
                       "start is %dx%dx%d",
276
280
                       bg_record->start[X],
277
281
                       bg_record->start[Y],
278
282
                       bg_record->start[Z]);
284
288
        end[X] = -1;
285
289
        end[Y] = -1;
286
290
        end[Z] = -1;
 
291
        if(!start_set) {
 
292
                bg_record->start[X] = HOSTLIST_BASE;
 
293
                bg_record->start[Y] = HOSTLIST_BASE;
 
294
                bg_record->start[Z] = HOSTLIST_BASE;
 
295
        }
287
296
 
288
297
        list_sort(bg_record->bg_block_list, (ListCmpF) _ba_node_cmpf_inc);
289
298
 
291
300
        while ((ba_node = list_next(itr)) != NULL) {
292
301
                if(!ba_node->used)
293
302
                        continue;
294
 
                debug4("%c%c%c is included in this block",
 
303
                debug4("process_nodes: "
 
304
                       "%c%c%c is included in this block",
295
305
                       alpha_num[ba_node->coord[X]],
296
306
                       alpha_num[ba_node->coord[Y]],
297
307
                       alpha_num[ba_node->coord[Z]]);
308
318
                        bg_record->geo[Z]++;
309
319
                        end[Z] = ba_node->coord[Z];
310
320
                }
 
321
                if(!start_set) {
 
322
                        if(ba_node->coord[X]<bg_record->start[X]) {
 
323
                                bg_record->start[X] = ba_node->coord[X];
 
324
                        }
 
325
                        if(ba_node->coord[Y]<bg_record->start[Y]) {
 
326
                                bg_record->start[Y] = ba_node->coord[Y];
 
327
                        }
 
328
                        if(ba_node->coord[Z]<bg_record->start[Z]) {
 
329
                                bg_record->start[Z] = ba_node->coord[Z];
 
330
                        }
 
331
                }
311
332
        }
312
333
        list_iterator_destroy(itr);
313
 
        debug3("geo = %c%c%c bp count is %d\n",
 
334
        debug3("process_nodes: "
 
335
               "geo = %c%c%c bp count is %d start is %c%c%c\n",
314
336
               alpha_num[bg_record->geo[X]],
315
337
               alpha_num[bg_record->geo[Y]],
316
338
               alpha_num[bg_record->geo[Z]],
317
 
               bg_record->bp_count);
 
339
               bg_record->bp_count,
 
340
               alpha_num[bg_record->start[X]],
 
341
               alpha_num[bg_record->start[Y]],
 
342
               alpha_num[bg_record->start[Z]]);
318
343
        /* This check is for sub midplane systems to figure out what
319
344
           the largest block can be.
320
345
        */
325
350
                    && (bg_record->geo[Z] == DIM_SIZE[Z])) {
326
351
                        bg_record->full_block = 1;      
327
352
                }       
328
 
        } else if(bg_record->node_cnt == bluegene_bp_node_cnt)
 
353
        } else if(bg_record->node_cnt == bg_conf->bp_node_cnt)
329
354
                bg_record->full_block = 1;
330
355
        
331
 
        
332
356
/* #ifndef HAVE_BG_FILES */
333
357
/*      max_dim[X] = MAX(max_dim[X], end[X]); */
334
358
/*      max_dim[Y] = MAX(max_dim[Y], end[Y]); */
338
362
        if (node_name2bitmap(bg_record->nodes, 
339
363
                             false, 
340
364
                             &bg_record->bitmap)) {
341
 
                fatal("1 Unable to convert nodes %s to bitmap", 
 
365
                fatal("process_nodes: "
 
366
                      "1 Unable to convert nodes %s to bitmap", 
342
367
                      bg_record->nodes);
343
368
        }
344
 
#endif
345
369
        return;
346
370
}
347
371
 
499
523
        itr = list_iterator_create(my_list);
500
524
        while ((bg_record = (bg_record_t *) list_next(itr)) != NULL) {
501
525
                if(bg_record->bg_block_id)
502
 
                        if (!strcmp(bg_record->bg_block_id, 
503
 
                                    bg_block_id))
 
526
                        if (!strcasecmp(bg_record->bg_block_id, bg_block_id))
504
527
                                break;
505
528
        }
506
529
        list_iterator_destroy(itr);
524
547
        }
525
548
        if(!bg_record->user_name) {
526
549
                error("No user_name");
527
 
                bg_record->user_name = xstrdup(bg_slurm_user_name);
 
550
                bg_record->user_name = xstrdup(bg_conf->slurm_user_name);
528
551
        }
529
552
#ifdef HAVE_BG_FILES
530
553
        int rc=0;       
538
561
                        return -1;
539
562
                } else if (rc == REMOVE_USER_NONE) {
540
563
                        if (strcmp(bg_record->target_name, 
541
 
                                   bg_slurm_user_name)) {
 
564
                                   bg_conf->slurm_user_name)) {
542
565
                                info("Adding user %s to Block %s",
543
566
                                     bg_record->target_name, 
544
567
                                     bg_record->bg_block_id);
563
586
                uid_t pw_uid;
564
587
                xfree(bg_record->user_name);
565
588
                bg_record->user_name = xstrdup(bg_record->target_name);
566
 
                pw_uid = uid_from_string(bg_record->user_name);
567
 
                if(pw_uid == (uid_t) -1) {
 
589
                if (uid_from_string (bg_record->user_name, &pw_uid) < 0) {
568
590
                        error("No such user: %s", bg_record->user_name);
569
591
                        return -1;
570
592
                } else {
601
623
                }
602
624
                unlock_slurmctld(job_write_lock);
603
625
                slurm_mutex_lock(&block_state_mutex);
604
 
                if(remove_from_bg_list(bg_job_block_list, bg_record) 
 
626
                if(remove_from_bg_list(bg_lists->job_running, bg_record) 
605
627
                   == SLURM_SUCCESS) {
606
628
                        num_unused_cpus += bg_record->cpu_cnt;
607
629
                }
609
631
        }
610
632
 
611
633
        /* small blocks */
612
 
        if(bg_record->cpu_cnt < procs_per_node) {
 
634
        if(bg_record->cpu_cnt < bg_conf->procs_per_bp) {
613
635
                debug2("small block");
614
636
                goto end_it;
615
637
        }
651
673
        if(!bg_record)
652
674
                return SLURM_ERROR;
653
675
        
654
 
        bg_record->ionode_bitmap = bit_alloc(bluegene_numpsets);
 
676
        bg_record->ionode_bitmap = bit_alloc(bg_conf->numpsets);
655
677
        /* Set the correct ionodes being used in this block */
656
678
        bit_nset(bg_record->ionode_bitmap, io_start, io_start+io_nodes);
657
679
        bit_fmt(bitstring, BITSIZE, bg_record->ionode_bitmap);
669
691
        int i, len;
670
692
        int small_count = 0;
671
693
 
 
694
        xassert(bg_conf->slurm_user_name);
 
695
 
672
696
        if(!records) {
673
697
                fatal("add_bg_record: no records list given");
674
698
        }
675
 
        bg_record = (bg_record_t*) xmalloc(sizeof(bg_record_t));
676
 
        
677
 
        
678
 
        bg_record->user_name = xstrdup(bg_slurm_user_name);
679
 
        bg_record->target_name = xstrdup(bg_slurm_user_name);
680
 
        
681
 
        pw_uid = uid_from_string(bg_record->user_name);
682
 
        if(pw_uid == (uid_t) -1) {
683
 
                error("No such user: %s", bg_record->user_name);
684
 
        } else {
 
699
        bg_record = (bg_record_t*) xmalloc(sizeof(bg_record_t));        
 
700
        
 
701
        bg_record->user_name = xstrdup(bg_conf->slurm_user_name);
 
702
        bg_record->target_name = xstrdup(bg_conf->slurm_user_name);
 
703
        
 
704
        if (uid_from_string (bg_record->user_name, &pw_uid) < 0)
 
705
                error("add_bg_record: No such user: %s", bg_record->user_name);
 
706
        else
685
707
                bg_record->user_uid = pw_uid;
686
 
        }
687
708
 
688
709
        bg_record->bg_block_list = list_create(destroy_ba_node);
689
710
        if(used_nodes) {
690
711
                if(copy_node_path(used_nodes, &bg_record->bg_block_list)
691
712
                   == SLURM_ERROR)
692
 
                        error("couldn't copy the path for the allocation");
 
713
                        error("add_bg_record: "
 
714
                              "couldn't copy the path for the allocation");
693
715
                bg_record->bp_count = list_count(used_nodes);
694
716
        }
695
717
        /* bg_record->boot_state = 0;   Implicit */
696
718
        /* bg_record->state = 0;        Implicit */
697
719
#ifdef HAVE_BGL
698
 
        debug2("asking for %s %d %d %s", 
 
720
        debug2("add_bg_record: asking for %s %d %d %s", 
699
721
               blockreq->block, blockreq->small32, blockreq->small128,
700
722
               convert_conn_type(blockreq->conn_type));
701
723
#else
702
 
        debug2("asking for %s %d %d %d %d %d %s", 
 
724
        debug2("add_bg_record: asking for %s %d %d %d %d %d %s", 
703
725
               blockreq->block, blockreq->small256, 
704
726
               blockreq->small128, blockreq->small64,
705
727
               blockreq->small32, blockreq->small16, 
708
730
        /* Set the bitmap blank here if it is a full node we don't
709
731
           want anything set we also don't want the bg_record->ionodes set.
710
732
        */
711
 
        bg_record->ionode_bitmap = bit_alloc(bluegene_numpsets);
 
733
        bg_record->ionode_bitmap = bit_alloc(bg_conf->numpsets);
712
734
 
713
735
        len = strlen(blockreq->block);
714
736
        i=0;
721
743
        if(i<len) {
722
744
                len -= i;
723
745
                
724
 
                len += strlen(bg_slurm_node_prefix)+1;
 
746
                len += strlen(bg_conf->slurm_node_prefix)+1;
725
747
                bg_record->nodes = xmalloc(len);
726
748
                snprintf(bg_record->nodes, len, "%s%s", 
727
 
                        bg_slurm_node_prefix, blockreq->block+i);
 
749
                        bg_conf->slurm_node_prefix, blockreq->block+i);
728
750
        } else 
729
 
                fatal("BPs=%s is in a weird format", blockreq->block); 
 
751
                fatal("add_bg_record: BPs=%s is in a weird format",
 
752
                      blockreq->block); 
730
753
        
731
754
        process_nodes(bg_record, false);
732
755
        
734
757
        bg_record->node_use = SELECT_COPROCESSOR_MODE;
735
758
#endif
736
759
        bg_record->conn_type = blockreq->conn_type;
737
 
        bg_record->cpu_cnt = procs_per_node * bg_record->bp_count;
738
 
        bg_record->node_cnt = bluegene_bp_node_cnt * bg_record->bp_count;
 
760
        bg_record->cpu_cnt = bg_conf->procs_per_bp * bg_record->bp_count;
 
761
        bg_record->node_cnt = bg_conf->bp_node_cnt * bg_record->bp_count;
739
762
        bg_record->job_running = NO_JOB_RUNNING;
740
763
 
741
764
#ifdef HAVE_BGL
742
765
        if(blockreq->blrtsimage)
743
766
                bg_record->blrtsimage = xstrdup(blockreq->blrtsimage);
744
767
        else
745
 
                bg_record->blrtsimage = xstrdup(default_blrtsimage);
 
768
                bg_record->blrtsimage = xstrdup(bg_conf->default_blrtsimage);
746
769
#endif
747
770
        if(blockreq->linuximage)
748
771
                bg_record->linuximage = xstrdup(blockreq->linuximage);
749
772
        else
750
 
                bg_record->linuximage = xstrdup(default_linuximage);
 
773
                bg_record->linuximage = xstrdup(bg_conf->default_linuximage);
751
774
 
752
775
        if(blockreq->mloaderimage)
753
776
                bg_record->mloaderimage = xstrdup(blockreq->mloaderimage);
754
777
        else
755
 
                bg_record->mloaderimage = xstrdup(default_mloaderimage);
 
778
                bg_record->mloaderimage =
 
779
                        xstrdup(bg_conf->default_mloaderimage);
756
780
 
757
781
        if(blockreq->ramdiskimage)
758
782
                bg_record->ramdiskimage = xstrdup(blockreq->ramdiskimage);
759
783
        else
760
 
                bg_record->ramdiskimage = xstrdup(default_ramdiskimage);
 
784
                bg_record->ramdiskimage =
 
785
                        xstrdup(bg_conf->default_ramdiskimage);
761
786
                
762
787
        if(bg_record->conn_type != SELECT_SMALL) {
763
788
                /* this needs to be an append so we keep things in the
766
791
                /* this isn't a correct list so we need to set it later for
767
792
                   now we just used it to be the bp number */
768
793
                if(!used_nodes) {
769
 
                        debug4("we didn't get a request list so we are "
 
794
                        debug4("add_bg_record: "
 
795
                               "we didn't get a request list so we are "
770
796
                               "destroying this bp list");
771
797
                        list_destroy(bg_record->bg_block_list);
772
798
                        bg_record->bg_block_list = NULL;
773
799
                }
774
800
        } else {
775
 
                debug("adding a small block");
 
801
                debug("add_bg_record: adding a small block");
776
802
                if(no_check)
777
803
                        goto no_check;
778
804
                /* if the ionode cnt for small32 is 0 then don't
779
805
                   allow a sub quarter allocation 
780
806
                */
781
 
                if(bluegene_nodecard_ionode_cnt < 2) {
782
 
                        if(!bluegene_nodecard_ionode_cnt && blockreq->small32) 
783
 
                                fatal("There is an error in your "
 
807
                if(bg_conf->nodecard_ionode_cnt < 2) {
 
808
                        if(!bg_conf->nodecard_ionode_cnt && blockreq->small32) 
 
809
                                fatal("add_bg_record: "
 
810
                                      "There is an error in your "
784
811
                                      "bluegene.conf file.\n"
785
812
                                      "Can't create a 32 node block with "
786
813
                                      "Numpsets=%u. (Try setting it "
787
814
                                      "to at least 16)",
788
 
                                      bluegene_numpsets);
 
815
                                      bg_conf->numpsets);
789
816
#ifndef HAVE_BGL
790
817
                        if(blockreq->small16) 
791
 
                                fatal("There is an error in your "
 
818
                                fatal("add_bg_record: "
 
819
                                      "There is an error in your "
792
820
                                      "bluegene.conf file.\n"
793
821
                                      "Can't create a 16 node block with "
794
822
                                      "Numpsets=%u. (Try setting it to "
795
823
                                      "at least 32)",
796
 
                                      bluegene_numpsets);
797
 
                        if((bluegene_io_ratio < 0.5) && blockreq->small64) 
798
 
                                fatal("There is an error in your "
 
824
                                      bg_conf->numpsets);
 
825
                        if((bg_conf->io_ratio < 0.5) && blockreq->small64) 
 
826
                                fatal("add_bg_record: "
 
827
                                      "There is an error in your "
799
828
                                      "bluegene.conf file.\n"
800
829
                                      "Can't create a 64 node block with "
801
830
                                      "Numpsets=%u. (Try setting it "
802
831
                                      "to at least 8)",
803
 
                                      bluegene_numpsets);
 
832
                                      bg_conf->numpsets);
804
833
#endif
805
834
                }
806
835
 
807
836
#ifdef HAVE_BGL
808
837
                if(blockreq->small32==0 && blockreq->small128==0) {
809
 
                        info("No specs given for this small block, "
 
838
                        info("add_bg_record: "
 
839
                             "No specs given for this small block, "
810
840
                             "I am spliting this block into 4 128CnBlocks");
811
841
                        blockreq->small128=4;
812
842
                }               
813
843
 
814
 
                i = (blockreq->small32*bluegene_nodecard_node_cnt) + 
815
 
                        (blockreq->small128*bluegene_quarter_node_cnt);
816
 
                if(i != bluegene_bp_node_cnt)
817
 
                        fatal("There is an error in your bluegene.conf file.\n"
 
844
                i = (blockreq->small32*bg_conf->nodecard_node_cnt) + 
 
845
                        (blockreq->small128*bg_conf->quarter_node_cnt);
 
846
                if(i != bg_conf->bp_node_cnt)
 
847
                        fatal("add_bg_record: "
 
848
                              "There is an error in your bluegene.conf file.\n"
818
849
                              "I am unable to request %d nodes consisting of "
819
850
                              "%u 32CnBlocks and\n%u 128CnBlocks in one "
820
851
                              "base partition with %u nodes.", 
821
852
                              i, blockreq->small32, blockreq->small128,
822
 
                              bluegene_bp_node_cnt);
 
853
                              bg_conf->bp_node_cnt);
823
854
                small_count = blockreq->small32+blockreq->small128; 
824
855
#else
825
856
                if(!blockreq->small16 && !blockreq->small32 
826
857
                   && !blockreq->small64 && !blockreq->small128 
827
858
                   && !blockreq->small256) {
828
 
                        info("No specs given for this small block, "
 
859
                        info("add_bg_record: "
 
860
                             "No specs given for this small block, "
829
861
                             "I am spliting this block into 2 256CnBlocks");
830
862
                        blockreq->small256=2;
831
863
                }               
835
867
                        + (blockreq->small64*64) 
836
868
                        + (blockreq->small128*128)
837
869
                        + (blockreq->small256*256);
838
 
                if(i != bluegene_bp_node_cnt)
839
 
                        fatal("There is an error in your bluegene.conf file.\n"
 
870
                if(i != bg_conf->bp_node_cnt)
 
871
                        fatal("add_bg_record: "
 
872
                              "There is an error in your bluegene.conf file.\n"
840
873
                              "I am unable to request %d nodes consisting of "
841
874
                              "%u 16CNBlocks, %u 32CNBlocks,\n"
842
875
                              "%u 64CNBlocks, %u 128CNBlocks, "
844
877
                              "in one base partition with %u nodes.", 
845
878
                              i, blockreq->small16, blockreq->small32, 
846
879
                              blockreq->small64, blockreq->small128, 
847
 
                              blockreq->small256, bluegene_bp_node_cnt);
 
880
                              blockreq->small256, bg_conf->bp_node_cnt);
848
881
                small_count = blockreq->small16
849
882
                        + blockreq->small32
850
883
                        + blockreq->small64
872
905
extern int handle_small_record_request(List records, blockreq_t *blockreq,
873
906
                                       bg_record_t *bg_record, bitoff_t start)
874
907
{
875
 
        bitstr_t *ionodes = bit_alloc(bluegene_numpsets);
 
908
        bitstr_t *ionodes = bit_alloc(bg_conf->numpsets);
876
909
        int i=0, ionode_cnt = 0;
877
910
        bg_record_t *found_record = NULL;
878
911
 
881
914
        xassert(bg_record);
882
915
 
883
916
        xassert(start >= 0);
884
 
        xassert(start < bluegene_numpsets);
 
917
        xassert(start < bg_conf->numpsets);
885
918
 
886
919
#ifndef HAVE_BGL
887
920
        for(i=0; i<blockreq->small16; i++) {
895
928
                start++;
896
929
        }
897
930
#endif
898
 
        if((ionode_cnt = bluegene_nodecard_ionode_cnt))
 
931
        if((ionode_cnt = bg_conf->nodecard_ionode_cnt))
899
932
                ionode_cnt--;
900
933
        for(i=0; i<blockreq->small32; i++) {
901
934
                bit_nset(ionodes, start, start+ionode_cnt);
909
942
        }
910
943
        
911
944
#ifndef HAVE_BGL
912
 
        if((ionode_cnt = bluegene_nodecard_ionode_cnt * 2))
 
945
        if((ionode_cnt = bg_conf->nodecard_ionode_cnt * 2))
913
946
                ionode_cnt--;
914
947
        for(i=0; i<blockreq->small64; i++) {
915
948
                bit_nset(ionodes, start, start+ionode_cnt);
922
955
                start+=ionode_cnt+1;
923
956
        }
924
957
#endif
925
 
        if((ionode_cnt = bluegene_quarter_ionode_cnt))
 
958
        if((ionode_cnt = bg_conf->quarter_ionode_cnt))
926
959
                ionode_cnt--;
927
960
        for(i=0; i<blockreq->small128; i++) {
928
961
                bit_nset(ionodes, start, start+ionode_cnt);
936
969
        }
937
970
 
938
971
#ifndef HAVE_BGL
939
 
        if((ionode_cnt = bluegene_quarter_ionode_cnt * 2))
 
972
        if((ionode_cnt = bg_conf->quarter_ionode_cnt * 2))
940
973
                ionode_cnt--;
941
974
        for(i=0; i<blockreq->small256; i++) {
942
975
                bit_nset(ionodes, start, start+ionode_cnt);
987
1020
        if(io_cnt == NO_VAL) {
988
1021
                io_cnt = 1;
989
1022
                /* Translate 1 nodecard count to ionode count */
990
 
                if((io_cnt *= bluegene_io_ratio))
 
1023
                if((io_cnt *= bg_conf->io_ratio))
991
1024
                        io_cnt--;
 
1025
 
992
1026
                /* make sure we create something that is able to be
993
1027
                   created */
994
 
                if(bluegene_smallest_block < bluegene_nodecard_node_cnt)
995
 
                        create_size = bluegene_nodecard_node_cnt;
 
1028
                if(bg_conf->smallest_block < bg_conf->nodecard_node_cnt)
 
1029
                        create_size = bg_conf->nodecard_node_cnt;
996
1030
                else
997
 
                        create_size = bluegene_smallest_block;
 
1031
                        create_size = bg_conf->smallest_block;
998
1032
        }
999
1033
 
1000
1034
        node_ptr = find_node_record(bp_name);
1003
1037
                       bp_name);
1004
1038
                return EINVAL;
1005
1039
        }
 
1040
 
 
1041
        /* this is here for sanity check to make sure we don't core on
 
1042
           these bits when we set them below. */
 
1043
        if(io_start >= bg_conf->numpsets 
 
1044
           || (io_start+io_cnt) >= bg_conf->numpsets) {
 
1045
                debug("io %d-%d not configured on this "
 
1046
                      "system, only %d ionodes per midplane",
 
1047
                      io_start, io_start+io_cnt, bg_conf->numpsets);
 
1048
                return EINVAL;
 
1049
        }
1006
1050
        bp_bit = (node_ptr - node_record_table_ptr);
1007
1051
        
1008
1052
        memset(&blockreq, 0, sizeof(blockreq_t));
1010
1054
        blockreq.conn_type = SELECT_SMALL;
1011
1055
        blockreq.block = bp_name;
1012
1056
 
1013
 
        debug3("here setting %d of %d and %d-%d of %d",
 
1057
        debug3("here setting node %d of %d and ionodes %d-%d of %d",
1014
1058
               bp_bit, node_record_count, io_start, 
1015
 
               io_start+io_cnt, bluegene_numpsets);
 
1059
               io_start+io_cnt, bg_conf->numpsets);
1016
1060
 
1017
1061
        memset(&tmp_record, 0, sizeof(bg_record_t));
1018
1062
        tmp_record.bp_count = 1;
1019
 
        tmp_record.node_cnt = bluegene_nodecard_node_cnt;
 
1063
        tmp_record.node_cnt = bg_conf->nodecard_node_cnt;
1020
1064
        tmp_record.bitmap = bit_alloc(node_record_count);
1021
1065
        bit_set(tmp_record.bitmap, bp_bit);
1022
1066
 
1023
 
        tmp_record.ionode_bitmap = bit_alloc(bluegene_numpsets);
 
1067
        tmp_record.ionode_bitmap = bit_alloc(bg_conf->numpsets);
1024
1068
        bit_nset(tmp_record.ionode_bitmap, io_start, io_start+io_cnt);
1025
1069
 
1026
1070
        slurm_mutex_lock(&block_state_mutex);
1027
 
        itr = list_iterator_create(bg_list);
 
1071
        itr = list_iterator_create(bg_lists->main);
1028
1072
        while ((bg_record = list_next(itr))) {
1029
1073
                if(!bit_test(bg_record->bitmap, bp_bit))
1030
1074
                        continue;
1035
1079
                if(bg_record->job_running > NO_JOB_RUNNING) 
1036
1080
                        slurm_fail_job(bg_record->job_running);
1037
1081
 
1038
 
                /* mark every one of these in an error state */
1039
 
                if(bluegene_layout_mode != LAYOUT_DYNAMIC) {
 
1082
                /* If Running Dynamic mode and the the block is
 
1083
                   smaller than the create size just continue on.
 
1084
                */
 
1085
                if((bg_conf->layout_mode == LAYOUT_DYNAMIC)
 
1086
                   && (bg_record->node_cnt < create_size)) {
1040
1087
                        if(!delete_list)
1041
1088
                                delete_list = list_create(NULL);
1042
1089
                        list_append(delete_list, bg_record);
1043
1090
                        continue;
1044
 
                } 
1045
 
 
1046
 
                /* below is only for dynamic modes since there are
1047
 
                   never overlapping blocks there */
1048
 
                /* if the block is smaller than the create size just
1049
 
                   continue on.
1050
 
                */
1051
 
                if(bg_record->node_cnt < create_size)
1052
 
                        continue;
1053
 
 
 
1091
                }
 
1092
 
 
1093
                /* keep track of the smallest size that is at least
 
1094
                   the size of create_size. */
1054
1095
                if(!smallest_bg_record || 
1055
1096
                   (smallest_bg_record->node_cnt > bg_record->node_cnt))
1056
1097
                        smallest_bg_record = bg_record;
1058
1099
        list_iterator_destroy(itr);
1059
1100
        slurm_mutex_unlock(&block_state_mutex);
1060
1101
        
1061
 
        if(bluegene_layout_mode != LAYOUT_DYNAMIC) {
 
1102
        if(bg_conf->layout_mode != LAYOUT_DYNAMIC) {
1062
1103
                debug3("running non-dynamic mode");
1063
 
                if(delete_list) {
1064
 
                        int cnt_set = 0;
1065
 
                        /* don't lock here since it is handled inside
1066
 
                           the put_block_in_error_state
1067
 
                        */
1068
 
                        itr = list_iterator_create(delete_list);
1069
 
                        while ((bg_record = list_next(itr))) {
1070
 
                                /* we already handled this */
1071
 
                                if(bg_record->state == RM_PARTITION_ERROR) {
1072
 
                                        rc = SLURM_NO_CHANGE_IN_DATA;
1073
 
                                        continue;
1074
 
                                }
1075
 
                                                                
1076
 
                                rc = put_block_in_error_state(
1077
 
                                        bg_record, BLOCK_ERROR_STATE);
1078
 
                                cnt_set++;
1079
 
                        }
1080
 
                        if(cnt_set)
1081
 
                                rc = SLURM_SUCCESS;
1082
 
                        list_iterator_destroy(itr);
 
1104
                
 
1105
                /* This should never happen, but just in case... */
 
1106
                if(delete_list) 
1083
1107
                        list_destroy(delete_list);
 
1108
 
 
1109
                /* If we found a block that is smaller or equal to a
 
1110
                   midplane we will just mark it in an error state as
 
1111
                   opposed to draining the node.  
 
1112
                */
 
1113
                if(smallest_bg_record 
 
1114
                   && (smallest_bg_record->node_cnt < bg_conf->bp_node_cnt)){
 
1115
                        if(smallest_bg_record->state == RM_PARTITION_ERROR) {
 
1116
                                rc = SLURM_NO_CHANGE_IN_DATA;
 
1117
                                goto cleanup;
 
1118
                        }
 
1119
                        
 
1120
                        rc = put_block_in_error_state(
 
1121
                                smallest_bg_record, BLOCK_ERROR_STATE);
1084
1122
                        goto cleanup;
1085
1123
                } 
1086
1124
                
1087
 
                debug("didn't get a smallest block");
 
1125
                debug("No block under 1 midplane available for this nodecard.  "
 
1126
                      "Draining the whole node.");
1088
1127
                if(!node_already_down(bp_name)) {
1089
1128
                        time_t now = time(NULL);
1090
1129
                        char reason[128], time_str[32];
1100
1139
                goto cleanup;
1101
1140
        } 
1102
1141
 
 
1142
        /* below is only for Dynamic mode */
1103
1143
        
1104
 
        if(smallest_bg_record) {
 
1144
        if(delete_list) {
 
1145
                int cnt_set = 0;
 
1146
                bitstr_t *iobitmap = bit_alloc(bg_conf->numpsets);
 
1147
                /* don't lock here since it is handled inside
 
1148
                   the put_block_in_error_state
 
1149
                */
 
1150
                itr = list_iterator_create(delete_list);
 
1151
                while ((bg_record = list_next(itr))) {
 
1152
                        debug2("combining smaller than nodecard "
 
1153
                               "dynamic block %s",
 
1154
                               bg_record->bg_block_id);
 
1155
                        while(bg_record->job_running > NO_JOB_RUNNING)
 
1156
                                sleep(1);
 
1157
 
 
1158
                        bit_or(iobitmap, bg_record->ionode_bitmap);
 
1159
                        cnt_set++;
 
1160
                }
 
1161
                list_iterator_destroy(itr);
 
1162
                list_destroy(delete_list);
 
1163
                if(!cnt_set) {
 
1164
                        FREE_NULL_BITMAP(iobitmap);
 
1165
                        rc = SLURM_ERROR;
 
1166
                        goto cleanup;
 
1167
                }
 
1168
                /* set the start to be the same as the start of the
 
1169
                   ionode_bitmap.  If no ionodes set (not a small
 
1170
                   block) set io_start = 0. */
 
1171
                if((io_start = bit_ffs(iobitmap)) == -1) {
 
1172
                        io_start = 0;
 
1173
                        if(create_size > bg_conf->nodecard_node_cnt) 
 
1174
                                blockreq.small128 = 4;
 
1175
                        else
 
1176
                                blockreq.small32 = 16;
 
1177
                } else if(create_size <= bg_conf->nodecard_node_cnt) 
 
1178
                        blockreq.small32 = 1;
 
1179
                else
 
1180
                        /* this should never happen */
 
1181
                        blockreq.small128 = 1;
 
1182
                
 
1183
                FREE_NULL_BITMAP(iobitmap);             
 
1184
        } else if(smallest_bg_record) {
1105
1185
                debug2("smallest dynamic block is %s",
1106
1186
                       smallest_bg_record->bg_block_id);
1107
1187
                if(smallest_bg_record->state == RM_PARTITION_ERROR) {
1146
1226
                        break;
1147
1227
                }
1148
1228
 
1149
 
                if(create_size != bluegene_nodecard_node_cnt) {
 
1229
                if(create_size != bg_conf->nodecard_node_cnt) {
1150
1230
                        blockreq.small128 = blockreq.small32 / 4;
1151
1231
                        blockreq.small32 = 0;
1152
 
                }
1153
 
                /* set the start to be the same as the start of the
1154
 
                   ionode_bitmap.  If no ionodes set (not a small
1155
 
                   block) set io_start = 0. */
1156
 
                if((io_start = bit_ffs(smallest_bg_record->ionode_bitmap))
1157
 
                   == -1)
 
1232
                        io_start = 0;
 
1233
                } else if((io_start =
 
1234
                           bit_ffs(smallest_bg_record->ionode_bitmap)) == -1)
 
1235
                        /* set the start to be the same as the start of the
 
1236
                           ionode_bitmap.  If no ionodes set (not a small
 
1237
                           block) set io_start = 0. */
1158
1238
                        io_start = 0;
1159
1239
        } else {
1160
1240
                switch(create_size) {
1208
1288
        delete_list = list_create(NULL);
1209
1289
        while((bg_record = list_pop(requests))) {
1210
1290
                slurm_mutex_lock(&block_state_mutex);
1211
 
                itr = list_iterator_create(bg_list);
 
1291
                itr = list_iterator_create(bg_lists->main);
1212
1292
                while((found_record = list_next(itr))) {
1213
1293
                        if(!blocks_overlap(bg_record, found_record))
1214
1294
                                continue;
1215
1295
                        list_push(delete_list, found_record);
1216
1296
                        list_remove(itr);
1217
 
                        num_block_to_free++;
1218
1297
                }
1219
1298
                list_iterator_destroy(itr);
1220
1299
                slurm_mutex_unlock(&block_state_mutex);
1232
1311
                      bg_record->bg_block_id);
1233
1312
                print_bg_record(bg_record);
1234
1313
                slurm_mutex_lock(&block_state_mutex);
1235
 
                list_append(bg_list, bg_record);
 
1314
                list_append(bg_lists->main, bg_record);
1236
1315
                slurm_mutex_unlock(&block_state_mutex);
1237
1316
                if(bit_overlap(bg_record->ionode_bitmap, 
1238
1317
                               tmp_record.ionode_bitmap)) {
1247
1326
        slurm_mutex_lock(&block_state_mutex);
1248
1327
        free_block_list(delete_list);
1249
1328
        list_destroy(delete_list);
1250
 
        sort_bg_record_inc_size(bg_list);
 
1329
        sort_bg_record_inc_size(bg_lists->main);
1251
1330
        slurm_mutex_unlock(&block_state_mutex);
1252
1331
        last_bg_update = time(NULL);    
1253
1332
 
1279
1358
        bp_bit = (node_ptr - node_record_table_ptr);
1280
1359
        
1281
1360
        slurm_mutex_lock(&block_state_mutex);
1282
 
        itr = list_iterator_create(bg_list);
 
1361
        itr = list_iterator_create(bg_lists->main);
1283
1362
        while((bg_record = list_next(itr))) {
1284
1363
                if(bg_record->job_running != BLOCK_ERROR_STATE)
1285
1364
                        continue;
1330
1409
        info("Setting Block %s to ERROR state.", bg_record->bg_block_id);
1331
1410
        /* we add the block to these lists so we don't try to schedule
1332
1411
           on them. */
1333
 
        if(!block_ptr_exist_in_list(bg_job_block_list, bg_record)) {
1334
 
                list_push(bg_job_block_list, bg_record);
 
1412
        if(!block_ptr_exist_in_list(bg_lists->job_running, bg_record)) {
 
1413
                list_push(bg_lists->job_running, bg_record);
1335
1414
                num_unused_cpus -= bg_record->cpu_cnt;
1336
1415
        }
1337
 
        if(!block_ptr_exist_in_list(bg_booted_block_list, bg_record)) 
1338
 
                list_push(bg_booted_block_list, bg_record);
 
1416
        if(!block_ptr_exist_in_list(bg_lists->booted, bg_record)) 
 
1417
                list_push(bg_lists->booted, bg_record);
1339
1418
        
1340
1419
        slurm_mutex_lock(&block_state_mutex);
1341
1420
        bg_record->job_running = state;
1343
1422
 
1344
1423
        xfree(bg_record->user_name);
1345
1424
        xfree(bg_record->target_name);
1346
 
        bg_record->user_name = xstrdup(bg_slurm_user_name);
1347
 
        bg_record->target_name = xstrdup(bg_slurm_user_name);
 
1425
        bg_record->user_name = xstrdup(bg_conf->slurm_user_name);
 
1426
        bg_record->target_name = xstrdup(bg_conf->slurm_user_name);
1348
1427
        
1349
 
        pw_uid = uid_from_string(bg_record->user_name);
1350
 
        if(pw_uid == (uid_t) -1) {
 
1428
        if (uid_from_string (bg_record->user_name, &pw_uid) < 0)
1351
1429
                error("No such user: %s", bg_record->user_name);
1352
 
        } else {
 
1430
        else
1353
1431
                bg_record->user_uid = pw_uid;
1354
 
        }
 
1432
 
1355
1433
        slurm_mutex_unlock(&block_state_mutex);
1356
1434
 
1357
1435
        trigger_block_error();
1358
 
        last_bg_update = time(NULL);
1359
1436
 
1360
1437
        return SLURM_SUCCESS;
1361
1438
}
1372
1449
             "being in an error state.",
1373
1450
              bg_record->bg_block_id);
1374
1451
 
1375
 
        if(remove_from_bg_list(bg_job_block_list, bg_record) == SLURM_SUCCESS) 
 
1452
        if(remove_from_bg_list(bg_lists->job_running, bg_record)
 
1453
           == SLURM_SUCCESS) 
1376
1454
                num_unused_cpus += bg_record->cpu_cnt;
1377
 
        remove_from_bg_list(bg_booted_block_list, bg_record);
 
1455
        remove_from_bg_list(bg_lists->booted, bg_record);
1378
1456
 
1379
1457
        bg_record->job_running = NO_JOB_RUNNING;
1380
1458
        bg_record->state = RM_PARTITION_FREE;
1385
1463
 
1386
1464
/************************* local functions ***************************/
1387
1465
 
1388
 
#ifdef HAVE_BG
1389
1466
static int _addto_node_list(bg_record_t *bg_record, int *start, int *end)
1390
1467
{
1391
1468
        int node_count=0;
1420
1497
                                
1421
1498
                                snprintf(node_name_tmp, sizeof(node_name_tmp),
1422
1499
                                         "%s%c%c%c", 
1423
 
                                         bg_slurm_node_prefix,
 
1500
                                         bg_conf->slurm_node_prefix,
1424
1501
                                         alpha_num[x], alpha_num[y],
1425
1502
                                         alpha_num[z]);         
1426
1503
                                
1460
1537
}
1461
1538
 
1462
1539
 
1463
 
#endif //HAVE_BG
1464
 
 
1465