Unix CM: Catch ICL initialisation failures
[openafs.git] / src / afs / afs_icl.c
index c8547ef..60520e1 100644 (file)
@@ -24,9 +24,6 @@
 #include "netinet/in_var.h"
 #endif
 #endif /* !defined(UKERNEL) */
-#ifdef AFS_LINUX22_ENV
-#include "h/smp_lock.h"
-#endif
 
 
 struct afs_icl_set *afs_iclSetp = (struct afs_icl_set *)0;
@@ -86,14 +83,17 @@ afs_icl_InitLogs(void)
 
     /* initialize the ICL system */
     code = afs_icl_CreateLog("cmfx", 60 * 1024, &logp);
-    if (code == 0)
-       code =
-           afs_icl_CreateSetWithFlags("cm", logp, NULL,
-                                      ICL_CRSET_FLAG_DEFAULT_OFF,
-                                      &afs_iclSetp);
-    code =
-       afs_icl_CreateSet("cmlongterm", logp, NULL,
-                         &afs_iclLongTermSetp);
+    if (code)
+       return code;
+
+    code = afs_icl_CreateSetWithFlags("cm", logp, NULL,
+                                     ICL_CRSET_FLAG_DEFAULT_OFF,
+                                     &afs_iclSetp);
+    if (code)
+       return code;
+
+    code = afs_icl_CreateSet("cmlongterm", logp, NULL,
+                            &afs_iclLongTermSetp);
     return code;
 }
 
@@ -129,7 +129,7 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
     afs_int32 code;
     struct afs_icl_log *logp;
     struct afs_icl_set *setp;
-#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if defined(AFS_SGI61_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
     size_t temp;
 #else /* AFS_SGI61_ENV */
 #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
@@ -181,7 +181,7 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
        if (!logp)
            return ENOENT;
 #define        BUFFERSIZE      AFS_LRALLOCSIZ
-       lp = (afs_int32 *) osi_AllocLargeSpace(AFS_LRALLOCSIZ);
+       lp = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
        elts = BUFFERSIZE / sizeof(afs_int32);
        if (p3 < elts)
            elts = p3;
@@ -410,6 +410,7 @@ afs_icl_Event4(struct afs_icl_set *setp, afs_int32 eventID,
        return 0;
 
     AFS_ASSERT_GLOCK();
+    afs_icl_SetHold(setp);
     mask = lAndT >> 24 & 0xff; /* mask of which logs to log to */
     ix = ICL_EVENTBYTE(eventID);
     ObtainReadLock(&setp->lock);
@@ -425,6 +426,7 @@ afs_icl_Event4(struct afs_icl_set *setp, afs_int32 eventID,
        }
     }
     ReleaseReadLock(&setp->lock);
+    afs_icl_SetRele(setp);
     return 0;
 }
 
@@ -746,8 +748,7 @@ afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags,
        }
     }
 
-    logp = (struct afs_icl_log *)
-       osi_AllocSmallSpace(sizeof(struct afs_icl_log));
+    logp = osi_AllocSmallSpace(sizeof(struct afs_icl_log));
     memset((caddr_t) logp, 0, sizeof(*logp));
 
     logp->refCount = 1;
@@ -932,8 +933,8 @@ afs_icl_LogUse(struct afs_icl_log *logp)
            /* we weren't passed in a hint and it wasn't set */
            logp->logSize = ICL_DEFAULT_LOGSIZE;
        }
-       logp->datap =
-           (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logp->logSize);
+       logp->datap = afs_osi_Alloc(sizeof(afs_int32) * logp->logSize);
+       osi_Assert(logp->datap != NULL);
 #ifdef KERNEL_HAVE_PIN
        pin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
 #endif
@@ -980,8 +981,8 @@ afs_icl_LogSetSize(struct afs_icl_log *logp, afs_int32 logSize)
 #ifdef KERNEL_HAVE_PIN
        unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
 #endif
-       logp->datap =
-           (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize);
+       logp->datap = afs_osi_Alloc(sizeof(afs_int32) * logSize);
+       osi_Assert(logp->datap != NULL);
 #ifdef KERNEL_HAVE_PIN
        pin((char *)logp->datap, sizeof(afs_int32) * logSize);
 #endif
@@ -1154,7 +1155,7 @@ afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp,
     if (flags & ICL_CRSET_FLAG_PERSISTENT)
        states |= ICL_SETF_PERSISTENT;
 
-    setp = (struct afs_icl_set *)osi_AllocSmallSpace(sizeof(struct afs_icl_set));
+    setp = osi_AllocSmallSpace(sizeof(struct afs_icl_set));
     memset((caddr_t) setp, 0, sizeof(*setp));
     setp->refCount = 1;
     if (states & ICL_SETF_FREED)
@@ -1171,6 +1172,7 @@ afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp,
     strcpy(setp->name, name);
     setp->nevents = ICL_DEFAULTEVENTS;
     setp->eventFlags = afs_osi_Alloc(ICL_DEFAULTEVENTS);
+    osi_Assert(setp->eventFlags != NULL);
 #ifdef KERNEL_HAVE_PIN
     pin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
 #endif