afs: remove dead ICL (fstrace) code
[openafs.git] / src / afs / afs_icl.c
index 1310ce8..dd77f36 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
@@ -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;
@@ -58,16 +55,14 @@ shutdown_icl(void)
     struct afs_icl_log *logp;
     struct afs_icl_set *setp;
 
-    setp = afs_icl_FindSet("cm");
-    if (setp) {
-       /* Release the reference from Find, and the initial one */
-       afs_icl_SetFree(setp);
+    if (afs_iclSetp) {
+       setp = afs_iclSetp;  /* "cm" */
+       afs_iclSetp = NULL;
        afs_icl_SetFree(setp);
     }
-    setp = afs_icl_FindSet("cmlongterm");
-    if (setp) {
-       /* Release the reference from Find, and the initial one */
-       afs_icl_SetFree(setp);
+    if (afs_iclLongTermSetp) {
+       setp = afs_iclLongTermSetp; /* "cmlongterm" */
+       afs_iclLongTermSetp = NULL;
        afs_icl_SetFree(setp);
     }
     logp = afs_icl_FindLog("cmfx");
@@ -86,14 +81,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 +127,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 +179,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;
@@ -240,7 +238,7 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
        setp = afs_icl_FindSet(tname);
        if (!setp)
            return ENOENT;
-       if (p2 > ICL_LOGSPERSET)
+       if (p2 >= ICL_LOGSPERSET)
            return EINVAL;
        if (!(tlp = setp->logs[p2]))
            return EBADF;
@@ -410,6 +408,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 +424,7 @@ afs_icl_Event4(struct afs_icl_set *setp, afs_int32 eventID,
        }
     }
     ReleaseReadLock(&setp->lock);
+    afs_icl_SetRele(setp);
     return 0;
 }
 
@@ -545,18 +545,6 @@ afs_icl_AppendString(struct afs_icl_log *logp, char *astr)
 #define ICL_APPENDLONG(lp, x) ICL_APPENDINT32((lp), (x))
 #endif
 
-/* routine to tell whether we're dealing with the address or the
- * object itself
- */
-int
-afs_icl_UseAddr(int type)
-{
-    if (type == ICL_TYPE_HYPER || type == ICL_TYPE_STRING
-       || type == ICL_TYPE_FID || type == ICL_TYPE_INT64)
-       return 1;
-    else
-       return 0;
-}
 
 void
 afs_icl_AppendOne(struct afs_icl_log *logp, int type, long parm)
@@ -614,7 +602,7 @@ afs_icl_AppendRecord(struct afs_icl_log *logp, afs_int32 op,
 {
     int rsize;                 /* record size in longs */
     int tsize;         /* temp size */
-    osi_timeval_t tv;
+    osi_timeval32_t tv;
     int t1, t2, t3, t4;
 
     t4 = types & 0x3f;         /* decode types */
@@ -746,8 +734,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;
@@ -890,19 +877,6 @@ afs_icl_CopyOut(struct afs_icl_log *logp, afs_int32 * bufferp,
     return code;
 }
 
-/* return basic parameter information about a log */
-int
-afs_icl_GetLogParms(struct afs_icl_log *logp, afs_int32 * maxSizep,
-                   afs_int32 * curSizep)
-{
-    ObtainReadLock(&logp->lock);
-    *maxSizep = logp->logSize;
-    *curSizep = logp->logElements;
-    ReleaseReadLock(&logp->lock);
-    return 0;
-}
-
-
 /* hold and release logs */
 int
 afs_icl_LogHold(struct afs_icl_log *logp)
@@ -913,14 +887,6 @@ afs_icl_LogHold(struct afs_icl_log *logp)
     return 0;
 }
 
-/* hold and release logs, called with lock already held */
-int
-afs_icl_LogHoldNL(struct afs_icl_log *logp)
-{
-    logp->refCount++;
-    return 0;
-}
-
 /* keep track of how many sets believe the log itself is allocated */
 int
 afs_icl_LogUse(struct afs_icl_log *logp)
@@ -932,8 +898,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 +946,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
@@ -1076,32 +1042,6 @@ afs_icl_FindLog(char *name)
     return tp;
 }
 
-int
-afs_icl_EnumerateLogs(int (*aproc)
-                       (char *name, char *arock, struct afs_icl_log * tp),
-                     char *arock)
-{
-    struct afs_icl_log *tp;
-    afs_int32 code;
-
-    code = 0;
-    ObtainWriteLock(&afs_icl_lock, 195);
-    for (tp = afs_icl_allLogs; tp; tp = tp->nextp) {
-       tp->refCount++;         /* hold this guy */
-       ReleaseWriteLock(&afs_icl_lock);
-       ObtainReadLock(&tp->lock);
-       code = (*aproc) (tp->name, arock, tp);
-       ReleaseReadLock(&tp->lock);
-       ObtainWriteLock(&afs_icl_lock, 196);
-       if (--tp->refCount == 0)
-           afs_icl_ZapLog(tp);
-       if (code)
-           break;
-    }
-    ReleaseWriteLock(&afs_icl_lock);
-    return code;
-}
-
 struct afs_icl_set *afs_icl_allSets = 0;
 
 int
@@ -1154,7 +1094,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 +1111,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
@@ -1201,46 +1142,6 @@ afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp,
     return 0;
 }
 
-/* function to change event enabling information for a particular set */
-int
-afs_icl_SetEnable(struct afs_icl_set *setp, afs_int32 eventID, int setValue)
-{
-    char *tp;
-
-    ObtainWriteLock(&setp->lock, 200);
-    if (!ICL_EVENTOK(setp, eventID)) {
-       ReleaseWriteLock(&setp->lock);
-       return -1;
-    }
-    tp = &setp->eventFlags[ICL_EVENTBYTE(eventID)];
-    if (setValue)
-       *tp |= ICL_EVENTMASK(eventID);
-    else
-       *tp &= ~(ICL_EVENTMASK(eventID));
-    ReleaseWriteLock(&setp->lock);
-    return 0;
-}
-
-/* return indication of whether a particular event ID is enabled
- * for tracing.  If *getValuep is set to 0, the event is disabled,
- * otherwise it is enabled.  All events start out enabled by default.
- */
-int
-afs_icl_GetEnable(struct afs_icl_set *setp, afs_int32 eventID, int *getValuep)
-{
-    ObtainReadLock(&setp->lock);
-    if (!ICL_EVENTOK(setp, eventID)) {
-       ReleaseWriteLock(&setp->lock);
-       return -1;
-    }
-    if (setp->eventFlags[ICL_EVENTBYTE(eventID)] & ICL_EVENTMASK(eventID))
-       *getValuep = 1;
-    else
-       *getValuep = 0;
-    ReleaseReadLock(&setp->lock);
-    return 0;
-}
-
 /* hold and release event sets */
 int
 afs_icl_SetHold(struct afs_icl_set *setp)
@@ -1344,54 +1245,6 @@ afs_icl_ZeroSet(struct afs_icl_set *setp)
 }
 
 int
-afs_icl_EnumerateSets(int (*aproc)
-                       (char *name, char *arock, struct afs_icl_log * tp),
-                     char *arock)
-{
-    struct afs_icl_set *tp, *np;
-    afs_int32 code;
-
-    code = 0;
-    ObtainWriteLock(&afs_icl_lock, 205);
-    for (tp = afs_icl_allSets; tp; tp = np) {
-       tp->refCount++;         /* hold this guy */
-       ReleaseWriteLock(&afs_icl_lock);
-       code = (*aproc) (tp->name, arock, (struct afs_icl_log *)tp);
-       ObtainWriteLock(&afs_icl_lock, 206);
-       np = tp->nextp;         /* tp may disappear next, but not np */
-       if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED))
-           afs_icl_ZapSet(tp);
-       if (code)
-           break;
-    }
-    ReleaseWriteLock(&afs_icl_lock);
-    return code;
-}
-
-int
-afs_icl_AddLogToSet(struct afs_icl_set *setp, struct afs_icl_log *newlogp)
-{
-    int i;
-    int code = -1;
-
-    ObtainWriteLock(&setp->lock, 207);
-    for (i = 0; i < ICL_LOGSPERSET; i++) {
-       if (!setp->logs[i]) {
-           setp->logs[i] = newlogp;
-           code = i;
-           afs_icl_LogHold(newlogp);
-           if (!(setp->states & ICL_SETF_FREED)) {
-               /* bump up the number of sets using the log */
-               afs_icl_LogUse(newlogp);
-           }
-           break;
-       }
-    }
-    ReleaseWriteLock(&setp->lock);
-    return code;
-}
-
-int
 afs_icl_SetSetStat(struct afs_icl_set *setp, int op)
 {
     int i;
@@ -1431,7 +1284,7 @@ afs_icl_SetSetStat(struct afs_icl_set *setp, int op)
        break;
 
     case ICL_OP_SS_FREE:       /* deassert design for log */
-       /* 
+       /*
         * if we are already in this state, do nothing; otherwise
         * deassert desire for log
         */