[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-stable
Subject:    Re: 4.8-p7 kernel panic (kld pcm related panic)
From:       Barry Bouwsma <freebsd-misuser () remove-NOSPAM-to-reply ! NOSPAM ! dyndns ! dk>
Date:       2003-09-30 3:18:13
[Download RAW message or body]

[Drop hostname part of IPv6-only address above to obtain IPv4-capable e-mail,
 or just drop me from the recipients and I'll catch up from the archives]


> It seems that the savecore is not working in my setup from the rc scripts. 
> However it seems to work when run by hand.  Backtrace attached.

> > a kernel panic while X was running.  Unfortunately I cannot provide a back
> > trace because savecore did not work (see messages below) and I do not have
> > P.S.  How can I fix savecore?  I have two ide drives, and a swap partition on
> Sep 19 11:43:21 amnesiac savecore: writing compressed core to
> /devel/freebsd/crash/vmcore.0.gz
> Sep 19 11:43:21 amnesiac savecore: /devel/freebsd/crash/vmcore.0.gz: Illegal
> seek
> Sep 19 11:43:21 amnesiac savecore: WARNING: vmcore may be incomplete

I have a patch (for savecore, that is).  The problem is you're trying to
write a compressed core at boot.  You need to change your boot savecore
flags not to use the `-z' flag, or try out my ugly hack.

My apologies if someone else has already fixed this or replied with a fix
in the last week that I've been offline.

Change the Makefile /usr/src/sbin/savecore/Makefile to add zopen.c to SRCS,
or bzopen.c if you want to use bzip2 compression, which I found saves a
small bit of space but takes far longer than gzip when checking performance
vs space on a slow (120MHz) machine.

Grab the zopen.c file you can find in the libz source, or change the makefile
to point to it.  Or the bzopen.c file if you want that.  Actually, looking
at the zopen.c file, it won't do to change the makefile, since I see a hack
I added.  I suspect I made a similar hack to bzopen.c...

--- /usr/local/system/src/lib/libz/zopen.c	Mon Oct  1 00:53:01 2001
+++ /usr/local/source-hacks/sbin/savecore/zopen.c	Sat Jun 21 12:00:48 2003
@@ -10,7 +10,7 @@
 #include <stdio.h>
 #include <zlib.h>
 
-FILE *zopen(const char *fname, const char *mode);
+FILE *fzopen(const char *fname, const char *mode);
 
 /* convert arguments */
 static int
@@ -25,8 +25,14 @@
     return gzwrite(cookie, (void*)data, size);
 }
 
+static fpos_t
+xgzseek(void *cookie,  fpos_t offset, int whence)
+{
+    return gzseek(cookie, (z_off_t)offset, whence);
+}
+
 FILE *
-zopen(const char *fname, const char *mode)
+fzopen(const char *fname, const char *mode)
 {
     gzFile gz = gzopen(fname, mode);
     if(gz == NULL)
@@ -35,5 +41,5 @@
     if(*mode == 'r')
 	return (funopen(gz, xgzread, NULL, NULL, gzclose));
     else
-	return (funopen(gz, NULL, xgzwrite, NULL, gzclose));
+	return (funopen(gz, NULL, xgzwrite, xgzseek, gzclose));
 }


Then patch savecore.c, using the below diff as a guide (it's ugly as sin
since I've not cleaned it up and left copious notes for myself, sorry,
but the actual changes should be trivial and easy to spot)...


--- /usr/local/source-hacks/sbin/savecore/savecore.c-DIST	Tue Jun 25 00:26:35 2002
+++ /usr/local/source-hacks/sbin/savecore/savecore.c	Sun Jun 22 09:37:53 2003
@@ -64,7 +64,10 @@
 #include <string.h>
 #include <unistd.h>
 
-extern FILE *zopen(const char *fname, const char *mode);
+/* XXX HACK extern FILE *zopen(const char *fname, const char *mode); */
+extern FILE *fzopen(const char *fname, const char *mode); /* XXX GREAT */
+/* XXXX Let's not use bzlib, eh, while it takes 21min whilst zlib takes
+        somewhere between 4 and 12 min, eh?     extern FILE *Bzopen(const char \
*fname, const char *mode);   */  
 #ifdef __alpha__
 #define ok(number) ALPHA_K0SEG_TO_PHYS(number)
@@ -401,7 +404,14 @@
 	(void)snprintf(path, sizeof(path), "%s/vmcore.%d%s",
 	    savedir, bounds, compress ? ".gz" : "");
 	if (compress)
-		fp = zopen(path, "w");
+		/* XXX HACK fp = zopen(path, "w"); */
+/* using wb1h instead means time of 4m16 sec (a win) and size of 54M a LOSE
+     optimizing for space wb9 gives time of forever... 12m28s size 47,01M,
+	hardly an improvement over default wb6...   */
+		/* GRRR  fp = Bzopen(path, "wb1"); */
+		fp = fzopen(path, "wb1");
+/* XXX With virginal boot, wb1 compressed core with fseek takes 1m22s
+	while default wb6 takes 2m58s, sizes 4,3M vs 3,8M ... */
 	else
 		fp = fopen(path, "w");
 	if (fp == NULL) {
@@ -428,6 +438,15 @@
 				syslog(LOG_ERR, "%s: %m", ddname);
 			goto err2;
 		}
+#if 1  /* XXXX Enabled for bzlib and needed for normal zopen... */
+/* Hmmm.  With a virginal dump, using this and zlib (no fseek) takes
+   1m 18s (rather than 1m22s), can it be slightly faster? */
+		if (compress) {
+			nw = fwrite(buf, 1, nr, fp);
+		} else
+#endif   /*   XXX   could also be buf, nr, 1, fp, eh? */
+		{
+/*  end HACK, above took 6m 11s... */
 		for (nw = 0; nw < nr; nw = he) {
 			/* find a contiguous block of zeroes */
 			for (hs = nw; hs < nr; hs += BLOCKSIZE) {
@@ -461,8 +480,19 @@
 				if (fwrite(buf + nw, hs - nw, 1, fp) != 1)
 					break;
 			if (he > hs)
+#if 0  /* XXXX try without... */
+/* Somehow this doesn't work with a `zopen'ed file... */
+			    if (compress) {
+/* fwrite() took 6m7s...  */
+				if (fwrite(buf + hs, he - hs, 1, fp) != 1)
+					break;
+			    } else /* XXX HACK */
+#endif  /*  XXX  0 */
+/* XXX Fixing zopen() to accept gzseek()s lets this work with 6m6s
+       time to dump/compress... */
 				if (fseeko(fp, he - hs, SEEK_CUR) == -1)
 					break;
+		} /* XXX HACK */
 		}
 		if (nw != nr) {
 			syslog(LOG_ERR, "%s: %m", path);
@@ -480,7 +510,15 @@
 	(void)snprintf(path, sizeof(path), "%s/kernel.%d%s",
 	    savedir, bounds, compress ? ".gz" : "");
 	if (compress)
-		fp = zopen(path, "w");
+		/* XXX HACK  fp = zopen(path, "w"); */
+/* XXX wb1f changes time from 6m6s to 4m43s... size increases from 47,05M to
+						47,69M...
+      Just wb1 gives time of 4m42s and size same as wb1f... */
+/* XXX AIEE.  Bzopen wb1 is dawg-slow with time 21m28s, size 46,88M
+	with virginal dump, 4m33s , size down from 4,29M to 3,66M
+		wb9 much worse; almost 31m, size 45,42M ....  */
+		/* fp = Bzopen(path, "wb1");    AIEEE */
+		fp = fzopen(path, "wb1");
 	else
 		fp = fopen(path, "w");
 	if (fp == NULL) {


There's no guarantee that the latest source code is the same as the 4.7-ish
source that I patched, so if someone wants to do this the Right Way, well,
have at it.  I just wanted to see if I could write compressed dumps, then
as my machine is dawg-slow anyway, decided to not bother -- instead I do
as you did and run from the commandline since my dump destination is mounted
by default read-only, as I try to avoid the amount of fsckin' needed after
a panic with half a terabyte of filesystems.


Barry Bouwsma

_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org"


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic