unpin-out-of-order-oops-20050125
[openafs.git] / src / afs / afs_call.c
index ad5922d..9266fd7 100644 (file)
@@ -271,7 +271,7 @@ afsd_thread(void *rock)
        complete_and_exit(0, 0);
        break;
     default:
-       printf("Unknown op %d in StartDaemon()\n", parm);
+       printf("Unknown op %ld in StartDaemon()\n", (long)parm);
        break;
     }
     return 0;
@@ -875,7 +875,7 @@ afs_syscall_call(parm, parm2, parm3, parm4, parm5, parm6)
        char *cellname = afs_osi_Alloc(cellLen);
 
 #ifndef UKERNEL
-       afs_osi_MaskSignals();
+       afs_osi_MaskUserLoop();
 #endif
        AFS_COPYIN((afs_int32 *) parm2, cellname, cellLen, code);
        AFS_COPYIN((afs_int32 *) parm3, kmsg, kmsgLen, code);
@@ -1096,6 +1096,7 @@ struct iparam32 {
 };
 
 
+#if defined(AFS_HPUX_64BIT_ENV) || defined(AFS_SUN57_64BIT_ENV) || (defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) && !defined(AFS_AMD64_LINUX20_ENV))
 static void
 iparam32_to_iparam(const struct iparam32 *src, struct iparam *dst)
 {
@@ -1104,6 +1105,7 @@ iparam32_to_iparam(const struct iparam32 *src, struct iparam *dst)
     dst->param3 = src->param3;
     dst->param4 = src->param4;
 }
+#endif
 
 /*
  * If you need to change copyin_iparam(), you may also need to change
@@ -1148,6 +1150,8 @@ copyin_iparam(caddr_t cmarg, struct iparam *dst)
     if (current->thread.flags & THREAD_IA32)
 #elif defined(AFS_PPC64_LINUX20_ENV)
     if (current->thread.flags & PPC_FLAG_32BIT) 
+#elif defined(AFS_S390X_LINUX20_ENV)
+    if (current->thread.flags & S390_FLAG_31BIT) 
 #else
 #error Not done for this linux version
 #endif
@@ -1510,6 +1514,11 @@ afs_shutdown(void)
     extern struct osi_file *afs_cacheInodep;
 
     AFS_STATCNT(afs_shutdown);
+    if (afs_initState == 0) {
+        afs_warn("AFS not initialized - not shutting down\n");
+      return;
+    }
+
     if (afs_shuttingdown)
        return;
     afs_shuttingdown = 1;
@@ -1521,6 +1530,9 @@ afs_shutdown(void)
 
     afs_termState = AFSOP_STOP_RXCALLBACK;
     rx_WakeupServerProcs();
+#ifdef AFS_AIX51_ENV
+    shutdown_rxkernel();
+#endif
     /* shutdown_rxkernel(); */
     while (afs_termState == AFSOP_STOP_RXCALLBACK)
        afs_osi_Sleep(&afs_termState);
@@ -1591,7 +1603,11 @@ afs_shutdown(void)
     shutdown_rx();
     afs_shutdown_BKG();
     shutdown_bufferpackage();
+#endif
+#ifdef AFS_AIX51_ENV
     shutdown_daemons();
+#endif
+#ifdef notdef
     shutdown_cache();
     shutdown_osi();
     shutdown_osinet();
@@ -2601,10 +2617,10 @@ afs_icl_LogFreeUse(register struct afs_icl_log *logp)
     ObtainWriteLock(&logp->lock, 189);
     if (--logp->setCount == 0) {
        /* no more users -- free it (but keep log structure around) */
-       afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
 #ifdef KERNEL_HAVE_PIN
        unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
 #endif
+       afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
        logp->firstUsed = logp->firstFree = 0;
        logp->logElements = 0;
        logp->datap = NULL;
@@ -2627,10 +2643,10 @@ afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize)
        logp->logElements = 0;
 
        /* free and allocate a new one */
-       afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
 #ifdef KERNEL_HAVE_PIN
        unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
 #endif
+       afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
        logp->datap =
            (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize);
 #ifdef KERNEL_HAVE_PIN
@@ -2654,7 +2670,10 @@ afs_icl_ZapLog(register struct afs_icl_log *logp)
            /* found the dude we want to remove */
            *lpp = logp->nextp;
            osi_FreeSmallSpace(logp->name);
-           osi_FreeSmallSpace(logp->datap);
+#ifdef KERNEL_HAVE_PIN
+           unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
+#endif
+           afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
            osi_FreeSmallSpace(logp);
            break;              /* won't find it twice */
        }
@@ -2912,10 +2931,10 @@ afs_icl_ZapSet(register struct afs_icl_set *setp)
            /* found the dude we want to remove */
            *lpp = setp->nextp;
            osi_FreeSmallSpace(setp->name);
-           afs_osi_Free(setp->eventFlags, ICL_DEFAULTEVENTS);
 #ifdef KERNEL_HAVE_PIN
            unpin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
 #endif
+           afs_osi_Free(setp->eventFlags, ICL_DEFAULTEVENTS);
            for (i = 0; i < ICL_LOGSPERSET; i++) {
                if ((tlp = setp->logs[i]))
                    afs_icl_LogReleNL(tlp);
@@ -3004,7 +3023,7 @@ afs_icl_EnumerateSets(int (*aproc)
     for (tp = afs_icl_allSets; tp; tp = np) {
        tp->refCount++;         /* hold this guy */
        ReleaseWriteLock(&afs_icl_lock);
-       code = (*aproc) (tp->name, arock, tp);
+       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))