fs-getcache-show-more-20060615
[openafs.git] / src / afs / afs_pioctl.c
index 61d663f..2c4599b 100644 (file)
@@ -1945,12 +1945,12 @@ DECL_PIOCTL(PCheckServers)
        pcheck = (struct chservinfo *)ain;
        if (pcheck->tinterval >= 0) {
            cp = aout;
-           memcpy(cp, (char *)&PROBE_INTERVAL, sizeof(afs_int32));
+           memcpy(cp, (char *)&afs_probe_interval, sizeof(afs_int32));
            *aoutSize = sizeof(afs_int32);
            if (pcheck->tinterval > 0) {
                if (!afs_osi_suser(*acred))
                    return EACCES;
-               PROBE_INTERVAL = pcheck->tinterval;
+               afs_probe_interval = pcheck->tinterval;
            }
            return 0;
        }
@@ -2175,11 +2175,51 @@ DECL_PIOCTL(PSetCacheSize)
 DECL_PIOCTL(PGetCacheSize)
 {
     afs_int32 results[MAXGCSTATS];
-
+    afs_int32 flags;
+    register struct dcache * tdc;
+    int i, size;
+    
     AFS_STATCNT(PGetCacheSize);
+
+    if (sizeof(afs_int32) == ainSize){
+       memcpy((char *)&flags, ain, sizeof(afs_int32));
+    } else if (0 == ainSize){ 
+       flags = 0;
+    } else {
+       return EINVAL;
+    }
+    
     memset((char *)results, 0, sizeof(results));
     results[0] = afs_cacheBlocks;
     results[1] = afs_blocksUsed;
+    results[2] = afs_cacheFiles;
+    
+    if (1 == flags){
+        for (i = 0; i < afs_cacheFiles; i++) {
+           if (afs_indexFlags[i] & IFFree) results[3]++;
+       }
+    } else if (2 == flags){
+        for (i = 0; i < afs_cacheFiles; i++) {
+           if (afs_indexFlags[i] & IFFree) results[3]++;
+           if (afs_indexFlags[i] & IFEverUsed) results[4]++;
+           if (afs_indexFlags[i] & IFDataMod) results[5]++;
+           if (afs_indexFlags[i] & IFDirtyPages) results[6]++;
+           if (afs_indexFlags[i] & IFAnyPages) results[7]++;
+           if (afs_indexFlags[i] & IFDiscarded) results[8]++;
+
+           tdc = afs_indexTable[i];
+           if (tdc){
+               results[9]++;
+               size = tdc->validPos;
+               if ( 0 < size && size < (1<<12) ) results[10]++;
+               else if (size < (1<<14) ) results[11]++;
+               else if (size < (1<<16) ) results[12]++;
+               else if (size < (1<<18) ) results[13]++;
+               else if (size < (1<<20) ) results[14]++;
+               else if (size >= (1<<20) ) results[15]++;
+           }
+        }
+    }
     memcpy(aout, (char *)results, sizeof(results));
     *aoutSize = sizeof(results);
     return 0;
@@ -2549,6 +2589,9 @@ DECL_PIOCTL(PFlushVolumeData)
     register struct volume *tv;
     afs_int32 cell, volume;
     struct afs_q *tq, *uq;
+#ifdef AFS_DARWIN80_ENV
+    vnode_t vp;
+#endif
 
     AFS_STATCNT(PFlushVolumeData);
     if (!avc)
@@ -2567,6 +2610,7 @@ DECL_PIOCTL(PFlushVolumeData)
     ObtainReadLock(&afs_xvcache);
     i = VCHashV(&avc->fid);
     for (tq = afs_vhashTV[i].prev; tq != &afs_vhashTV[i]; tq = uq) {
+           uq = QPrev(tq);
            tvc = QTOVH(tq);
            if (tvc->fid.Fid.Volume == volume && tvc->fid.Cell == cell) {
                if (tvc->states & CVInit) {
@@ -2584,16 +2628,24 @@ DECL_PIOCTL(PFlushVolumeData)
 #if    defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV)  || defined(AFS_SUN5_ENV)  || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
                VN_HOLD(AFSTOV(tvc));
 #else
-#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 #ifdef AFS_DARWIN80_ENV
-                if (vnode_get(AFSTOV(tvc)))
-                    continue;
-#endif
+               vp = AFSTOV(tvc);
+               if (vnode_get(vp))
+                   continue;
+               if (vnode_ref(vp)) {
+                   AFS_GUNLOCK();
+                   vnode_put(vp);
+                   AFS_GLOCK();
+                   continue;
+               }
+#else
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
                osi_vnhold(tvc, 0);
 #else
                VREFCOUNT_INC(tvc); /* AIX, apparently */
 #endif
 #endif
+#endif
                ReleaseReadLock(&afs_xvcache);
 #ifdef AFS_BOZONLOCK_ENV
                afs_BozonLock(&tvc->pvnLock, tvc);      /* Since afs_TryToSmush will do a pvn_vptrunc */
@@ -2618,8 +2670,6 @@ DECL_PIOCTL(PFlushVolumeData)
                uq = QPrev(tq);
                /* our tvc ptr is still good until now */
                AFS_FAST_RELE(tvc);
-           } else {
-               uq = QPrev(tq);
            }
        }
     ReleaseReadLock(&afs_xvcache);