]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-enhance-afsdb-debugging-20071123
authorDerrick Brashear <shadow@dementia.org>
Fri, 23 Nov 2007 14:34:57 +0000 (14:34 +0000)
committerDerrick Brashear <shadow@dementia.org>
Fri, 23 Nov 2007 14:34:57 +0000 (14:34 +0000)
add support for cmdebug showing cell locks. add fstrace afsdb event

(cherry picked from commit b776352e3b824d7c733ef05a71eac85c025b290b)

src/afs/afs_callback.c
src/afs/afs_cell.c
src/afs/afs_prototypes.h
src/afs/afs_trace.et

index 5e8c1c0a7c8177c78a3b0ae048b6fc97ac0207a4..ee1a222b4fa2fa8b76e3d8b82bf121f03108329e 100644 (file)
@@ -61,7 +61,11 @@ static struct ltable {
     {
       "afs_xsrvAddr", (char *)&afs_xsrvAddr},
     {
-    "afs_xvreclaim", (char *)&afs_xvreclaim}
+      "afs_xvreclaim", (char *)&afs_xvreclaim},
+#ifdef AFS_AFSDB_ENV
+    { "afsdb_client_lock", (char *)&afsdb_client_lock},
+    { "afsdb_req_lock", (char *)&afsdb_req_lock},
+#endif
 };
 unsigned long lastCallBack_vnode;
 unsigned int lastCallBack_dv;
@@ -307,11 +311,35 @@ SRXAFSCB_GetLock(struct rx_call *a_call, afs_int32 a_index,
 
     AFS_STATCNT(SRXAFSCB_GetLock);
     nentries = sizeof(ltable) / sizeof(struct ltable);
-    if (a_index < 0 || a_index >= nentries) {
+    if (a_index < 0 || a_index >= nentries+afs_cellindex) {
        /*
         * Past EOF
         */
        code = 1;
+    } else if (a_index >= nentries) {
+       struct cell *tc = afs_GetCellByIndex(a_index-nentries, 0);
+       strcpy(a_result->name, tc->cellName);
+       a_result->lock.waitStates =
+           ((struct afs_lock *)&(tc->lock))->wait_states;
+       a_result->lock.exclLocked =
+           ((struct afs_lock *)&(tc->lock))->excl_locked;
+       a_result->lock.readersReading =
+           ((struct afs_lock *)&(tc->lock))->readers_reading;
+       a_result->lock.numWaiting =
+           ((struct afs_lock *)&(tc->lock))->num_waiting;
+#ifdef INSTRUMENT_LOCKS
+       a_result->lock.pid_last_reader =
+           MyPidxx2Pid(((struct afs_lock *)&(tc->lock))->pid_last_reader);
+       a_result->lock.pid_writer =
+           MyPidxx2Pid(((struct afs_lock *)&(tc->lock))->pid_writer);
+       a_result->lock.src_indicator =
+           ((struct afs_lock *)&(tc->lock))->src_indicator;
+#else
+       a_result->lock.pid_last_reader = 0;
+       a_result->lock.pid_writer = 0;
+       a_result->lock.src_indicator = 0;
+#endif
+       code = 0;
     } else {
        /*
         * Found it - copy out its contents.
index 972e59b0a0df40d46f9df0fc1a5c599a84b874b6..6a96b444bffd3088f9b3a71f89b4152d0b013726 100644 (file)
@@ -35,7 +35,8 @@ afs_rwlock_t afs_xcell;               /* Export for cmdebug peeking at locks */
  */
 
 #ifdef AFS_AFSDB_ENV
-static afs_rwlock_t afsdb_client_lock; /* Serializes client requests */
+afs_rwlock_t afsdb_client_lock;        /* Serializes client requests */
+afs_rwlock_t afsdb_req_lock;   /* Serializes client requests */
 static char afsdb_handler_running;     /* Protected by GLOCK */
 static char afsdb_handler_shutdown;    /* Protected by GLOCK */
 
@@ -67,11 +68,11 @@ afs_AFSDBHandler(char *acellName, int acellNameLen, afs_int32 * kernelMsg)
        return -2;
     afsdb_handler_running = 1;
 
-    ObtainSharedLock(&afsdb_req.lock, 683);
+    ObtainSharedLock(&afsdb_req_lock, 683);
     if (afsdb_req.pending) {
        int i, hostCount;
 
-       UpgradeSToWLock(&afsdb_req.lock, 684);
+       UpgradeSToWLock(&afsdb_req_lock, 684);
        hostCount = kernelMsg[0];
        *afsdb_req.timeout = kernelMsg[1];
        if (*afsdb_req.timeout)
@@ -89,20 +90,20 @@ afs_AFSDBHandler(char *acellName, int acellNameLen, afs_int32 * kernelMsg)
        afsdb_req.pending = 0;
        afsdb_req.complete = 1;
        afs_osi_Wakeup(&afsdb_req);
-       ConvertWToSLock(&afsdb_req.lock);
+       ConvertWToSLock(&afsdb_req_lock);
     }
-    ConvertSToRLock(&afsdb_req.lock);
+    ConvertSToRLock(&afsdb_req_lock);
 
     /* Wait for a request */
     while (afsdb_req.pending == 0 && afs_termState != AFSOP_STOP_AFSDB) {
-       ReleaseReadLock(&afsdb_req.lock);
+       ReleaseReadLock(&afsdb_req_lock);
        afs_osi_Sleep(&afsdb_req);
-       ObtainReadLock(&afsdb_req.lock);
+       ObtainReadLock(&afsdb_req_lock);
     }
 
     /* Check if we're shutting down */
     if (afs_termState == AFSOP_STOP_AFSDB) {
-       ReleaseReadLock(&afsdb_req.lock);
+       ReleaseReadLock(&afsdb_req_lock);
 
        /* Inform anyone waiting for us that we're going away */
        afsdb_handler_shutdown = 1;
@@ -116,7 +117,7 @@ afs_AFSDBHandler(char *acellName, int acellNameLen, afs_int32 * kernelMsg)
 
     /* Return the lookup request to userspace */
     strncpy(acellName, afsdb_req.cellname, acellNameLen);
-    ReleaseReadLock(&afsdb_req.lock);
+    ReleaseReadLock(&afsdb_req_lock);
     return 0;
 }
 
@@ -129,7 +130,7 @@ afs_GetCellHostsAFSDB(char *acellName, afs_int32 * acellHosts, int *timeout,
        return ENOENT;
 
     ObtainWriteLock(&afsdb_client_lock, 685);
-    ObtainWriteLock(&afsdb_req.lock, 686);
+    ObtainWriteLock(&afsdb_req_lock, 686);
 
     *acellHosts = 0;
     afsdb_req.cellname = acellName;
@@ -140,17 +141,17 @@ afs_GetCellHostsAFSDB(char *acellName, afs_int32 * acellHosts, int *timeout,
     afsdb_req.complete = 0;
     afsdb_req.pending = 1;
     afs_osi_Wakeup(&afsdb_req);
-    ConvertWToRLock(&afsdb_req.lock);
+    ConvertWToRLock(&afsdb_req_lock);
 
     while (afsdb_handler_running && !afsdb_req.complete) {
-       ReleaseReadLock(&afsdb_req.lock);
+       ReleaseReadLock(&afsdb_req_lock);
        afs_osi_Sleep(&afsdb_req);
-       ObtainReadLock(&afsdb_req.lock);
+       ObtainReadLock(&afsdb_req_lock);
     };
-    ReleaseReadLock(&afsdb_req.lock);
+    ReleaseReadLock(&afsdb_req_lock);
     ReleaseWriteLock(&afsdb_client_lock);
 
-    if (*acellHosts)
+    if (*acellHosts) 
        return 0;
     else
        return ENOENT;
@@ -177,6 +178,8 @@ afs_LookupAFSDB(char *acellName)
        afs_NewCellAlias(acellName, realName);
 
   done:
+    afs_Trace2(afs_iclSetp, CM_TRACE_AFSDB, ICL_TYPE_STRING, acellName, 
+              ICL_TYPE_INT32, code);
     if (realName)
        afs_osi_FreeStr(realName);
 #endif
@@ -819,7 +822,7 @@ afs_CellInit()
     RWLOCK_INIT(&afs_xcell, "afs_xcell");
 #ifdef AFS_AFSDB_ENV
     RWLOCK_INIT(&afsdb_client_lock, "afsdb_client_lock");
-    RWLOCK_INIT(&afsdb_req.lock, "afsdb_req.lock");
+    RWLOCK_INIT(&afsdb_req_lock, "afsdb_req_lock");
 #endif
     QInit(&CellLRU);
 
index 8874d94e84094a7a62143b09f9bd2e7125707a93..83ac8ece2a855d27da09117fc003d80bba3d01a6 100644 (file)
@@ -195,7 +195,12 @@ extern void afs_InitCBQueue(int doLockInit);
 extern void afs_DequeueCallback(struct vcache *avc);
 
 /* afs_cell.c */
+extern afs_int32 afs_cellindex;
 extern afs_rwlock_t afs_xcell;
+#ifdef AFS_AFSDB_ENV
+extern afs_rwlock_t afsdb_client_lock;
+extern afs_rwlock_t afsdb_req_lock;
+#endif
 extern struct afs_q CellLRU;           
 
 extern void afs_CellInit(void);
index cf81f078d9ce1ef907959309e864c6683a60987e..1c264057868dcf0e591f2a2a4ed422de893457e2 100644 (file)
@@ -172,5 +172,6 @@ error_table 2 ZCM
        ec      CM_TRACE_LOCKWAIT,"%s line %d: Waiting for lock 0x%lx level %d"
        ec      CM_TRACE_WRITEFAILED, "osi_Write failed len %ld resid %ld err %ld"
        ec      CM_TRACE_ADJUSTSIZE2, "AdjustSize dc = 0x%lx, chunkBytes = 0x%x used = %ld, diff = %ld"
+       ec      CM_TRACE_AFSDB, "AFSDB lookup %s returned %d"
 end