sparc64-linux26-20050508
[openafs.git] / src / afs / afs_call.c
index c801c04..db2f9e1 100644 (file)
@@ -31,7 +31,7 @@ RCSID
 #endif
 
 
-#if    defined(AFS_AIX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
+#if defined(AFS_SUN5_ENV) || defined(AFS_AIX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV)
 #define        AFS_MINBUFFERS  100
 #else
 #define        AFS_MINBUFFERS  50
@@ -100,6 +100,8 @@ afs_int32 afs_rx_harddead = AFS_HARDDEADTIME;
 static int
   Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval);
 
+static int afscall_set_rxpck_received = 0;
+
 #if defined(AFS_HPUX_ENV)
 extern int afs_vfs_mount();
 #endif /* defined(AFS_HPUX_ENV) */
@@ -128,6 +130,7 @@ afs_InitSetup(int preallocs)
     memset(afs_zeros, 0, AFS_ZEROS);
 
     /* start RX */
+    if(!afscall_set_rxpck_received)
     rx_extraPackets = AFS_NRXPACKETS;  /* smaller # of packets */
     code = rx_InitHost(rx_bindhost, htons(7001));
     if (code) {
@@ -271,7 +274,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;
@@ -502,7 +505,7 @@ afs_syscall_call(parm, parm2, parm3, parm4, parm5, parm6)
        while (!afs_InitSetup_done)
            afs_osi_Sleep(&afs_InitSetup_done);
 
-#if defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if defined(AFS_SGI_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) || defined(AFS_SUN5_ENV)
        temp = AFS_MINBUFFERS;  /* Should fix this soon */
 #else
        /* number of 2k buffers we could get from all of the buffer space */
@@ -514,6 +517,18 @@ afs_syscall_call(parm, parm2, parm3, parm4, parm5, parm6)
        DInit(temp);
        afs_rootFid.Fid.Volume = 0;
        code = 0;
+    } else if (parm == AFSOP_BUCKETPCT) {
+       /* need to enable this now, will disable again before GO
+          if we don't have 100% */
+       splitdcache = 1;
+       switch (parm2) {
+       case 1:
+           afs_tpct1 = parm3;
+           break;
+       case 2:
+           afs_tpct2 = parm3;
+           break;
+       }           
     } else if (parm == AFSOP_ADDCELL) {
        /* add a cell.  Parameter 2 is 8 hosts (in net order),  parm 3 is the null-terminated
         * name.  Parameter 4 is the length of the name, including the null.  Parm 5 is the
@@ -690,8 +705,15 @@ afs_syscall_call(parm, parm2, parm3, parm4, parm5, parm6)
            afs_osi_Sleep(&afs_initState);
        afs_initState = 101;
        afs_setTime = parm2;
+       if (afs_tpct1 + afs_tpct2 != 100) {
+           afs_tpct1 = 0;
+           afs_tpct2 = 0;
+           splitdcache = 0;
+       } else {        
+           splitdcache = 1;
+       }
        afs_osi_Wakeup(&afs_initState);
-#if    (!defined(AFS_NONFSTRANS) && !defined(AFS_DEC_ENV)) || defined(AFS_AIX_IAUTH_ENV)
+#if    (!defined(AFS_NONFSTRANS)) || defined(AFS_AIX_IAUTH_ENV)
        afs_nfsclient_init();
 #endif
        printf("found %d non-empty cache files (%d%%).\n",
@@ -901,6 +923,9 @@ afs_syscall_call(parm, parm2, parm3, parm4, parm5, parm6)
        code = 0;
     } else if (parm == AFSOP_SET_BACKUPTREE) {
        afs_bkvolpref = parm2;
+    } else if (parm == AFSOP_SET_RXPCK) {
+       rx_extraPackets = parm2;
+       afscall_set_rxpck_received = 1;
     } else
        code = EINVAL;
 
@@ -1096,6 +1121,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))
 static void
 iparam32_to_iparam(const struct iparam32 *src, struct iparam *dst)
 {
@@ -1104,6 +1130,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
@@ -1137,21 +1164,33 @@ copyin_iparam(caddr_t cmarg, struct iparam *dst)
     }
 #endif /* AFS_SUN57_64BIT_ENV */
 
-#if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) && !defined(AFS_AMD64_LINUX20_ENV)
+#if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)
     struct iparam32 dst32;
 
-#ifdef AFS_SPARC64_LINUX24_ENV
+#ifdef AFS_SPARC64_LINUX26_ENV
+    if (test_thread_flag(TIF_32BIT))
+#elif AFS_SPARC64_LINUX24_ENV
     if (current->thread.flags & SPARC_FLAG_32BIT)
 #elif defined(AFS_SPARC64_LINUX20_ENV)
     if (current->tss.flags & SPARC_FLAG_32BIT)
+
+#elif defined(AFS_AMD64_LINUX26_ENV)
+    if (test_thread_flag(TIF_IA32))
 #elif defined(AFS_AMD64_LINUX20_ENV)
     if (current->thread.flags & THREAD_IA32)
+
+#elif defined(AFS_PPC64_LINUX26_ENV)
+    if (current->thread_info->flags & _TIF_32BIT) 
 #elif defined(AFS_PPC64_LINUX20_ENV)
     if (current->thread.flags & PPC_FLAG_32BIT) 
+
+#elif defined(AFS_S390X_LINUX26_ENV)
+    if (test_thread_flag(TIF_31BIT))
 #elif defined(AFS_S390X_LINUX20_ENV)
     if (current->thread.flags & S390_FLAG_31BIT) 
+
 #else
-#error Not done for this linux version
+#error iparam32 not done for this linux platform
 #endif
     {
        AFS_COPYIN(cmarg, (caddr_t) & dst32, sizeof dst32, code);
@@ -1258,11 +1297,7 @@ Afs_syscall()
     } *uap = (struct a *)u.u_ap;
 #else /* UKERNEL */
 int
-#if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
-afs_syscall()
-#else
 Afs_syscall()
-#endif                         /* SUN && !SUN5 */
 {
     register struct a {
        long syscall;
@@ -1274,9 +1309,7 @@ Afs_syscall()
        long parm6;
     } *uap = (struct a *)u.u_ap;
 #endif /* UKERNEL */
-#if  defined(AFS_DEC_ENV)
-    int *retval = &u.u_r.r_val1;
-#elif defined(AFS_HPUX_ENV)
+#if defined(AFS_HPUX_ENV)
     long *retval = &u.u_rval1;
 #else
     int *retval = &u.u_rval1;
@@ -1314,7 +1347,12 @@ Afs_syscall()
 })
 
 
-       if (current->thread.flags & SPARC_FLAG_32BIT) {
+#ifdef AFS_SPARC64_LINUX26_ENV
+       if (test_thread_flag(TIF_32BIT))
+#else
+       if (current->thread.flags & SPARC_FLAG_32BIT)
+#endif
+       {
            AFS_COPYIN((char *)parm4, (char *)eparm32, sizeof(eparm32), code);
            eparm[0] = AA(eparm32[0]);
            eparm[1] = AA(eparm32[1]);
@@ -1614,11 +1652,8 @@ afs_shutdown(void)
     shutdown_vfsops();
     shutdown_exporter();
     shutdown_memcache();
-#if !defined(AFS_NONFSTRANS) || defined(AFS_AIX_IAUTH_ENV)
-#if !defined(AFS_DEC_ENV) && !defined(AFS_OSF_ENV)
-    /* this routine does not exist in Ultrix systems... 93.01.19 */
+#if (!defined(AFS_NONFSTRANS) || defined(AFS_AIX_IAUTH_ENV)) && !defined(AFS_OSF_ENV)
     shutdown_nfsclnt();
-#endif /* AFS_DEC_ENV */
 #endif
     shutdown_afstest();
     /* The following hold the cm stats */
@@ -1653,7 +1688,7 @@ afs_shutdown_BKG(void)
 }
 
 
-#if defined(AFS_ALPHA_ENV) || defined(AFS_SGI61_ENV)
+#if defined(AFS_OSF_ENV) || defined(AFS_SGI61_ENV)
 /* For SGI 6.2, this can is changed to 1 if it's a 32 bit kernel. */
 #if defined(AFS_SGI62_ENV) && defined(KERNEL) && !defined(_K64U64)
 int afs_icl_sizeofLong = 1;
@@ -2088,16 +2123,16 @@ afs_icl_AppendString(struct afs_icl_log *logp, char *astr)
         (lp)->logElements++; \
     MACRO_END
 
-#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
+#if defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 #define ICL_APPENDLONG(lp, x) \
     MACRO_BEGIN \
        ICL_APPENDINT32((lp), ((x) >> 32) & 0xffffffffL); \
        ICL_APPENDINT32((lp), (x) & 0xffffffffL); \
     MACRO_END
 
-#else /* AFS_ALPHA_ENV */
+#else /* AFS_OSF_ENV */
 #define ICL_APPENDLONG(lp, x) ICL_APPENDINT32((lp), (x))
-#endif /* AFS_ALPHA_ENV */
+#endif /* AFS_OSF_ENV */
 
 /* routine to tell whether we're dealing with the address or the
  * object itself
@@ -2242,10 +2277,10 @@ afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op,
            ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[2]);
            ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[3]);
        }
-#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
+#if defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
        else if (t1 == ICL_TYPE_INT32)
            ICL_APPENDINT32(logp, (afs_int32) p1);
-#endif /* AFS_ALPHA_ENV */
+#endif /* AFS_OSF_ENV */
        else
            ICL_APPENDLONG(logp, p1);
     }
@@ -2282,10 +2317,10 @@ afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op,
            ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[2]);
            ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[3]);
        }
-#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
+#if defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
        else if (t2 == ICL_TYPE_INT32)
            ICL_APPENDINT32(logp, (afs_int32) p2);
-#endif /* AFS_ALPHA_ENV */
+#endif /* AFS_OSF_ENV */
        else
            ICL_APPENDLONG(logp, p2);
     }
@@ -2322,10 +2357,10 @@ afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op,
            ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[2]);
            ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[3]);
        }
-#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
+#if defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
        else if (t3 == ICL_TYPE_INT32)
            ICL_APPENDINT32(logp, (afs_int32) p3);
-#endif /* AFS_ALPHA_ENV */
+#endif /* AFS_OSF_ENV */
        else
            ICL_APPENDLONG(logp, p3);
     }
@@ -2362,10 +2397,10 @@ afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op,
            ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[2]);
            ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[3]);
        }
-#if defined(AFS_ALPHA_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
+#if defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
        else if (t4 == ICL_TYPE_INT32)
            ICL_APPENDINT32(logp, (afs_int32) p4);
-#endif /* AFS_ALPHA_ENV */
+#endif /* AFS_OSF_ENV */
        else
            ICL_APPENDLONG(logp, p4);
     }
@@ -2615,10 +2650,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;
@@ -2641,10 +2676,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
@@ -2668,7 +2703,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 */
        }
@@ -2926,10 +2964,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);
@@ -3018,7 +3056,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))