[OpenAFS-devel] Kernel panic with openafs 1.4.0

chas williams - CONTRACTOR chas@cmf.nrl.navy.mil
Sat, 26 Aug 2006 12:38:36 -0400


In message <87FD290119261E9B530AAD58@sirius.fac.cs.cmu.edu>,Jeffrey Hutzelman w
rites:
>Besides calling BUG() inline, which is a good thing, your code has the 
>effect of changing the behavior on 2.4 so that we call BUG() instead of 

does this version feel warm and fuzzy?  it also "fixes" osi_Assert()
to use BUG() as well.  i didn't want to cut up two header files with
the same #ifdef so i #undef'd so it would all be in the "same" place.

a related change is that osi_AssertFailK() now just does a printk()
instead of formatting a 1k buffer.  its a good idea to avoid using too
much stack on 2.6 kernels since some actually have 4k stacks.

Index: src/rx/rx_prototypes.h
===================================================================
--- src/rx/rx_prototypes.h	(revision 49)
+++ src/rx/rx_prototypes.h	(working copy)
@@ -325,7 +325,14 @@
 extern void rxk_shutdownPorts(void);
 extern osi_socket rxi_GetUDPSocket(u_short port);
 extern osi_socket rxi_GetHostUDPSocket(u_int host, u_short port);
-extern void osi_Panic();
+#if defined(KERNEL) && defined(AFS_LINUX26_ENV)
+#define osi_Panic(msg...) do { printk(KERN_CRIT "openafs: " msg); BUG(); } while (0)
+#undef osi_Assert
+#define osi_Assert(expr) \
+    do { if (!(expr)) { osi_AssertFailK(#expr, __FILE__, __LINE__); BUG(); } } while (0)
+#else
+extern void osi_Panic();	/* leave without args till stdarg rewrite */
+#endif
 extern int osi_utoa(char *buf, size_t len, unsigned long val);
 extern void rxi_InitPeerParams(register struct rx_peer *pp);
 extern void shutdown_rxkernel(void);
@@ -556,7 +563,6 @@
 extern osi_socket rxi_GetUDPSocket(u_short port);
 extern void osi_AssertFailU(const char *expr, const char *file, int line);
 extern int rx_getAllAddr(afs_int32 * buffer, int maxSize);
-extern void osi_Panic();	/* leave without args till stdarg rewrite */
 extern void rxi_InitPeerParams(struct rx_peer *pp);
 
 #if defined(AFS_AIX32_ENV) && !defined(KERNEL)
Index: src/rx/rx_kcommon.c
===================================================================
--- src/rx/rx_kcommon.c	(revision 49)
+++ src/rx/rx_kcommon.c	(working copy)
@@ -124,6 +124,7 @@
     return rxi_GetHostUDPSocket(htonl(INADDR_ANY), port);
 }
 
+#if !defined(AFS_LINUX26_ENV)
 void
 osi_Panic(msg, a1, a2, a3)
      char *msg;
@@ -132,7 +133,7 @@
 	msg = "Unknown AFS panic";
 
     printf(msg, a1, a2, a3);
-#ifdef AFS_LINUX24_ENV
+#ifdef AFS_LINUX20_ENV
     * ((char *) 0) = 0; 
 #else
     panic(msg);
@@ -261,6 +262,13 @@
 
     osi_Panic(buf);
 }
+#else
+void
+osi_AssertFailK(const char *expr, const char *file, int line)
+{
+    printk(KERN_CRIT "assertion failed: %s, file: %s, line: %d\n", expr, file, line);
+}
+#endif
 
 #ifndef UKERNEL
 /* This is the server process request loop. Kernel server
Index: src/afs/afs_osi.h
===================================================================
--- src/afs/afs_osi.h	(revision 49)
+++ src/afs/afs_osi.h	(working copy)
@@ -220,7 +220,7 @@
 
 #ifdef AFS_GLOBAL_SUNLOCK
 #define AFS_ASSERT_GLOCK() \
-    (ISAFS_GLOCK() || (osi_Panic("afs global lock not held at %s:%d\n", __FILE__, __LINE__), 0))
+    do { if (!ISAFS_GLOCK()) osi_Panic("afs global lock not held at %s:%d\n", __FILE__, __LINE__); } while (0)
 #endif /* AFS_GLOBAL_SUNLOCK */
 
 #ifdef RX_ENABLE_LOCKS