afs: Remove osi_GetuTime
[openafs.git] / src / afs / afs_callback.c
index 0fee94a..73e9cfd 100644 (file)
@@ -52,10 +52,6 @@ static struct ltable {
     "afs_xcbhash", (char *)&afs_xcbhash}, {
     "afs_xaxs", (char *)&afs_xaxs}, {
     "afs_xinterface", (char *)&afs_xinterface},
-#ifndef UKERNEL
-    {
-    "afs_xosi", (char *)&afs_xosi},
-#endif
     {
       "afs_xsrvAddr", (char *)&afs_xsrvAddr},
     {
@@ -65,10 +61,12 @@ static struct ltable {
     { "afs_discon_lock", (char *)&afs_discon_lock},
     { "afs_disconDirtyLock", (char *)&afs_disconDirtyLock},
     { "afs_discon_vc_dirty", (char *)&afs_xvcdirty},
+    { "afs_dynrootDirLock", (char *)&afs_dynrootDirLock},
+    { "afs_dynSymlinkLock", (char *)&afs_dynSymlinkLock},
 };
 unsigned long lastCallBack_vnode;
 unsigned int lastCallBack_dv;
-osi_timeval_t lastCallBack_time;
+osi_timeval32_t lastCallBack_time;
 
 /* these are for storing alternate interface addresses */
 struct interfaceAddr afs_cb_interface;
@@ -304,6 +302,7 @@ SRXAFSCB_GetLock(struct rx_call *a_call, afs_int32 a_index,
     XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_GETLOCK);
 
     AFS_STATCNT(SRXAFSCB_GetLock);
+    memset(a_result, 0, sizeof(*a_result));
     nentries = sizeof(ltable) / sizeof(struct ltable);
     if (a_index < 0 || a_index >= nentries+afs_cellindex) {
        /*
@@ -448,16 +447,11 @@ loop1:
                            afs_osi_Sleep(&tvc->f.states);
                            goto loop1;
                        }
-#if     defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV)  || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
-                       AFS_FAST_HOLD(tvc);
-#else
 #ifdef AFS_DARWIN80_ENV
                        if (tvc->f.states & CDeadVnode) {
-                           if (!(tvc->f.states & CBulkFetching)) {
-                               ReleaseReadLock(&afs_xvcache);
-                               afs_osi_Sleep(&tvc->f.states);
-                               goto loop1;
-                           }
+                           ReleaseReadLock(&afs_xvcache);
+                           afs_osi_Sleep(&tvc->f.states);
+                           goto loop1;
                        }
                        vp = AFSTOV(tvc);
                        if (vnode_get(vp))
@@ -468,27 +462,18 @@ loop1:
                            AFS_GLOCK();
                            continue;
                        }
-                       if (tvc->f.states & (CBulkFetching|CDeadVnode)) {
-                           AFS_GUNLOCK();
-                           vnode_recycle(AFSTOV(tvc));
-                           AFS_GLOCK();
-                       }
 #else
-                       AFS_FAST_HOLD(tvc);
-#endif
+                       if (osi_vnhold(tvc) != 0) {
+                           continue;
+                       }
 #endif
                        ReleaseReadLock(&afs_xvcache);
-                       ObtainWriteLock(&afs_xcbhash, 449);
-                       afs_DequeueCallback(tvc);
-                       tvc->f.states &= ~(CStatd | CUnique | CBulkFetching);
+                       afs_StaleVCacheFlags(tvc, 0, CUnique | CBulkFetching);
                        afs_allCBs++;
                        if (tvc->f.fid.Fid.Vnode & 1)
                            afs_oddCBs++;
                        else
                            afs_evenCBs++;
-                       ReleaseWriteLock(&afs_xcbhash);
-                       if ((tvc->f.fid.Fid.Vnode & 1 || (vType(tvc) == VDIR)))
-                           osi_dnlc_purgedp(tvc);
                        afs_Trace3(afs_iclSetp, CM_TRACE_CALLBACK,
                                   ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32,
                                   tvc->f.states, ICL_TYPE_INT32,
@@ -500,10 +485,10 @@ loop1:
                        uq = QPrev(tq);
                        AFS_FAST_RELE(tvc);
                    } else if ((tvc->f.states & CMValid)
-                              && (tvc->mvid->Fid.Volume == a_fid->Volume)) {
+                              && (tvc->mvid.target_root->Fid.Volume == a_fid->Volume)) {
                        tvc->f.states &= ~CMValid;
                        if (!localFid.Cell)
-                           localFid.Cell = tvc->mvid->Cell;
+                           localFid.Cell = tvc->mvid.target_root->Cell;
                    }
                }
                ReleaseReadLock(&afs_xvcache);
@@ -543,16 +528,11 @@ loop2:
                        afs_osi_Sleep(&tvc->f.states);
                        goto loop2;
                    }
-#if     defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV)  || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
-                   AFS_FAST_HOLD(tvc);
-#else
 #ifdef AFS_DARWIN80_ENV
                    if (tvc->f.states & CDeadVnode) {
-                       if (!(tvc->f.states & CBulkFetching)) {
-                           ReleaseReadLock(&afs_xvcache);
-                           afs_osi_Sleep(&tvc->f.states);
-                           goto loop2;
-                       }
+                       ReleaseReadLock(&afs_xvcache);
+                       afs_osi_Sleep(&tvc->f.states);
+                       goto loop2;
                    }
                    vp = AFSTOV(tvc);
                    if (vnode_get(vp))
@@ -563,29 +543,20 @@ loop2:
                        AFS_GLOCK();
                        continue;
                    }
-                   if (tvc->f.states & (CBulkFetching|CDeadVnode)) {
-                       AFS_GUNLOCK();
-                       vnode_recycle(AFSTOV(tvc));
-                       AFS_GLOCK();
-                   }
 #else
-                   AFS_FAST_HOLD(tvc);
-#endif
+                   if (osi_vnhold(tvc) != 0) {
+                       continue;
+                   }
 #endif
                    ReleaseReadLock(&afs_xvcache);
-                   ObtainWriteLock(&afs_xcbhash, 450);
-                   afs_DequeueCallback(tvc);
-                   tvc->f.states &= ~(CStatd | CUnique | CBulkFetching);
-                   ReleaseWriteLock(&afs_xcbhash);
-                   if ((tvc->f.fid.Fid.Vnode & 1 || (vType(tvc) == VDIR)))
-                       osi_dnlc_purgedp(tvc);
+                   afs_StaleVCacheFlags(tvc, 0, CUnique | CBulkFetching);
                    afs_Trace3(afs_iclSetp, CM_TRACE_CALLBACK,
                               ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32,
                               tvc->f.states, ICL_TYPE_LONG, 0);
 #ifdef CBDEBUG
                    lastCallBack_vnode = afid->Vnode;
                    lastCallBack_dv = tvc->mstat.DataVersion.low;
-                   osi_GetuTime(&lastCallBack_time);
+                   osi_GetTime(&lastCallBack_time);
 #endif /* CBDEBUG */
 #ifdef AFS_DARWIN80_ENV
                    vnode_put(AFSTOV(tvc));
@@ -757,18 +728,14 @@ SRXAFSCB_InitCallBackState(struct rx_call *a_call)
            for (i = 0; i < VCSIZE; i++)
                for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
                    if (tvc->callback == ts) {
-                       ObtainWriteLock(&afs_xcbhash, 451);
-                       afs_DequeueCallback(tvc);
-                       tvc->callback = NULL;
-                       tvc->f.states &= ~(CStatd | CUnique | CBulkFetching);
-                       ReleaseWriteLock(&afs_xcbhash);
+                       afs_StaleVCacheFlags(tvc, AFS_STALEVC_NODNLC |
+                                                 AFS_STALEVC_CLEARCB,
+                                            CUnique | CBulkFetching);
                    }
                }
 
            /* capabilities need be requested again */
-           ObtainWriteLock(&afs_xserver, 877);
            ts->flags &= ~SCAPS_KNOWN;
-           ReleaseWriteLock(&afs_xserver);
        }
 
 
@@ -909,6 +876,7 @@ SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
         */
        dataBytes = sizeof(struct afs_CMStats);
        dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes);
+       osi_Assert(dataBuffP != NULL);
        memcpy((char *)dataBuffP, (char *)&afs_cmstats, dataBytes);
        a_dataP->AFSCB_CollData_len = dataBytes >> 2;
        a_dataP->AFSCB_CollData_val = dataBuffP;
@@ -929,6 +897,7 @@ SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
        afs_CountServers();
        dataBytes = sizeof(afs_stats_cmperf);
        dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes);
+       osi_Assert(dataBuffP != NULL);
        memcpy((char *)dataBuffP, (char *)&afs_stats_cmperf, dataBytes);
        a_dataP->AFSCB_CollData_len = dataBytes >> 2;
        a_dataP->AFSCB_CollData_val = dataBuffP;
@@ -953,6 +922,7 @@ SRXAFSCB_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
 
        dataBytes = sizeof(afs_stats_cmfullperf);
        dataBuffP = (afs_int32 *) afs_osi_Alloc(dataBytes);
+       osi_Assert(dataBuffP != NULL);
        memcpy((char *)dataBuffP, (char *)(&afs_stats_cmfullperf), dataBytes);
        a_dataP->AFSCB_CollData_len = dataBytes >> 2;
        a_dataP->AFSCB_CollData_val = dataBuffP;
@@ -1306,8 +1276,8 @@ SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index,
        p_name = tcell->cellName;
        for (j = 0; j < AFSMAXCELLHOSTS && tcell->cellHosts[j]; j++);
        i = strlen(p_name);
-       a_hosts->serverList_val =
-           (afs_int32 *) afs_osi_Alloc(j * sizeof(afs_int32));
+       a_hosts->serverList_val = afs_osi_Alloc(j * sizeof(afs_int32));
+       osi_Assert(a_hosts->serverList_val != NULL);
        a_hosts->serverList_len = j;
        for (j = 0; j < AFSMAXCELLHOSTS && tcell->cellHosts[j]; j++)
            a_hosts->serverList_val[j] =
@@ -1315,9 +1285,10 @@ SRXAFSCB_GetCellServDB(struct rx_call *a_call, afs_int32 a_index,
        afs_PutCell(tcell, READ_LOCK);
     }
 
-    t_name = (char *)afs_osi_Alloc(i + 1);
+    t_name = afs_osi_Alloc(i + 1);
     if (t_name == NULL) {
-       afs_osi_Free(a_hosts->serverList_val, (j * sizeof(afs_int32)));
+       if (tcell != NULL)
+           afs_osi_Free(a_hosts->serverList_val, (j * sizeof(afs_int32)));
        RX_AFS_GUNLOCK();
        return ENOMEM;
     }
@@ -1373,7 +1344,7 @@ SRXAFSCB_GetLocalCell(struct rx_call *a_call, char **a_name)
        plen = strlen(p_name);
     else
        plen = 0;
-    t_name = (char *)afs_osi_Alloc(plen + 1);
+    t_name = afs_osi_Alloc(plen + 1);
     if (t_name == NULL) {
        if (tcell)
            afs_PutCell(tcell, READ_LOCK);
@@ -1470,7 +1441,7 @@ SRXAFSCB_GetCacheConfig(struct rx_call *a_call, afs_uint32 callerVersion,
      * Currently only support version 1
      */
     allocsize = sizeof(cm_initparams_v1);
-    t_config = (afs_uint32 *) afs_osi_Alloc(allocsize);
+    t_config = afs_osi_Alloc(allocsize);
     if (t_config == NULL) {
        RX_AFS_GUNLOCK();
        return ENOMEM;
@@ -1611,8 +1582,8 @@ SRXAFSCB_GetCellByNum(struct rx_call *a_call, afs_int32 a_cellnum,
 
     for (sn = 0; sn < AFSMAXCELLHOSTS && tcell->cellHosts[sn]; sn++);
     a_hosts->serverList_len = sn;
-    a_hosts->serverList_val =
-       (afs_int32 *) afs_osi_Alloc(sn * sizeof(afs_int32));
+    a_hosts->serverList_val = afs_osi_Alloc(sn * sizeof(afs_int32));
+    osi_Assert(a_hosts->serverList_val != NULL);
 
     for (i = 0; i < sn; i++)
        a_hosts->serverList_val[i] = ntohl(tcell->cellHosts[i]->addr->sa_ip);
@@ -1640,6 +1611,7 @@ SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call,
     ObtainReadLock(&afs_xinterface);
 
     /* return all network interface addresses */
+    memset(addr, 0, sizeof(*addr));
     addr->numberOfInterfaces = afs_cb_interface.numberOfInterfaces;
     addr->uuid = afs_cb_interface.uuid;
     for (i = 0; i < afs_cb_interface.numberOfInterfaces; i++) {
@@ -1653,7 +1625,8 @@ SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call,
     RX_AFS_GUNLOCK();
 
     dataBytes = 1 * sizeof(afs_uint32);
-    dataBuffP = (afs_uint32 *) afs_osi_Alloc(dataBytes);
+    dataBuffP = afs_osi_Alloc(dataBytes);
+    osi_Assert(dataBuffP != NULL);
     dataBuffP[0] = CLIENT_CAPABILITY_ERRORTRANS;
     capabilities->Capabilities_len = dataBytes / sizeof(afs_uint32);
     capabilities->Capabilities_val = dataBuffP;
@@ -1662,135 +1635,12 @@ SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call,
 }
 
 
-#if 0 && defined(AFS_LINUX24_ENV)
-extern struct vcache *afs_globalVp;
-
-int recurse_dcache_parent(parent, a_index, addr, inode, flags, time, fileName)
-     struct dentry * parent;
-    afs_int32 a_index;
-    afs_int32 *addr;
-    afs_int32 *inode;
-    afs_int32 *flags;
-    afs_int32 *time;
-    char ** fileName;
-{
-       struct dentry *this_parent = parent;
-       struct list_head *next;
-       int found = 0;
-       struct dentry *dentry;
-
-repeat:
-       next = this_parent->d_subdirs.next;
-resume:
-       while (next != &this_parent->d_subdirs) {
-               struct list_head *tmp = next;
-               dentry = list_entry(tmp, struct dentry, d_child);
-               if (a_index == 0)
-                 goto searchdone3;
-               a_index--;
-               next = tmp->next;
-               /*
-                * Descend a level if the d_subdirs list is non-empty.
-                */
-               if (!list_empty(&dentry->d_subdirs)) {
-                       this_parent = dentry;
-                       goto repeat;
-               }
-       }
-       /*
-        * All done at this level ... ascend and resume the search.
-        */
-       if (this_parent != parent) {
-               next = this_parent->d_child.next;
-               this_parent = this_parent->d_parent;
-               goto resume;
-       }
-       goto ret;
-
- searchdone3:
-    if (d_unhashed(dentry))
-      *flags = 1;
-    else
-      *flags = 0;
-
-    *fileName = afs_strdup(dentry->d_name.name?dentry->d_name.name:"");
-    *inode = ITOAFS(dentry->d_inode);
-    *addr = atomic_read(&(dentry)->d_count);
-    *time = dentry->d_time;
-
-    return 0;
- ret:
-    return 1;
-}
-#endif
-
 int
 SRXAFSCB_GetDE(struct rx_call *a_call, afs_int32 a_index, afs_int32 *addr,
               afs_int32 *inode, afs_int32 *flags, afs_int32 *time,
               char ** fileName)
 { /*SRXAFSCB_GetDE*/
     int code = 0;                              /*Return code*/
-#if 0 && defined(AFS_LINUX24_ENV)
-    int i;                     /*Loop variable*/
-    struct vcache *tvc = afs_globalVp;
-    struct dentry *dentry;
-    struct list_head *cur, *head = &(AFSTOI(tvc))->i_dentry;
-
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
-
-#if defined(AFS_LINUX24_ENV)
-    spin_lock(&dcache_lock);
-#endif
-
-    cur = head;
-    while ((cur = cur->next) != head) {
-      dentry = list_entry(cur, struct dentry, d_alias);
-
-      dget_locked(dentry);
-
-#if defined(AFS_LINUX24_ENV)
-      spin_unlock(&dcache_lock);
-#endif
-      if (a_index == 0)
-       goto searchdone2;
-      a_index--;
-
-      if (recurse_dcache_parent(dentry, a_index, addr, inode, flags, time, fileName) == 0) {
-       dput(dentry);
-       code = 0;
-       goto fcnDone;
-      }
-      dput(dentry);
-    }
- searchdone2:
-    if (cur == head) {
-       /*Past EOF*/
-       code = 1;
-       *fileName = afs_strdup("");
-       goto fcnDone;
-    }
-
-    if (d_unhashed(dentry))
-      *flags = 1;
-    else
-      *flags = 0;
-
-    *fileName = afs_strdup(dentry->d_name.name?dentry->d_name.name:"");
-    *inode = ITOAFS(dentry->d_inode);
-    *addr = atomic_read(&(dentry)->d_count);
-    *time = dentry->d_time;
-
-    dput(dentry);
-    code = 0;
-
-fcnDone:
-
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
-#endif
     return(code);
 
 } /*SRXAFSCB_GetDE*/