libafs: track dynroot locks for cmdebug
[openafs.git] / src / afs / afs_callback.c
index bdfb408..7e0e2dd 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
@@ -65,6 +65,8 @@ 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;
@@ -234,12 +236,7 @@ SRXAFSCB_GetCE64(struct rx_call *a_call, afs_int32 a_index,
     a_result->lock.pid_writer = 0;
     a_result->lock.src_indicator = 0;
 #endif /* INSTRUMENT_LOCKS */
-#if !defined(AFS_64BIT_ENV) 
-    a_result->Length.high = 0;
-    a_result->Length.low = tvc->f.m.Length;
-#else
     a_result->Length = tvc->f.m.Length;
-#endif
     a_result->DataVersion = hgetlo(tvc->f.m.DataVersion);
     a_result->callback = afs_data_pointer_to_int32(tvc->callback);     /* XXXX Now a pointer; change it XXXX */
     a_result->cbExpires = tvc->cbExpires;
@@ -382,7 +379,7 @@ SRXAFSCB_GetLock(struct rx_call *a_call, afs_int32 a_index,
  *
  * Description:
  *     Clear out callback information for the specified file, or
- *     even a whole volume.  Used to worry about callback was from 
+ *     even a whole volume.  Used to worry about callback was from
  *      within the particular cell or not.  Now we don't bother with
  *      that anymore; it's not worth the time.
  *
@@ -442,7 +439,7 @@ loop1:
                i = VCHashV(&localFid);
                for (tq = afs_vhashTV[i].prev; tq != &afs_vhashTV[i]; tq = uq) {
                    uq = QPrev(tq);
-                   tvc = QTOVH(tq);      
+                   tvc = QTOVH(tq);
                    if (tvc->f.fid.Fid.Volume == a_fid->Volume) {
                        tvc->callback = NULL;
                        if (!localFid.Cell)
@@ -458,11 +455,9 @@ loop1:
 #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))
@@ -473,11 +468,6 @@ loop1:
                            AFS_GLOCK();
                            continue;
                        }
-                       if (tvc->f.states & (CBulkFetching|CDeadVnode)) {
-                           AFS_GUNLOCK();
-                           vnode_recycle(AFSTOV(tvc));
-                           AFS_GLOCK();
-                       }
 #else
                        AFS_FAST_HOLD(tvc);
 #endif
@@ -553,11 +543,9 @@ loop2:
 #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))
@@ -568,11 +556,6 @@ loop2:
                        AFS_GLOCK();
                        continue;
                    }
-                   if (tvc->f.states & (CBulkFetching|CDeadVnode)) {
-                       AFS_GUNLOCK();
-                       vnode_recycle(AFSTOV(tvc));
-                       AFS_GLOCK();
-                   }
 #else
                    AFS_FAST_HOLD(tvc);
 #endif
@@ -771,9 +754,7 @@ SRXAFSCB_InitCallBackState(struct rx_call *a_call)
                }
 
            /* capabilities need be requested again */
-           ObtainWriteLock(&afs_xserver, 877);
            ts->flags &= ~SCAPS_KNOWN;
-           ReleaseWriteLock(&afs_xserver);
        }
 
 
@@ -914,6 +895,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;
@@ -934,6 +916,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;
@@ -958,6 +941,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;
@@ -1065,7 +1049,7 @@ shutdown_CB(void)
  *      a_call : Ptr to Rx call on which this request came in.
  *
  * Returns:
- *      RXGEN_OPCODE (always). 
+ *      RXGEN_OPCODE (always).
  *
  * Environment:
  *      Nothing interesting.
@@ -1311,8 +1295,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] =
@@ -1320,9 +1304,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;
     }
@@ -1378,7 +1363,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);
@@ -1475,7 +1460,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;
@@ -1616,8 +1601,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);
@@ -1658,7 +1643,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;
@@ -1706,7 +1692,7 @@ resume:
         * All done at this level ... ascend and resume the search.
         */
        if (this_parent != parent) {
-               next = this_parent->d_child.next; 
+               next = this_parent->d_child.next;
                this_parent = this_parent->d_parent;
                goto resume;
        }
@@ -1715,7 +1701,7 @@ resume:
  searchdone3:
     if (d_unhashed(dentry))
       *flags = 1;
-    else 
+    else
       *flags = 0;
 
     *fileName = afs_strdup(dentry->d_name.name?dentry->d_name.name:"");
@@ -1752,9 +1738,9 @@ SRXAFSCB_GetDE(struct rx_call *a_call, afs_int32 a_index, afs_int32 *addr,
     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
@@ -1768,7 +1754,7 @@ SRXAFSCB_GetDE(struct rx_call *a_call, afs_int32 a_index, afs_int32 *addr,
        goto fcnDone;
       }
       dput(dentry);
-    }                   
+    }
  searchdone2:
     if (cur == head) {
        /*Past EOF*/
@@ -1779,7 +1765,7 @@ SRXAFSCB_GetDE(struct rx_call *a_call, afs_int32 a_index, afs_int32 *addr,
 
     if (d_unhashed(dentry))
       *flags = 1;
-    else 
+    else
       *flags = 0;
 
     *fileName = afs_strdup(dentry->d_name.name?dentry->d_name.name:"");