]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DEVEL15-enhance-afsdb-debugging-20071123
authorDerrick Brashear <shadow@dementia.org>
Fri, 23 Nov 2007 14:32:56 +0000 (14:32 +0000)
committerDerrick Brashear <shadow@dementia.org>
Fri, 23 Nov 2007 14:32:56 +0000 (14:32 +0000)
allow cmdebug to show locks on cells. add fstrace event for afsdb

(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 7b1f276476e572ea35fd202c6ec8620ffb2eb07d..439fb7c4614fb6260be70c57564bf0cb9b782169 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 33ddfb6722df45aadc09b297a8ee54ea2e2c2a93..62fab7eac74d2c3a5366962afd4d5445f9164343 100644 (file)
@@ -36,7 +36,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 */
 
@@ -68,11 +69,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)
@@ -90,20 +91,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;
@@ -117,7 +118,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;
 }
 
@@ -130,7 +131,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 = afs_strdup(acellName);
@@ -141,16 +142,16 @@ 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);
     };
 
     afs_osi_FreeStr(afsdb_req.cellname);
-    ReleaseReadLock(&afsdb_req.lock);
+    ReleaseReadLock(&afsdb_req_lock);
     ReleaseWriteLock(&afsdb_client_lock);
 
     if (*acellHosts)
@@ -190,7 +191,9 @@ afs_LookupAFSDB(char *acellName)
     if (afs_strcasecmp(acellName, *realName))
        afs_NewCellAlias(acellName, *realName);
 
-  done:
+      done:
+    afs_Trace2(afs_iclSetp, CM_TRACE_AFSDB, ICL_TYPE_STRING, acellName, 
+              ICL_TYPE_INT32, code);
     if(timeout)
        afs_osi_Free(timeout, sizeof(int));
     if (realName && *realName)
@@ -862,7 +865,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 1dd1d4d33acea21cee71e0aad8d8b2625790c9d8..2903616852422447631452d1eb979b25d9c84cf6 100644 (file)
@@ -119,7 +119,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