diff -u -r dump-0.4b23-orig/dump/dump.h dump-0.4b23/dump/dump.h
--- dump-0.4b23-orig/dump/dump.h	Wed Aug  1 22:31:31 2001
+++ dump-0.4b23/dump/dump.h	Wed Aug 15 21:39:43 2001
@@ -90,7 +90,11 @@
 int	etapes;		/* estimated number of tapes */
 int	nonodump;	/* if set, do not honor UF_NODUMP user flags */
 int	unlimited;	/* if set, write to end of medium */
-int	compressed;	/* if set, dump is to be compressed */
+int     compressed;     /* if set, dump is to be compressed; */
+int	compressLevel;	/* compression level*/
+int     compressIncrement; /* if set, % to increase dynamic compression level */
+int     compressDecrement; /* if set, % to decrease dynamic compression level */
+int     tickLimit;      /* tick threshold for 'keeping up' or not */
 long long bytes_written;/* total bytes written to tape */
 long	uncomprblks;	/* uncompressed blocks written to tape */
 int	notify;		/* notify operator flag */
diff -u -r dump-0.4b23-orig/dump/main.c dump-0.4b23/dump/main.c
--- dump-0.4b23-orig/dump/main.c	Thu Jul 19 02:49:35 2001
+++ dump-0.4b23/dump/main.c	Wed Aug 15 21:41:36 2001
@@ -102,7 +102,11 @@
 long	blocksperfile;	/* output blocks per file */
 char	*host = NULL;	/* remote host (if any) */
 int	sizest = 0;	/* return size estimate only */
-int	compressed = 0;	/* use zlib to compress the output, compress level 1-9 */
+int     compressed = 0; /* use zlib to compress the output */
+int	compressLevel = 0; /* compress level 1-9 */
+int     compressIncrement = 0; /* % to increase dynamic compression level */
+int     compressDecrement = 0; /* % to decrease dynamic compression level */
+int     tickLimit = 2;  /* # of ticks of write delay to tolerate */
 long long bytes_written = 0; /* total bytes written */
 long	uncomprblks = 0;/* uncompressed blocks written */
 
@@ -180,7 +184,7 @@
 #endif
 			    "s:ST:uWw"
 #ifdef HAVE_ZLIB
-			    "z::"
+			    "z::I:D:l:"
 #endif
 			    )) != -1)
 		switch (ch) {
@@ -321,9 +325,19 @@
 			exit(X_FINOK);	/* do nothing else */
 #ifdef HAVE_ZLIB
 		case 'z':
-			compressed = 2;
+		        compressed = 1;
+			compressLevel = 2;
 			if (optarg)
-				compressed = numarg("compress level", 1L, 9L);
+				compressLevel = numarg("compress level", 1L, 9L);
+			break;
+		case 'I':
+			compressIncrement = numarg("compression increment", 0L, 100L);
+			break;
+		case 'D':
+			compressDecrement = numarg("compression decrement", 0L, 100L);
+			break;
+		case 'l':
+			tickLimit = numarg("write-latency limit", 0L, 100L);
 			break;
 #endif /* HAVE_ZLIB */
 
@@ -624,7 +638,7 @@
 
 		if (compressed)
 			msg("Compressing output at compression level %d\n", 
-			    compressed);
+			    compressLevel);
 	}
 
 #if defined(SIGINFO)
diff -u -r dump-0.4b23-orig/dump/tape.c dump-0.4b23/dump/tape.c
--- dump-0.4b23-orig/dump/tape.c	Fri Jul 20 04:02:45 2001
+++ dump-0.4b23/dump/tape.c	Wed Aug 15 22:19:12 2001
@@ -64,6 +64,7 @@
 #ifdef __linux__
 #include <sys/types.h>
 #include <sys/time.h>
+#include <sys/times.h>
 #include <time.h>
 #endif
 #include <sys/param.h>
@@ -1021,6 +1022,9 @@
 	struct tapebuf *comp_buf = NULL;
 	int compresult, do_compress = !first;
 	unsigned long worklen;
+        clock_t ticksBefore, ticksAfter;
+        struct tms tmsTime;
+        int percentSlide;
 #endif /* HAVE_ZLIB */
 	struct slave_results returns;
 #ifdef	__linux__
@@ -1060,6 +1064,7 @@
 		if (comp_buf == NULL)
 			quit("couldn't allocate a compress buffer.\n");
 		comp_buf->flags = 0;
+	        percentSlide = 50;
 	}
 #endif /* HAVE_ZLIB */
 
@@ -1107,8 +1112,13 @@
 		if (compressed && do_compress) {
 			comp_buf->length = bufsize;
 			worklen = TP_BSIZE + writesize;
-			compresult = compress2(comp_buf->buf, &worklen,
-				(char *)slp->tblock[0], writesize, compressed);
+		        if (compressLevel > 0) {
+			   compresult = compress2(comp_buf->buf, &worklen,
+						  (char *)slp->tblock[0], writesize, compressLevel);
+			} else {
+			   compresult = Z_OK;
+			   worklen = writesize;
+			}
 			if (compresult == Z_OK && worklen <= (writesize - 16)) {
 				/* write the compressed buffer */
 				comp_buf->length = worklen;
@@ -1168,7 +1178,11 @@
 				wrote = rmtwrite(buffer + size, bufsize - size);
 			else
 #endif
+		     {
+				ticksBefore = times(&tmsTime);
 				wrote = write(tapefd, buffer + size, bufsize - size);
+				ticksAfter = times(&tmsTime);
+		     }
 #ifdef WRITEDEBUG
 			printf("slave %d wrote %d\n", slave_number, wrote);
 #endif
@@ -1177,6 +1191,49 @@
 			if (wrote == 0)
 				eot_count++;
 			size += wrote;
+
+#ifdef HAVE_ZLIB
+		        if (compressed) {
+			   if (ticksAfter - ticksBefore >= tickLimit) {
+			      /*
+			       * The write took a relatively long time to
+			       * complete - enough so that we 'believe' that
+			       * we're keeping up with the output device.
+			       * Gradually crank up the compression level.
+			       */
+			      percentSlide += compressIncrement;
+			      if (percentSlide > 120) {
+				 percentSlide -= 100;
+				 if (compressLevel < 9) {
+				    compressLevel++;
+#ifdef DCDEBUG
+				    msg("Pid %d compressing at level %d\n", getpid(), compressLevel);
+#endif
+				 }
+			      }
+			   } else {
+			      /*
+			       * The write completed quickly.  We interpret
+			       * this as an indication that we aren't keeping
+			       * up with the output device and that it might
+			       * drop out of streaming, which would be bad for
+			       * throughput and could be fatally bad if we're
+			       * burning to a CD-R.  Gradually reduce the
+			       * compression level.
+			       */
+			      percentSlide -= compressDecrement;
+			      if (percentSlide < 0) {
+				 percentSlide += 100;
+				 if (compressLevel >= 1) {
+				    compressLevel--;
+#ifdef DCDEBUG
+				    msg("Pid %d compressing at level %d\n", getpid(), compressLevel);
+#endif
+				 }
+			      }
+			   }
+			}
+#endif		   
 		}
 
 #ifdef WRITEDEBUG
