add bulk newvcache method
authorDerrick Brashear <shadow@dementia.org>
Fri, 12 Feb 2010 21:37:19 +0000 (16:37 -0500)
committerDerrick Brashear <shadow@dementia.org>
Sat, 13 Feb 2010 03:29:09 +0000 (19:29 -0800)
let NewVCache return a vcache which is already configured for bulkfetching
takes the bulkstatus "sequence number" and sets the flags and length

Change-Id: Ife67c3deccda2ceefb4a0f1c98a837a3b6401cd2
Reviewed-on: http://gerrit.openafs.org/1302
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/afs/VNOPS/afs_vnop_lookup.c
src/afs/afs_prototypes.h
src/afs/afs_vcache.c

index a47a034..31a6cc1 100644 (file)
@@ -750,6 +750,9 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
      * and it is safe to set the status information for this file.
      */
     statSeqNo = bulkStatCounter++;
+    /* ensure against wrapping */
+    if (statSeqNo == 0)
+       statSeqNo = bulkStatCounter++;
 
     /* now we have dir data in the cache, so scan the dir page */
     fidIndex = 0;
@@ -799,7 +802,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
                }
            } while (tvcp && retry);
            if (!tvcp) {        /* otherwise, create manually */
-               tvcp = afs_NewVCache(&tfid, hostp);
+               tvcp = afs_NewBulkVCache(&tfid, hostp, statSeqNo);
                if (tvcp)
                {
                        ObtainWriteLock(&tvcp->lock, 505);
@@ -836,12 +839,16 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
             * if the new length will be ignored when afs_ProcessFS is
             * called with new stats. */
 #ifdef AFS_SGI_ENV
-           if (!(tvcp->f.states & (CStatd | CBulkFetching))
+           if (!(tvcp->f.states & CStatd)
+               && (!((tvcp->f.states & CBulkFetching) &&
+                     (tvcp->f.m.Length != statSeqNo)))
                && (tvcp->execsOrWriters <= 0)
                && !afs_DirtyPages(tvcp)
                && !AFS_VN_MAPPED((vnode_t *) tvcp))
 #else
-           if (!(tvcp->f.states & (CStatd | CBulkFetching))
+           if (!(tvcp->f.states & CStatd)
+               && (!((tvcp->f.states & CBulkFetching) &&
+                     (tvcp->f.m.Length != statSeqNo)))
                && (tvcp->execsOrWriters <= 0)
                && !afs_DirtyPages(tvcp))
 #endif
@@ -855,7 +862,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
                 * CBulkFetching state bit and the value in the file size.
                 * It is safe to set the status only if the CBulkFetching
                 * flag is still set and the value in the file size does
-                * not change.
+                * not change. NewBulkVCache sets us up.
                 *
                 * Don't fetch status for dirty files. We need to
                 * preserve the value of the file size. We could
@@ -863,8 +870,6 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
                 */
                memcpy((char *)(fidsp + fidIndex), (char *)&tfid.Fid,
                       sizeof(*fidsp));
-               tvcp->f.states |= CBulkFetching;
-               tvcp->f.m.Length = statSeqNo;
                fidIndex++;
            }
            afs_PutVCache(tvcp);
index 39d5297..40e9ec8 100644 (file)
@@ -1012,6 +1012,8 @@ extern struct vcache *afs_GetRootVCache(struct VenusFid *afid,
                                        struct volume *tvolp);
 extern struct vcache *afs_NewVCache(struct VenusFid *afid,
                                    struct server *serverp);
+extern struct vcache *afs_NewBulkVCache(struct VenusFid *afid,
+                                       struct server *serverp, int seq);
 extern int afs_VerifyVCache2(struct vcache *avc, struct vrequest *areq);
 extern struct vcache *afs_GetVCache(register struct VenusFid *afid,
                                    struct vrequest *areq, afs_int32 * cached,
index 525bf46..ade8bc6 100644 (file)
@@ -799,8 +799,9 @@ afs_AllocVCache(void)
  *
  * \return The new vcache struct.
  */
-struct vcache *
-afs_NewVCache(struct VenusFid *afid, struct server *serverp)
+
+static_inline struct vcache *
+afs_NewVCache_int(struct VenusFid *afid, struct server *serverp, int seq)
 {
     struct vcache *tvc;
     afs_int32 i, j;
@@ -1049,12 +1050,12 @@ afs_NewVCache(struct VenusFid *afid, struct server *serverp)
 #endif
            panic("afs getnewvnode");   /* can't happen */
 #ifdef AFS_FBSD70_ENV
-    /* XXX verified on 80--TODO check on 7x */
-    if (!vp->v_mount) {
-        vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); /* !glocked */
-        insmntque(vp, afs_globalVFS);
-        VOP_UNLOCK(vp, 0);
-    }
+       /* XXX verified on 80--TODO check on 7x */
+       if (!vp->v_mount) {
+           vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); /* !glocked */
+           insmntque(vp, afs_globalVFS);
+           VOP_UNLOCK(vp, 0);
+       }
 #endif
        AFS_GLOCK();
        ObtainWriteLock(&afs_xvcache,339);
@@ -1200,13 +1201,28 @@ afs_NewVCache(struct VenusFid *afid, struct server *serverp)
     memset(&(tvc->callsort), 0, sizeof(struct afs_q));
     tvc->slocks = NULL;
     tvc->f.states &=~ CVInit;
+    if (seq) {
+       tvc->f.states |= CBulkFetching;
+       tvc->f.m.Length = seq;
+    }
     afs_osi_Wakeup(&tvc->f.states);
 
     return tvc;
-
 }                              /*afs_NewVCache */
 
 
+struct vcache *
+afs_NewVCache(struct VenusFid *afid, struct server *serverp)
+{
+    return afs_NewVCache_int(afid, serverp, 0);
+}
+
+struct vcache *
+afs_NewBulkVCache(struct VenusFid *afid, struct server *serverp, int seq)
+{
+    return afs_NewVCache_int(afid, serverp, seq);
+}
+
 /*!
  * ???
  *