From 54ceed1c5d17df68455fc46231356908cd36128f Mon Sep 17 00:00:00 2001
From: Mehdi Dogguy <mehdi@debian.org>
Date: Mon, 8 Sep 2014 21:30:29 +0200
Subject: [PATCH] Imported Upstream version 1.2.15

---
 META                                          |   4 +-
 NEWS                                          |   9 +-
 contribs/mpich1.slurm.patch                   |   4 +-
 doc/html/publications.shtml                   |   8 +-
 doc/man/man1/sbatch.1                         |  11 +-
 doc/man/man1/scancel.1                        |  35 +++--
 doc/man/man1/srun.1                           |  35 +++--
 slurm.spec                                    |   6 +-
 src/api/slurm_pmi.c                           |  19 ++-
 src/api/step_ctx.c                            |   4 +-
 src/common/hostlist.c                         |   4 +-
 src/plugins/sched/wiki2/hostlist.c            |  25 +++-
 src/plugins/sched/wiki2/start_job.c           |  10 +-
 src/plugins/select/cons_res/select_cons_res.c |   3 +-
 src/salloc/opt.c                              |   9 +-
 src/salloc/salloc.c                           |   4 +-
 src/sattach/opt.c                             |   4 +-
 src/sbatch/opt.c                              |  24 +++-
 src/sbatch/opt.h                              |   3 +-
 src/sbatch/sbatch.c                           |  10 +-
 src/srun/opt.c                                |   9 +-
 testsuite/expect/Makefile.am                  |   2 +
 testsuite/expect/Makefile.in                  |   2 +
 testsuite/expect/README                       |   3 +-
 testsuite/expect/test1.88                     |   2 +-
 testsuite/expect/test1.88.prog.c              |   7 +-
 testsuite/expect/test17.31                    |  51 ++++++--
 testsuite/expect/test17.32                    | 122 ++++++++++++++++++
 testsuite/expect/test17.6                     |   2 +-
 29 files changed, 325 insertions(+), 106 deletions(-)
 create mode 100755 testsuite/expect/test17.32

diff --git a/META b/META
index d3c5aff85..ae7b593ee 100644
--- a/META
+++ b/META
@@ -3,8 +3,8 @@
   Api_revision:  0
   Major:         1
   Meta:          1
-  Micro:         14
+  Micro:         15
   Minor:         2
   Name:          slurm
   Release:       1
-  Version:       1.2.14
+  Version:       1.2.15
diff --git a/NEWS b/NEWS
index cc0ce72bb..3e21db491 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,13 @@ documents those changes that are of interest to users and admins.
 
 * Changes in SLURM 1.2.15
 =========================
+ -- In sched/wiki2, fix bug processing hostlist expressions where hosts
+    lack a numeric suffix.
+ -- Fix bug in srun. When user did not specify time limit, it defaulted to 
+    INFINITE rather than partition's limit.
+ -- In select/cons_res with SelectTypeParameters=CR_Socket_Memory, fix bug in 
+    memory allocation tracking, mem.patch from Chris Holmes, HP.
+ -- Add --overcommit option to the sbatch command.
 
 * Changes in SLURM 1.2.14
 =========================
@@ -2594,4 +2601,4 @@ documents those changes that are of interest to users and admins.
  -- Change directory to /tmp in slurmd if daemonizing.
  -- Logfiles are reopened on reconfigure.
  
-$Id: NEWS 12099 2007-08-22 22:37:17Z da $
+$Id: NEWS 12190 2007-08-31 19:05:18Z jette $
diff --git a/contribs/mpich1.slurm.patch b/contribs/mpich1.slurm.patch
index 6ecb186d3..738fb9eda 100644
--- a/contribs/mpich1.slurm.patch
+++ b/contribs/mpich1.slurm.patch
@@ -282,8 +282,8 @@ Index: README
 +DETAILS: The srun command opens two socket connections and passes 
 +their ports to all tasks via the SLURM_MPICH1_P4_PORT1 and 
 +SLURM_MPICH1_P4_PORT2 environment variables. Task zero connects to 
-+SLURM_MPICH1_P4_PORT1 and writes port number. The other tasks connect 
-+to SLURM_MPICH1_P4_PORT2 and that port number. This avoid the requirement 
++SLURM_MPICH1_P4_PORT1 and writes its port number. The other tasks connect to 
++SLURM_MPICH1_P4_PORT2 and read that port number. This avoid the requirement 
 +of having task zero launch all subsequent tasks and also launches 
 +all tasks under the direct control of SLURM (for process management 
 +and accounting).  SLURM only launches one task per node and that 
diff --git a/doc/html/publications.shtml b/doc/html/publications.shtml
index 58048a25b..8d918489e 100644
--- a/doc/html/publications.shtml
+++ b/doc/html/publications.shtml
@@ -1,8 +1,7 @@
 <!--#include virtual="header.txt"-->
 
 <h1>Publications</h1>
-<p><a href="http://www.cs.huji.ac.il/~feit/parsched/jsspp07/balle.pdf">
-<b>Enhancing an Open Source Resource Manager with Multi-Core/Multi-threaded Support</b></a> [PDF],
+<b>Enhancing an Open Source Resource Manager with Multi-Core/Multi-threaded Support</b>,
 S. M. Balle and D. Palermo,
 <i>Job Scheduling Strategies for Parallel Processing</i>,
 2007.</p>
@@ -13,14 +12,13 @@ M. Jette and M. Grondona,
 <i>Proceedings of ClusterWorld Conference and Expo</i>,
 San Jose, California, June 2003.</p>
 
-<p><a href="http://www.cs.huji.ac.il/~feit/parsched/jsspp03/p-03-3.ps.gz">
-<b>SLURM: Simple Linux Utility for Resource Management</b></a> [PDF,GZIP],
+<b>SLURM: Simple Linux Utility for Resource Management</b>,
 A. Yoo, M. Jette, and M. Grondona,
 <i>Job Scheduling Strategies for Parallel Processing</i>,
 volume 2862 of <i>Lecture Notes in Computer Science</i>, 
 pages 44-60,
 Springer-Verlag, 2003.</p>
 
-<p style="text-align:center;">Last modified 1 June 2007</p>
+<p style="text-align:center;">Last modified 31 August 2007</p>
 
 <!--#include virtual="footer.txt"-->
diff --git a/doc/man/man1/sbatch.1 b/doc/man/man1/sbatch.1
index 30dffc401..5ee2c5617 100644
--- a/doc/man/man1/sbatch.1
+++ b/doc/man/man1/sbatch.1
@@ -1,4 +1,4 @@
-.TH "sbatch" "1" "SLURM 1.2" "June 2007" "SLURM Commands"
+.TH "sbatch" "1" "SLURM 1.2" "August 2007" "SLURM Commands"
 .SH "NAME"
 .LP 
 sbatch \- Submit a batch script to SLURM.
@@ -271,6 +271,12 @@ When a job is requeued, the batch script is initiated from its beginning.
 Specify the number of tasks to be launched per node.
 Equivalent to \fB\-\-tasks\-per\-node\fR.
 
+\fB\-O\fR, \fB\-\-overcommit\fR
+Overcommit resources. Normally, \fBsbatch\fR will allocate one cpu per
+task to be executed. By specifying \fB\-\-overcommit\fR you are explicitly
+allowing more than one process per cpu. However no more than
+\fBMAX_TASKS_PER_NODE\fR tasks are permitted to execute per node.
+
 .TP
 \fB\-o\fR, \fB\-\-output\fR[=]<\fIfilename pattern\fR>
 Instruct SLURM to connect the batch script's standard output directly to the 
@@ -454,6 +460,9 @@ Same as \fB\-\-no\-requeue\fR.
 \fBSBATCH_NO_ROTATE\fR
 Same as \fB\-R\fR or \fB\-\-no\-rotate\fR.
 .TP
+\fBSLURM_OVERCOMMIT\fR
+Same as \fB\-O, \-\-overcommit\fR
+.TP
 \fBSBATCH_PARTITION\fR
 Same as \fB\-p\fR or \fB\-\-partition\fR.
 .TP
diff --git a/doc/man/man1/scancel.1 b/doc/man/man1/scancel.1
index dc06452d7..8943d5cb5 100644
--- a/doc/man/man1/scancel.1
+++ b/doc/man/man1/scancel.1
@@ -1,4 +1,4 @@
-.TH SCANCEL "1" "July 2007" "scancel 1.2" "Slurm components"
+.TH SCANCEL "1" "August 2007" "scancel 1.2" "Slurm components"
 .SH "NAME"
 scancel \- Used to signal jobs or job steps that are under the control of Slurm.
 .SH "SYNOPSIS"
@@ -16,6 +16,7 @@ be printed and the job will not be signaled.
 .TP
 \fB\-b\fR, \fB\-\-batch\fR
 Signal the batch job shell and its child processes.
+This is not applicable if \fIstep_id\fR is specified.
 
 .TP
 \fB-\-ctld\fR
@@ -64,23 +65,28 @@ Print a brief help message listing the \fBscancel\fR options.
 \fB\-v\fR, \fB\-\-verbose\fR
 Print additional logging. Multiple v's increase logging detail.
 This option is incompatible with the \fB\-\-quiet\fR option.
+
 .TP
 \fB\-V\fR, \fB\-\-Version\fR
 Print the version number of the scancel command. 
 
 .TP
 ARGUMENTS
+
 .TP
 \fIjob_id\fP
 The Slurm job ID to be signaled.
-If no step_id is specified and the \fB\-\-batch\fR option is not used, 
-then all jobs steps associated with the provided job_id will be signaled.
-If no job steps are active then no processes will be signalled.
-Any batch script which spawned the job steps will only be signalled if 
-the \fB\-\-batch\fR option is used.
+
 .TP
 \fIstep_id\fP
 The step ID of the job step to be signaled. 
+If not specified, the operation is performed at the level of a job.
+A "KILL" (the default) signal applied to a job cancels the job and
+all of its steps.
+For other signals, when \fB\-\-batch\fR is used, the batch shell 
+processes will be signalled.
+Otherwise the processes associated with all job steps, but not the 
+batch script itself, will be signalled.
 
 .SH "ENVIRONMENT VARIABLES"
 .PP
@@ -117,24 +123,33 @@ The location of the SLURM configuration file.
 
 .SH "NOTES"
 .LP
-If multiple filters are supplied (e.g. \fB\-\-partition\fR and \fB\-\-name\fR) only the 
-jobs satisfying all of the filtering options will be signaled.
+If multiple filters are supplied (e.g. \fB\-\-partition\fR and \fB\-\-name\fR) 
+only the jobs satisfying all of the filtering options will be signaled.
 .LP
-If a signal value of "KILL" (the default value) is to be sent to an entire job, this will 
-result in the job's termination and its resource allocation being released.
+If a signal value of "KILL" (the default value) is to be sent to an entire 
+job, this will result in the job's termination and its resource allocation 
+being released.
 .LP
 Cancelling a job step will not result in a job being terminated. 
 The job must be cancelled to release a resource allocation. 
+
 .SH "EXAMPLES"
 .TP
 Send SIGTERM to steps 1 and 3 of job 1234:
 scancel \-\-signal=TERM 1234.1 1234.3
+
 .TP
 Cancel job 1234 along with all of its steps:
 scancel 1234
+
+.TP
+Send SIGUSR1 to the batch shell processes of job 1235:
+scancel \-\-signal=USR1 \-\-batch 1235
+
 .TP
 Cancel job all pending jobs belonging to user "bob" in partition "debug":
 scancel \-\-state=PENDING \-\-user=bob \-\-partition=debug
+
 .SH "COPYING"
 Copyright (C) 2002-2007 The Regents of the University of California.
 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
diff --git a/doc/man/man1/srun.1 b/doc/man/man1/srun.1
index 492e80227..f534c2eeb 100644
--- a/doc/man/man1/srun.1
+++ b/doc/man/man1/srun.1
@@ -1,4 +1,4 @@
-\." $Id: srun.1 12054 2007-08-20 16:11:48Z jette $
+\." $Id: srun.1 12131 2007-08-24 00:06:21Z jette $
 .\"
 .TH SRUN "1" "July 2007" "srun 1.2" "slurm components"
 
@@ -1032,15 +1032,13 @@ demand for CPUs. In other words, a \fIminimum\fR of 16 nodes are being
 requested. However, if 16 nodes are requested for 15 processes,
 .B srun
 will consider this an error, as 15 processes cannot run across 16 nodes.
+
 .PP
 .B "IO Redirection"
 .PP
-By default stdout and stderr will be redirected from all tasks to the
-stdout and stderr of
-.B srun
-, and stdin will be redirected from the standard input of 
-.B srun 
-to all remote tasks. 
+By default, stdout and stderr will be redirected from all tasks to the
+stdout and stderr of \fBsrun\fR, and stdin will be redirected from the 
+standard input of \fBsrun\fR to all remote tasks. 
 For OS X, the poll() function does not support stdin, so input from 
 a terminal is not possible.
 This behavior may be changed with the 
@@ -1061,27 +1059,24 @@ stdin is not sent to any task (stdin is closed).
 stdout and/or stderr are redirected from only the task with relative
 id equal to \fItaskid\fR, where 0 <= \fItaskid\fR <= \fIntasks\fR,
 where \fIntasks\fR is the total number of tasks in the current job step.
-stdin is redirected from the stdin of
-.B srun
-to this same task.
+stdin is redirected from the stdin of \fBsrun\fR to this same task.
 .TP
 \fIfilename\fR
-.B srun
-will redirect stdout and/or stderr to the named file from all tasks.
+fBsrun\fR will redirect stdout and/or stderr to the named file from 
+all tasks.
 stdin will be redirected from the named file and broadcast to all
-tasks in the job.  If the job is submitted in batch mode using the
-.B \-b
-or
-.B \-\-batch
-option, \fIfilename\fR refers to a path on each of the nodes on which
-the job runs.  Otherwise \fIfilename\fR refers to a path on the host
+tasks in the job.  
+If the job is submitted in batch mode using the \fB\-b\fR or 
+\fB\-\-batch\fR option, \fIfilename\fR refers to a path on the first
+node allocated to the job. 
+Otherwise \fIfilename\fR refers to a path on the host
 that runs \fBsrun\fR.  Depending on the cluster's file system layout,
 this may result in the output appearing in different places depending
 on whether the job is run in batch mode.
 .TP
 format string
-.B srun 
-allows for a format string to be used to generate the named IO file 
+\fBsrun\fR allows for a format string to be used to generate the 
+named IO file 
 described above. The following list of format specifiers may be
 used in the format string to generate a filename that will be
 unique to a given jobid, stepid, node, or task. In each case, 
diff --git a/slurm.spec b/slurm.spec
index 7b06a20e5..3dc1059f4 100644
--- a/slurm.spec
+++ b/slurm.spec
@@ -3,14 +3,14 @@
 # Note that this package is not relocatable
 
 Name:    slurm
-Version: 1.2.14
+Version: 1.2.15
 Release: 1%{?dist}
 
 Summary: Simple Linux Utility for Resource Management
 
 License: GPL 
 Group: System Environment/Base
-Source: slurm-1.2.14.tar.bz2
+Source: slurm-1.2.15.tar.bz2
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
 URL: http://www.llnl.gov/linux/slurm
 %ifos linux
@@ -142,7 +142,7 @@ SLURM process tracking plugin for SGI job containers.
 (See http://oss.sgi.com/projects/pagg).
 
 %prep
-%setup -n slurm-1.2.14
+%setup -n slurm-1.2.15
 
 %build
 %configure --program-prefix=%{?_program_prefix:%{_program_prefix}} \
diff --git a/src/api/slurm_pmi.c b/src/api/slurm_pmi.c
index d6403a47c..8a5fb2b21 100644
--- a/src/api/slurm_pmi.c
+++ b/src/api/slurm_pmi.c
@@ -197,12 +197,19 @@ int  slurm_get_kvs_comm_set(struct kvs_comm_set **kvs_set_ptr,
 	/* Send the RPC to the local srun communcation manager.
 	 * Since the srun can be sent thousands of messages at 
 	 * the same time and refuse some connections, retry as 
-	 * needed. Spread out messages by task's rank. Also
-	 * increase the timeout if many tasks since the srun
-	 * command is very overloaded.
-	 * We also increase the timeout (default timeout is
-	 * 10 secs). */
-	usleep(pmi_rank * pmi_time);
+	 * needed. Wait until all key-pairs have been sent by
+	 * all tasks then spread out messages by task's rank.
+	 * Also increase the message timeout if many tasks 
+	 * since the srun command can get very overloaded (the
+	 * default timeout is 10 secs).
+	 *
+	 * TaskID  SendTime  GetTime  (Units are PMI_TIME, default=500 usec)
+	 *      0         0      N+0
+	 *      1         1      N+1
+	 *      2         2      N+2
+	 *    N-1       N-1      N+N-1
+	 */
+	usleep(pmi_size * pmi_time);
 	if      (pmi_size > 1000)	/* 100 secs */
 		timeout = slurm_get_msg_timeout() * 10000;
 	else if (pmi_size > 100)	/* 50 secs */
diff --git a/src/api/step_ctx.c b/src/api/step_ctx.c
index 08ee9f7ba..f43a12aa3 100644
--- a/src/api/step_ctx.c
+++ b/src/api/step_ctx.c
@@ -1,7 +1,7 @@
 /*****************************************************************************\
  *  step_ctx.c - step_ctx task functions for use by AIX/POE
  *
- *  $Id: step_ctx.c 10763 2007-01-12 20:15:44Z morrone $
+ *  $Id: step_ctx.c 12171 2007-08-29 17:22:48Z jette $
  *****************************************************************************
  *  Copyright (C) 2004 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -329,7 +329,7 @@ extern void slurm_step_ctx_params_t_init (slurm_step_ctx_params_t *ptr)
 	char *jobid_str;
 
 	/* zero the entire structure */
-	memset(ptr, 0, sizeof(job_step_create_request_msg_t));
+	memset(ptr, 0, sizeof(slurm_step_ctx_params_t));
 
 	/* now set anything that shouldn't be 0 or NULL by default */
 	ptr->relative = (uint16_t)NO_VAL;
diff --git a/src/common/hostlist.c b/src/common/hostlist.c
index 3de1d441b..eb0c3818d 100644
--- a/src/common/hostlist.c
+++ b/src/common/hostlist.c
@@ -1,5 +1,5 @@
 /*****************************************************************************\
- *  $Id: hostlist.c 11863 2007-07-23 18:15:00Z jette $
+ *  $Id: hostlist.c 12180 2007-08-30 18:06:57Z jette $
  *****************************************************************************
  *  $LSDId: hostlist.c,v 1.14 2003/10/14 20:11:54 grondo Exp $
  *****************************************************************************
@@ -1794,7 +1794,7 @@ char *hostlist_pop(hostlist_t hl)
 {
 	char *host = NULL;
 	if(!hl) {
-		error("hostlist_pop: no hoslist given");
+		error("hostlist_pop: no hostlist given");
 		return NULL;
 	}
 	
diff --git a/src/plugins/sched/wiki2/hostlist.c b/src/plugins/sched/wiki2/hostlist.c
index bd8d0bfd7..3818d023d 100644
--- a/src/plugins/sched/wiki2/hostlist.c
+++ b/src/plugins/sched/wiki2/hostlist.c
@@ -96,7 +96,8 @@ extern char * moab2slurm_task_list(char *moab_tasklist, int *task_cnt)
 			if (slurm_tasklist[i] == ':') {
 				slurm_tasklist[i] = ',';
 				(*task_cnt)++;
-			}
+			} else if (slurm_tasklist[i] == ',')
+				(*task_cnt)++;
 		}		
 		return slurm_tasklist;
 	}
@@ -189,7 +190,8 @@ static char * _task_list(struct job_record *job_ptr)
 static void _append_hl_buf(char **buf, hostlist_t *hl_tmp, int *reps)
 {
 	int host_str_len = 4096;
-	char *host_str, rep_str[8];
+	char *host_str, tmp_str[64];
+	char *sep, *tok, *tok_p;
 
 	host_str = xmalloc(host_str_len);
 	hostlist_uniq(*hl_tmp);
@@ -197,11 +199,20 @@ static void _append_hl_buf(char **buf, hostlist_t *hl_tmp, int *reps)
 		host_str_len *= 2;
 		xrealloc(*host_str, host_str_len);
 	}
+	/* Note that host_str may be of this form "alpha,beta". We want
+	 * to record this as "alpha*#:beta*#" and NOT "alpha,beta*#" */
 	if (*buf)
-		xstrcat(*buf, ":");
-	xstrcat(*buf, host_str);
-	snprintf(rep_str, 8, "*%d", *reps);
-	xstrcat(*buf, rep_str);
+		sep = ":";
+	else
+		sep = "";
+	tok = strtok_r(host_str, ",", &tok_p);
+	while (tok) {
+		snprintf(tmp_str, sizeof(tmp_str), "%s%s*%d",
+			sep, tok, *reps);
+		xstrcat(*buf, tmp_str);
+		sep = ":";
+		tok = strtok_r(NULL, ",", &tok_p);
+	}
 	xfree(host_str);
 	hostlist_destroy(*hl_tmp);
 	*hl_tmp = (hostlist_t) NULL;
@@ -233,7 +244,7 @@ static char * _task_list_exp(struct job_record *job_ptr)
 
 		if (reps == job_ptr->alloc_lps[i]) {
 			/* append to existing hostlist record */
-			if (hostlist_push(hl_tmp, host))
+			if (hostlist_push(hl_tmp, host) == 0)
 				error("hostlist_push failure");
 		} else {
 			if (hl_tmp)
diff --git a/src/plugins/sched/wiki2/start_job.c b/src/plugins/sched/wiki2/start_job.c
index 57c90d02b..6c578bdf1 100644
--- a/src/plugins/sched/wiki2/start_job.c
+++ b/src/plugins/sched/wiki2/start_job.c
@@ -141,6 +141,7 @@ static int	_start_job(uint32_t jobid, int task_cnt, char *hostlist,
 	size_t node_name_len;
 	static uint32_t cr_test = 0, cr_enabled = 0;
 
+info("task_cnt=%d, hostlist=%s, tasklist=%s", task_cnt, hostlist, tasklist);
 	if (cr_test == 0) {
 		select_g_get_info_from_plugin(SELECT_CR_PLUGIN,
 						&cr_enabled);
@@ -187,10 +188,6 @@ static int	_start_job(uint32_t jobid, int task_cnt, char *hostlist,
 		goto fini;
 	}
 
-	xfree(job_ptr->details->req_node_layout);
-	job_ptr->details->req_node_layout = (uint16_t *) 
-			xmalloc(bit_set_count(new_bitmap) * sizeof(uint16_t));
-
 	/* User excluded node list incompatable with Wiki
 	 * Exclude all nodes not explicitly requested */
 	if (task_cnt) {
@@ -204,7 +201,10 @@ static int	_start_job(uint32_t jobid, int task_cnt, char *hostlist,
 	 * as cpus should be used per node); at this point, node names
 	 * are comma-separated. This is _not_ a fast algorithm as it
 	 * performs many string compares. */
-	if (cr_enabled) {
+	xfree(job_ptr->details->req_node_layout);
+	if (task_cnt && cr_enabled) {
+		job_ptr->details->req_node_layout = (uint16_t *)
+			xmalloc(bit_set_count(new_bitmap) * sizeof(uint16_t));
 		bsize = bit_size(new_bitmap);
 		for (i = 0, ll = -1; i < bsize; i++) {
 			if (!bit_test(new_bitmap, i))
diff --git a/src/plugins/select/cons_res/select_cons_res.c b/src/plugins/select/cons_res/select_cons_res.c
index 0c22388c3..416ee1366 100644
--- a/src/plugins/select/cons_res/select_cons_res.c
+++ b/src/plugins/select/cons_res/select_cons_res.c
@@ -2,7 +2,7 @@
  *  select_cons_res.c - node selection plugin supporting consumable 
  *  resources policies.
  *
- *  $Id: select_cons_res.c 11989 2007-08-10 15:07:39Z jette $
+ *  $Id: select_cons_res.c 12189 2007-08-31 17:57:29Z jette $
  *****************************************************************************\
  *
  *  The following example below illustrates how four jobs are allocated
@@ -2443,7 +2443,6 @@ extern int select_p_update_nodeinfo(struct job_record *job_ptr)
 					error("Job %u Host %s too many allocated sockets %u",
 					      job->job_id, this_node->node_ptr->name, 
 					      this_node->alloc_sockets);
-				this_node->alloc_memory += job->alloc_memory[i];
 				break;
 			case CR_CORE_MEMORY:
 				this_node->alloc_memory += job->alloc_memory[i];
diff --git a/src/salloc/opt.c b/src/salloc/opt.c
index 8c7af3c01..245fc959d 100644
--- a/src/salloc/opt.c
+++ b/src/salloc/opt.c
@@ -425,7 +425,7 @@ static void _opt_default()
 	opt.min_nodes = 1;
 	opt.max_nodes = 0;
 	opt.nodes_set = false;
-	opt.time_limit = 0;
+	opt.time_limit = NO_VAL;
 	opt.time_limit_str = NULL;
 	opt.partition = NULL;
 
@@ -1038,8 +1038,9 @@ static bool _opt_verify(void)
 			error("Invalid time limit specification");
 			exit(1);
 		}
-	} else
-		opt.time_limit = INFINITE;
+		if (opt.time_limit == 0)
+			opt.time_limit = INFINITE;
+	}
 
 	if ((opt.euid != (uid_t) -1) && (opt.euid != opt.uid)) 
 		opt.uid = opt.euid;
@@ -1248,7 +1249,7 @@ static void _opt_list()
 	info("immediate      : %s", tf_(opt.immediate));
 	if (opt.time_limit == INFINITE)
 		info("time_limit     : INFINITE");
-	else
+	else if (opt.time_limit != NO_VAL)
 		info("time_limit     : %d", opt.time_limit);
 	info("wait           : %d", opt.max_wait);
 	if (opt.nice)
diff --git a/src/salloc/salloc.c b/src/salloc/salloc.c
index 53843b8cd..3a0b60e8d 100644
--- a/src/salloc/salloc.c
+++ b/src/salloc/salloc.c
@@ -2,7 +2,7 @@
  *  salloc.c - Request a SLURM job allocation and
  *             launch a user-specified command.
  *
- *  $Id: salloc.c 12002 2007-08-14 02:55:43Z morrone $
+ *  $Id: salloc.c 12187 2007-08-31 16:07:57Z jette $
  *****************************************************************************
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -292,7 +292,7 @@ static int fill_job_desc_from_opts(job_desc_msg_t *desc)
 		desc->cpus_per_task = opt.cpus_per_task;
 	if (opt.no_kill)
 		desc->kill_on_node_fail = 0;
-	if (opt.time_limit > -1)
+	if (opt.time_limit  != NO_VAL)
 		desc->time_limit = opt.time_limit;
 	desc->shared = opt.shared;
 	desc->job_id = opt.jobid;
diff --git a/src/sattach/opt.c b/src/sattach/opt.c
index 763508c12..76463f276 100644
--- a/src/sattach/opt.c
+++ b/src/sattach/opt.c
@@ -1,6 +1,6 @@
 /*****************************************************************************\
  *  opt.c - options processing for sattach
- *  $Id: opt.c 10574 2006-12-15 23:38:29Z jette $
+ *  $Id: opt.c 12143 2007-08-27 15:59:41Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -305,7 +305,7 @@ void set_options(const int argc, char **argv)
 		switch (opt_char) {
 			
 		case '?':
-			fprintf(stderr, "Try \"sbatch --help\" for more "
+			fprintf(stderr, "Try \"sattach --help\" for more "
 				"information\n");
 			exit(1);
 			break;
diff --git a/src/sbatch/opt.c b/src/sbatch/opt.c
index 9b067350b..3b43bf053 100644
--- a/src/sbatch/opt.c
+++ b/src/sbatch/opt.c
@@ -82,6 +82,7 @@
 #define OPT_GEOMETRY	0x0b
 #define OPT_MULTI	0x0f
 #define OPT_EXCLUSIVE	0x10
+#define OPT_OVERCOMMIT	0x11
 
 /* generic getopt_long flags, integers and *not* valid characters */
 #define LONG_OPT_JOBID       0x105
@@ -399,7 +400,7 @@ static void _opt_default()
 	opt.max_nodes = 0;
 	opt.tasks_per_node   = -1;
 	opt.nodes_set = false;
-	opt.time_limit = 0;
+	opt.time_limit = NO_VAL;
 	opt.partition = NULL;
 
 	opt.job_name = NULL;
@@ -414,6 +415,7 @@ static void _opt_default()
 
 	opt.immediate	= false;
 	opt.no_requeue	= false;
+	opt.overcommit	= false;
 
 	opt.quiet = 0;
 	opt.verbose = 0;
@@ -478,6 +480,7 @@ env_vars_t env_vars[] = {
   {"SBATCH_MLOADER_IMAGE", OPT_STRING,     &opt.mloaderimage,  NULL           },
   {"SBATCH_NO_REQUEUE",    OPT_BOOL,       &opt.no_requeue,    NULL           },
   {"SBATCH_NO_ROTATE",     OPT_BOOL,       &opt.no_rotate,     NULL           },
+  {"SBATCH_OVERCOMMIT",    OPT_OVERCOMMIT, NULL,               NULL           },
   {"SBATCH_PARTITION",     OPT_STRING,     &opt.partition,     NULL           },
   {"SBATCH_RAMDISK_IMAGE", OPT_STRING,     &opt.ramdiskimage,  NULL           },
   {"SBATCH_TIMELIMIT",     OPT_STRING,     &opt.time_limit_str,NULL           },
@@ -581,6 +584,10 @@ _process_env_var(env_vars_t *e, const char *val)
 		opt.shared = 0;
 		break;
 
+	case OPT_OVERCOMMIT:
+		opt.overcommit = true;
+		break;
+
 	default:
 		/* do nothing */
 		break;
@@ -611,6 +618,7 @@ static struct option long_options[] = {
 	{"tasks",         required_argument, 0, 'n'},
 	{"nodes",         required_argument, 0, 'N'},
 	{"output",        required_argument, 0, 'o'},
+	{"overcommit",    no_argument,       0, 'O'},
 	{"partition",     required_argument, 0, 'p'},
 	{"quiet",         no_argument,       0, 'q'},
 	{"no-rotate",     no_argument,       0, 'R'},
@@ -1086,6 +1094,9 @@ static void _set_options(int argc, char **argv)
 			else
 				opt.ofname = _fullpath(optarg);
 			break;
+		case 'O':
+			opt.overcommit = true;
+			break;
 		case 'p':
 			xfree(opt.partition);
 			opt.partition = xstrdup(optarg);
@@ -1704,8 +1715,9 @@ static bool _opt_verify(void)
 			error("Invalid time limit specification");
 			exit(1);
 		}
-	} else
-		opt.time_limit = INFINITE;
+		if (opt.time_limit == 0)
+			opt.time_limit = INFINITE;
+	}
 
 	if ((opt.euid != (uid_t) -1) && (opt.euid != opt.uid)) 
 		opt.uid = opt.euid;
@@ -2013,9 +2025,10 @@ static void _opt_list()
 	info("verbose        : %d", opt.verbose);
 	info("immediate      : %s", tf_(opt.immediate));
 	info("no-requeue     : %s", tf_(opt.no_requeue));
+	info("overcommit     : %s", tf_(opt.overcommit));
 	if (opt.time_limit == INFINITE)
 		info("time_limit     : INFINITE");
-	else
+	else if (opt.time_limit != NO_VAL)
 		info("time_limit     : %d", opt.time_limit);
 	if (opt.nice)
 		info("nice           : %d", opt.nice);
@@ -2064,7 +2077,7 @@ static void _usage(void)
  	printf(
 "Usage: sbatch [-N nnodes] [-n ntasks]\n"
 "              [-c ncpus] [-r n] [-p partition] [--hold] [-t minutes]\n"
-"              [-D path] [--immediate] [--no-kill]\n"
+"              [-D path] [--immediate] [--no-kill] [--overcommit]\n"
 "              [--input file] [--output file] [--error file]\n"
 "              [--workdir=directory] [--share] [-m dist] [-J jobname]\n"
 "              [--jobid=id] [--verbose] [--gid=group] [--uid=user]\n"
@@ -2109,6 +2122,7 @@ static void _help(void)
 "  -d, --dependency=jobid      defer job until specified jobid completes\n"
 "  -D, --workdir=directory     set working directory for batch script\n"
 "      --nice[=value]          decrease secheduling priority by value\n"
+"  -O, --overcommit            overcommit resources\n"
 "  -U, --account=name          charge job to specified account\n"
 "      --begin=time            defer job until HH:MM DD/MM/YY\n"
 "      --comment=name          arbitrary comment\n"
diff --git a/src/sbatch/opt.h b/src/sbatch/opt.h
index 4a2faa1d9..8ffded1be 100644
--- a/src/sbatch/opt.h
+++ b/src/sbatch/opt.h
@@ -1,6 +1,6 @@
 /*****************************************************************************\
  *  opt.h - definitions for srun option processing
- *  $Id: opt.h 11992 2007-08-10 18:59:15Z jette $
+ *  $Id: opt.h 12190 2007-08-31 19:05:18Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -80,6 +80,7 @@ typedef struct sbatch_options {
 	bool hold;		/* --hold, -H			*/
 	bool no_kill;		/* --no-kill, -k		*/
 	bool no_requeue;	/* --no-requeue			*/
+	bool overcommit;	/* --overcommit -O		*/
 	uint16_t shared;	/* --share,   -s		*/
 	int  quiet;
 	int  verbose;
diff --git a/src/sbatch/sbatch.c b/src/sbatch/sbatch.c
index 11036414d..4cf25d217 100644
--- a/src/sbatch/sbatch.c
+++ b/src/sbatch/sbatch.c
@@ -1,7 +1,7 @@
 /*****************************************************************************\
  *  sbatch.c - Submit a SLURM batch script.
  *
- *  $Id: sbatch.c 11864 2007-07-24 17:29:39Z jette $
+ *  $Id: sbatch.c 12190 2007-08-31 19:05:18Z jette $
  *****************************************************************************
  *  Copyright (C) 2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -176,7 +176,11 @@ static int fill_job_desc_from_opts(job_desc_msg_t *desc)
 		desc->job_min_memory = opt.realmem;
 	if (opt.tmpdisk > -1)
 		desc->job_min_tmp_disk = opt.tmpdisk;
-	desc->num_procs = opt.nprocs * opt.cpus_per_task;
+	if (opt.overcommit) {
+		desc->num_procs = opt.min_nodes;
+		desc->overcommit = opt.overcommit;
+	} else
+		desc->num_procs = opt.nprocs * opt.cpus_per_task;
 	if (opt.tasks_per_node > -1)
 		desc->ntasks_per_node = opt.tasks_per_node;
 	if (opt.nprocs_set)
@@ -185,7 +189,7 @@ static int fill_job_desc_from_opts(job_desc_msg_t *desc)
 		desc->cpus_per_task = opt.cpus_per_task;
 	if (opt.no_kill)
 		desc->kill_on_node_fail = 0;
-	if (opt.time_limit > -1)
+	if (opt.time_limit != NO_VAL)
 		desc->time_limit = opt.time_limit;
 	desc->shared = opt.shared;
 
diff --git a/src/srun/opt.c b/src/srun/opt.c
index ad71a54d8..d6b165799 100644
--- a/src/srun/opt.c
+++ b/src/srun/opt.c
@@ -1,6 +1,6 @@
 /*****************************************************************************\
  *  opt.c - options processing for srun
- *  $Id: opt.c 12098 2007-08-22 22:35:51Z da $
+ *  $Id: opt.c 12187 2007-08-31 16:07:57Z jette $
  *****************************************************************************
  *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@@ -2415,8 +2415,9 @@ static bool _opt_verify(void)
 			error("Invalid time limit specification");
 			exit(1);
 		}
-	} else
-		opt.time_limit = INFINITE;
+		if (opt.time_limit == 0)
+			opt.time_limit = INFINITE;
+	}
 
 	if ((opt.euid != (uid_t) -1) && (opt.euid != opt.uid)) 
 		opt.uid = opt.euid;
@@ -2684,7 +2685,7 @@ static void _opt_list()
 	info("threads        : %d", opt.max_threads);
 	if (opt.time_limit == INFINITE)
 		info("time_limit     : INFINITE");
-	else
+	else if (opt.time_limit != NO_VAL)
 		info("time_limit     : %d", opt.time_limit);
 	info("wait           : %d", opt.max_wait);
 	if (opt.nice)
diff --git a/testsuite/expect/Makefile.am b/testsuite/expect/Makefile.am
index dc86c6144..490524f99 100644
--- a/testsuite/expect/Makefile.am
+++ b/testsuite/expect/Makefile.am
@@ -266,6 +266,8 @@ EXTRA_DIST = \
 	test17.28			\
 	test17.29			\
 	test17.30			\
+	test17.31			\
+	test17.32			\
 	test18.1			\
 	test18.2			\
 	test18.3			\
diff --git a/testsuite/expect/Makefile.in b/testsuite/expect/Makefile.in
index e8f883b57..e2dd00284 100644
--- a/testsuite/expect/Makefile.in
+++ b/testsuite/expect/Makefile.in
@@ -485,6 +485,8 @@ EXTRA_DIST = \
 	test17.28			\
 	test17.29			\
 	test17.30			\
+	test17.31			\
+	test17.32			\
 	test18.1			\
 	test18.2			\
 	test18.3			\
diff --git a/testsuite/expect/README b/testsuite/expect/README
index 6cb5b3a1f..5ba47c64e 100644
--- a/testsuite/expect/README
+++ b/testsuite/expect/README
@@ -448,7 +448,8 @@ test17.27  Test that a job executes with the specified nodes, requires multiple
 test17.28  Tests #SBATCH entry functionality in a batch script.
 test17.29  Verify that command arguments get forwarded to job script.
 test17.30  Test of comment field specification (--comment option).
-test17.28  Tests #PBS entry functionality in a batch script.
+test17.31  Tests #PBS entry functionality in a batch script.
+test17.32  Test of --overcommit option.
 
 
 test18.#   Testing of slaunch options.
diff --git a/testsuite/expect/test1.88 b/testsuite/expect/test1.88
index d6e56be95..2450d925f 100755
--- a/testsuite/expect/test1.88
+++ b/testsuite/expect/test1.88
@@ -159,7 +159,7 @@ if {[wait_for_file $file_out] == 0} {
 	set complete 0
 	spawn $bin_cat $file_out
 	expect {
-                -re "I just received msg from Rank" {
+                -re "just received msg from Rank" {
 			incr matches
                         exp_continue
                 }
diff --git a/testsuite/expect/test1.88.prog.c b/testsuite/expect/test1.88.prog.c
index 274ec89f5..09ab2a7e7 100644
--- a/testsuite/expect/test1.88.prog.c
+++ b/testsuite/expect/test1.88.prog.c
@@ -26,11 +26,13 @@
 
 #include <stdio.h>
 #include <mpi.h>
+#include <sys/utsname.h>
 
 #define COMM_TAG 1000
 
 static void pass_its_neighbor(const int rank, const int size, const int* buf)
 {
+	struct utsname uts;
 	MPI_Request request[2];
 	MPI_Status status[2];
 
@@ -40,8 +42,9 @@ static void pass_its_neighbor(const int rank, const int size, const int* buf)
 		MPI_COMM_WORLD, &request[1]);
 	MPI_Waitall(2, request, status);
 
-	fprintf(stdout, "Rank[%d] I just received msg from Rank %d\n", 
-		rank, *buf);
+	uname(&uts);
+	fprintf(stdout, "Rank[%d] on %s just received msg from Rank %d\n", 
+		rank, uts.nodename, *buf);
 }
 
 int main(int argc, char * argv[])
diff --git a/testsuite/expect/test17.31 b/testsuite/expect/test17.31
index 0f54069fa..681f2e6b7 100755
--- a/testsuite/expect/test17.31
+++ b/testsuite/expect/test17.31
@@ -42,8 +42,6 @@ set node_cnt    3
 set ppn_cnt     2
 set min_mem     1024
 
-append min_mem_mb $min_mem "mb"
-
 print_header $test_id
 
 set available [available_nodes [default_partition]]
@@ -53,6 +51,35 @@ if {$available < $node_cnt} {
 	exit $exit_code
 }
 
+log_user 0
+set scontrol_pid [spawn $scontrol show nodes]
+expect {
+	-re "CPUS=($number)" {
+		if {$expect_out(1,string) < $ppn_cnt} {
+			set ppn_cnt $expect_out(1,string)
+		}
+		exp_continue
+	}
+	-re "RealMemory=($number)" {
+		if {$expect_out(1,string) < $min_mem} {
+			set min_mem $expect_out(1,string)
+		}
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: scontrol not responding\n"
+		set exit_code 1
+		slow_kill $scontrol_pid
+		exp_continue
+	}
+	eof {
+		wait
+	}
+}
+log_user 1
+send_user "Actual configuration: min_cpus=$ppn_cnt  min_mem=$min_mem\n\n"
+append min_mem_mb $min_mem "mb"
+
 #
 # Build input script file
 # NOTE: The initial sleep is so that all of the submissions have time 
@@ -65,7 +92,7 @@ $bin_sleep $delay
 "
 
 set matches 0
-spawn $sbatch -vv -o $file_out $file_in
+set sbatch_pid [spawn $sbatch -vv -o $file_out $file_in]
 #exp_internal 1
 expect {
 	-re "nprocs$whitespace: ($number) \\(set\\)" {
@@ -79,27 +106,26 @@ expect {
 		}		
 		exp_continue
 	}
-	-re "mem=($number)" {
-		set mem $expect_out(1,string)
-		if { $mem != $min_mem } {
-			send_user "\nFAILURE: Min memory is different ($mem) than requested ($min_mem)\n"
+	-re "nodes$whitespace: ($number)" {
+		set nodes $expect_out(1,string)
+		if { $nodes != $node_cnt } {
+			send_user "\nFAILURE: Bad node count allocated\n"
 			set exit_code 1
 		} else {
 			incr matches
 		}
 		exp_continue
 	}
-	-re "nodes$whitespace: ($number)" {
-		set nodes $expect_out(1,string)
-		if { $nodes != $node_cnt } {
-			send_user "\nFAILURE: Bad node count allocated\n"
+	-re "mem=($number)" {
+		set mem $expect_out(1,string)
+		if { $mem != $min_mem } {
+			send_user "\nFAILURE: Min memory is different ($mem) than requested ($min_mem)\n"
 			set exit_code 1
 		} else {
 			incr matches
 		}
 		exp_continue
 	}
-	
 	-re "batch job ($number)" {
 		set job_id $expect_out(1,string)
 		exp_continue
@@ -113,6 +139,7 @@ expect {
 	timeout {
 		send_user "\nFAILURE: sbatch not responding\n"
 		set exit_code 1
+		slow_kill $sbatch_pid
 		exp_continue
 	}
 	eof {
diff --git a/testsuite/expect/test17.32 b/testsuite/expect/test17.32
new file mode 100755
index 000000000..032c1dba2
--- /dev/null
+++ b/testsuite/expect/test17.32
@@ -0,0 +1,122 @@
+#!/usr/bin/expect
+############################################################################
+# Purpose: Test of SLURM functionality
+#          Test of --overcommit option.
+#
+# Output:  "TEST: #.#" followed by "SUCCESS" if test was successful, OR
+#          "FAILURE: ..." otherwise with an explanation of the failure, OR
+#          anything else indicates a failure mode that must be investigated.
+############################################################################
+# Copyright (C) 2002-2007 The Regents of the University of California.
+# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+# Written by Morris Jette <jette1@llnl.gov>
+# UCRL-CODE-226842.
+# 
+# This file is part of SLURM, a resource management program.
+# For details, see <http://www.llnl.gov/linux/slurm/>.
+#  
+# SLURM is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option)
+# any later version.
+# 
+# SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+# details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with SLURM; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+############################################################################
+source ./globals
+
+set test_id     "17.32"
+set exit_code   0
+set file_in     "test$test_id.input"
+set file_out    "test$test_id.output"
+set job_id      0
+set task_cnt    10
+
+print_header $test_id
+
+#
+# Submit a slurm job that will execute 'id' on 4 tasks (or try anyway)
+#
+file delete $file_in $file_out
+make_bash_script $file_in "
+  env | grep SLURM | sort
+  $srun $bin_id"
+
+#
+# Submit a slurm job that will execute 'id' on 1 node and over task_cnt tasks
+#
+spawn $sbatch --tasks=$task_cnt --overcommit -N1 --output=$file_out -t1 $file_in
+expect {
+	-re "Submitted batch job ($number)" {
+		set job_id $expect_out(1,string)
+		exp_continue
+	}
+	-re "Batch job submission failed" {
+		send_user "\nNo worries, error not unexpected\n"
+		set no_run 1
+		exp_continue
+	}
+	timeout {
+		send_user "\nFAILURE: sbatch not responding\n"
+		set exit_code 1
+	}
+	eof {
+		wait
+	}
+}
+
+#
+# Wait for job to complete
+#
+if {[wait_for_job $job_id "DONE"] != 0} {
+	send_user "\nFAILURE: waiting for job to complete\n"
+	set exit_code 1
+}
+set matches     0
+set tasks       0
+if {[wait_for_file $file_out] == 0} {
+	spawn $bin_cat $file_out
+	expect {
+		-re "SLURM_NPROCS=$task_cnt" {
+			incr matches
+			exp_continue
+		}
+		-re "SLURM_OVERCOMMIT=1" {
+			incr matches
+			exp_continue
+		}
+		-re "uid=" {
+			incr tasks
+			exp_continue
+		}
+		eof {
+			wait
+		}
+	}
+}
+if {$matches != 2} {
+	send_user "\nFAILURE: Did not set desired allocation env vars\n"
+	set exit_code 1
+}
+if {$task_cnt != $tasks} {
+	send_user "\nFAILURE: Did not get proper number of tasks: "
+	send_user "$task_cnt, $tasks\n"
+	set exit_code 1
+}
+
+if {$task_cnt != $tasks} {
+	send_user "\nFAILURE: Did not get proper number of tasks: "
+	send_user "$task_cnt, $tasks\n"
+	set exit_code 1
+}
+if {$exit_code == 0} {
+	file delete $file_in $file_out
+	send_user "\nSUCCESS\n"
+}
+exit $exit_code
diff --git a/testsuite/expect/test17.6 b/testsuite/expect/test17.6
index b78233bb9..2d845385d 100755
--- a/testsuite/expect/test17.6
+++ b/testsuite/expect/test17.6
@@ -42,7 +42,7 @@ set tasks       0
 print_header $test_id
 
 #
-# Submit a slurm job that will execute 'id' on 4 tasks (or try) anway
+# Submit a slurm job that will execute 'id' on 4 tasks (or try anyway)
 #
 file delete $file_in $file_out
 make_bash_script $file_in "$slaunch $bin_id"
-- 
GitLab