client-dir-package-interface-update-20041106
authorChaskiel M Grundman <cg2v@andrew.cmu.edu>
Sat, 6 Nov 2004 07:16:54 +0000 (07:16 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sat, 6 Nov 2004 07:16:54 +0000 (07:16 +0000)
FIXES 15726

cleanup from dread-do-validation; change to using dcache and not just fcache

15 files changed:
src/afs/LINUX/osi_vnodeops.c
src/afs/VNOPS/afs_vnop_create.c
src/afs/VNOPS/afs_vnop_dirops.c
src/afs/VNOPS/afs_vnop_link.c
src/afs/VNOPS/afs_vnop_lookup.c
src/afs/VNOPS/afs_vnop_readdir.c
src/afs/VNOPS/afs_vnop_remove.c
src/afs/VNOPS/afs_vnop_rename.c
src/afs/VNOPS/afs_vnop_symlink.c
src/afs/afs.h
src/afs/afs_buffer.c
src/afs/afs_dcache.c
src/afs/afs_pioctl.c
src/afs/afs_prototypes.h
src/afs/afs_segments.c

index 8178d0b..b64f89d 100644 (file)
@@ -333,11 +333,11 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir)
     code = 0;
     offset = (int) fp->f_pos;
     while (1) {
-       dirpos = BlobScan(&tdc->f, offset);
+       dirpos = BlobScan(tdc, offset);
        if (!dirpos)
            break;
 
-       de = afs_dir_GetBlob(&tdc->f, dirpos);
+       de = afs_dir_GetBlob(tdc, dirpos);
        if (!de)
            break;
 
index c16f411..2e3dcb1 100644 (file)
@@ -154,7 +154,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
     if (tdc) {
        /* see if file already exists.  If it does, we only set 
         * the size attributes (to handle O_TRUNC) */
-       code = afs_dir_Lookup(&tdc->f, aname, &newFid.Fid);     /* use dnlc first xxx */
+       code = afs_dir_Lookup(tdc, aname, &newFid.Fid); /* use dnlc first xxx */
        if (code == 0) {
            ReleaseSharedLock(&tdc->lock);
            afs_PutDCache(tdc);
@@ -368,10 +368,10 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
        UpgradeSToWLock(&tdc->lock, 631);
     if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
        /* we can do it locally */
-       code = afs_dir_Create(&tdc->f, aname, &newFid.Fid);
+       code = afs_dir_Create(tdc, aname, &newFid.Fid);
        if (code) {
            ZapDCE(tdc);
-           DZap(&tdc->f);
+           DZap(tdc);
        }
     }
     if (tdc) {
@@ -531,7 +531,7 @@ afs_LocalHero(register struct vcache *avc, register struct dcache *adc,
     } else {
        if (adc) {
            ZapDCE(adc);
-           DZap(&adc->f);
+           DZap(adc);
        }
        if (avc->states & CStatd) {
            osi_dnlc_purgedp(avc);
index 0cd7ced..32357ac 100644 (file)
@@ -147,10 +147,10 @@ afs_mkdir(OSI_VC_ARG(adp), aname, attrs, avcp, acred)
        ObtainWriteLock(&tdc->lock, 632);
     if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
        /* we can do it locally */
-       code = afs_dir_Create(&tdc->f, aname, &newFid.Fid);
+       code = afs_dir_Create(tdc, aname, &newFid.Fid);
        if (code) {
            ZapDCE(tdc);        /* surprise error -- use invalid value */
-           DZap(&tdc->f);
+           DZap(tdc);
        }
     }
     if (tdc) {
@@ -250,7 +250,7 @@ afs_rmdir(adp, aname, acred)
        struct VenusFid unlinkFid;
 
        unlinkFid.Fid.Vnode = 0;
-       code = afs_dir_Lookup(&tdc->f, aname, &unlinkFid.Fid);
+       code = afs_dir_Lookup(tdc, aname, &unlinkFid.Fid);
        if (code == 0) {
            afs_int32 cached = 0;
 
@@ -304,10 +304,10 @@ afs_rmdir(adp, aname, acred)
        UpgradeSToWLock(&tdc->lock, 634);
     if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
        /* we can do it locally */
-       code = afs_dir_Delete(&tdc->f, aname);
+       code = afs_dir_Delete(tdc, aname);
        if (code) {
            ZapDCE(tdc);        /* surprise error -- invalid value */
-           DZap(&tdc->f);
+           DZap(tdc);
        }
     }
     if (tdc) {
index 22ac2bc..b6eb2a6 100644 (file)
@@ -137,10 +137,10 @@ afs_link(avc, OSI_VC_ARG(adp), aname, acred)
        ObtainWriteLock(&tdc->lock, 635);
     if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
        /* we can do it locally */
-       code = afs_dir_Create(&tdc->f, aname, &avc->fid.Fid);
+       code = afs_dir_Create(tdc, aname, &avc->fid.Fid);
        if (code) {
            ZapDCE(tdc);        /* surprise error -- invalid value */
-           DZap(&tdc->f);
+           DZap(tdc);
        }
     }
     if (tdc) {
index 8add8d8..b2042a9 100644 (file)
@@ -507,21 +507,7 @@ Next_AtSys(register struct vcache *avc, struct vrequest *areq,
     return 1;
 }
 
-#if (defined(AFS_SGI62_ENV) || defined(AFS_SUN57_64BIT_ENV))
-extern int BlobScan(ino64_t * afile, afs_int32 ablob);
-#else
-#if defined(AFS_HPUX1123_ENV)
-/* DEE should use the new afs_inode_t  for all */
-extern int BlobScan(ino_t * afile, afs_int32 ablob);
-#else
-#if defined AFS_LINUX_64BIT_KERNEL
-extern int BlobScan(long *afile, afs_int32 ablob);
-#else
-extern int BlobScan(afs_int32 * afile, afs_int32 ablob);
-#endif
-#endif
-#endif
-
+extern int BlobScan(struct dcache * afile, afs_int32 ablob);
 
 /* called with an unlocked directory and directory cookie.  Areqp
  * describes who is making the call.
@@ -674,7 +660,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
        /* look for first safe entry to examine in the directory.  BlobScan
         * looks for a the 1st allocated dir after the dirCookie slot.
         */
-       newIndex = BlobScan(&dcp->f, (dirCookie >> 5));
+       newIndex = BlobScan(dcp, (dirCookie >> 5));
        if (newIndex == 0)
            break;
 
@@ -683,7 +669,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
 
        /* get a ptr to the dir entry */
        dirEntryp =
-           (struct DirEntry *)afs_dir_GetBlob(&dcp->f, newIndex);
+           (struct DirEntry *)afs_dir_GetBlob(dcp, newIndex);
        if (!dirEntryp)
            break;
 
@@ -1293,7 +1279,6 @@ afs_lookup(adp, aname, avcp, acred)
     {                          /* sub-block just to reduce stack usage */
        register struct dcache *tdc;
        afs_size_t dirOffset, dirLen;
-       struct fcache *theDir;
        struct VenusFid tfid;
 
        /* now we have to lookup the next fid */
@@ -1351,15 +1336,14 @@ afs_lookup(adp, aname, avcp, acred)
 
        /* lookup the name in the appropriate dir, and return a cache entry
         * on the resulting fid */
-       theDir = &tdc->f;
        code =
-           afs_dir_LookupOffset(theDir, sysState.name, &tfid.Fid,
+           afs_dir_LookupOffset(tdc, sysState.name, &tfid.Fid,
                                 &dirCookie);
 
        /* If the first lookup doesn't succeed, maybe it's got @sys in the name */
        while (code == ENOENT && Next_AtSys(adp, &treq, &sysState))
            code =
-               afs_dir_LookupOffset(theDir, sysState.name, &tfid.Fid,
+               afs_dir_LookupOffset(tdc, sysState.name, &tfid.Fid,
                                     &dirCookie);
        tname = sysState.name;
 
index d1d0330..9954d14 100644 (file)
@@ -67,7 +67,7 @@ extern struct DirEntry *afs_dir_GetBlob();
     become static.
 */
 int
-BlobScan(struct fcache * afile, afs_int32 ablob)
+BlobScan(struct dcache * afile, afs_int32 ablob)
 {
     register afs_int32 relativeBlob;
     afs_int32 pageBlob;
@@ -641,8 +641,8 @@ afs_readdir(OSI_VC_ARG(avc), auio, acred)
        origOffset = auio->afsio_offset;
        /* scan for the next interesting entry scan for in-use blob otherwise up point at
         * this blob note that ode, if non-zero, also represents a held dir page */
-       if (!(us = BlobScan(&tdc->f, (origOffset >> 5)))
-           || !(nde = (struct DirEntry *)afs_dir_GetBlob(&tdc->f, us))) {
+       if (!(us = BlobScan(tdc, (origOffset >> 5)))
+           || !(nde = (struct DirEntry *)afs_dir_GetBlob(tdc, us))) {
            /* failed to setup nde, return what we've got, and release ode */
            if (len) {
                /* something to hand over. */
@@ -932,8 +932,8 @@ afs1_readdir(avc, auio, acred)
 
        /* scan for the next interesting entry scan for in-use blob otherwise up point at
         * this blob note that ode, if non-zero, also represents a held dir page */
-       if (!(us = BlobScan(&tdc->f, (origOffset >> 5)))
-           || !(nde = (struct DirEntry *)afs_dir_GetBlob(&tdc->f, us))) {
+       if (!(us = BlobScan(tdc, (origOffset >> 5)))
+           || !(nde = (struct DirEntry *)afs_dir_GetBlob(tdc, us))) {
            /* failed to setup nde, return what we've got, and release ode */
            if (len) {
                /* something to hand over. */
index 363bc22..982a7d6 100644 (file)
@@ -154,10 +154,10 @@ afsremove(register struct vcache *adp, register struct dcache *tdc,
        UpgradeSToWLock(&tdc->lock, 637);
     if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
        /* we can do it locally */
-       code = afs_dir_Delete(&tdc->f, aname);
+       code = afs_dir_Delete(tdc, aname);
        if (code) {
            ZapDCE(tdc);        /* surprise error -- invalid value */
-           DZap(&tdc->f);
+           DZap(tdc);
        }
     }
     if (tdc) {
@@ -357,7 +357,7 @@ afs_remove(OSI_VC_ARG(adp), aname, acred)
      * done the work */
     if (!tvc)
        if (tdc) {
-           code = afs_dir_Lookup(&tdc->f, aname, &unlinkFid.Fid);
+           code = afs_dir_Lookup(tdc, aname, &unlinkFid.Fid);
            if (code == 0) {
                afs_int32 cached = 0;
 
index 642c421..394f114 100644 (file)
@@ -146,7 +146,7 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp,
     }
 
     if (code == 0)
-       code = afs_dir_Lookup(&tdc1->f, aname1, &fileFid.Fid);
+       code = afs_dir_Lookup(tdc1, aname1, &fileFid.Fid);
     if (code) {
        if (tdc1) {
            ReleaseWriteLock(&tdc1->lock);
@@ -205,38 +205,38 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp,
            if (!doLocally) {
                if (tdc1) {
                    ZapDCE(tdc1);
-                   DZap(&tdc1->f);
+                   DZap(tdc1);
                }
                if (tdc2) {
                    ZapDCE(tdc2);
-                   DZap(&tdc2->f);
+                   DZap(tdc2);
                }
            }
        }
        /* now really do the work */
        if (doLocally) {
            /* first lookup the fid of the dude we're moving */
-           code = afs_dir_Lookup(&tdc1->f, aname1, &fileFid.Fid);
+           code = afs_dir_Lookup(tdc1, aname1, &fileFid.Fid);
            if (code == 0) {
                /* delete the source */
-               code = afs_dir_Delete(&tdc1->f, aname1);
+               code = afs_dir_Delete(tdc1, aname1);
            }
            /* first see if target is there */
            if (code == 0
-               && afs_dir_Lookup(&tdc2->f, aname2,
+               && afs_dir_Lookup(tdc2, aname2,
                                  &unlinkFid.Fid) == 0) {
                /* target already exists, and will be unlinked by server */
-               code = afs_dir_Delete(&tdc2->f, aname2);
+               code = afs_dir_Delete(tdc2, aname2);
            }
            if (code == 0) {
-               code = afs_dir_Create(&tdc2->f, aname2, &fileFid.Fid);
+               code = afs_dir_Create(tdc2, aname2, &fileFid.Fid);
            }
            if (code != 0) {
                ZapDCE(tdc1);
-               DZap(&tdc1->f);
+               DZap(tdc1);
                if (!oneDir) {
                    ZapDCE(tdc2);
-                   DZap(&tdc2->f);
+                   DZap(tdc2);
                }
            }
        }
@@ -339,7 +339,7 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp,
            if (tdc1) {
                ObtainWriteLock(&tdc1->lock, 648);
                ZapDCE(tdc1);   /* mark as unknown */
-               DZap(&tdc1->f);
+               DZap(tdc1);
                ReleaseWriteLock(&tdc1->lock);
                afs_PutDCache(tdc1);    /* put it back */
            }
index cd5008d..59548cc 100644 (file)
@@ -184,10 +184,10 @@ int afs_symlink
     /* otherwise, we should see if we can make the change to the dir locally */
     if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
        /* we can do it locally */
-       code = afs_dir_Create(&tdc->f, aname, &newFid.Fid);
+       code = afs_dir_Create(tdc, aname, &newFid.Fid);
        if (code) {
            ZapDCE(tdc);        /* surprise error -- use invalid value */
-           DZap(&tdc->f);
+           DZap(tdc);
        }
     }
     if (tdc) {
index 334277d..c5105aa 100644 (file)
@@ -1195,7 +1195,7 @@ struct afs_fakestat_state {
 extern int afs_fakestat_enable;
 
 struct buffer {
-    struct fcache *fid;
+    struct dcache *fid;
     afs_int32 page;
     afs_int32 accesstime;
     struct buffer *hashNext;
index 0b56b26..b8a366c 100644 (file)
@@ -63,7 +63,7 @@ RCSID
 /* page hash table size - this is pretty intertwined with pHash */
 #define PHSIZE (PHPAGEMASK + PHFIDMASK + 1)
 /* the pHash macro */
-#define pHash(fid,page) ((((afs_int32)((fid)->inode)) & PHFIDMASK) \
+#define pHash(fid,page) ((((afs_int32)((fid)->f.inode)) & PHFIDMASK) \
                         | (page & PHPAGEMASK))
 
 #ifdef dirty
@@ -88,7 +88,7 @@ static int nbuffers;
 static afs_int32 timecounter;
 
 /* Prototypes for static routines */
-static struct buffer *afs_newslot(struct fcache * afid, afs_int32 apage,
+static struct buffer *afs_newslot(struct dcache * afid, afs_int32 apage,
                                  register struct buffer *lp);
 
 static int dinit_flag = 0;
@@ -150,7 +150,7 @@ DInit(int abuffers)
 }
 
 void *
-DRead(register struct fcache * fid, register int page)
+DRead(register struct dcache * fid, register int page)
 {
     /* Read a page from the disk. */
     register struct buffer *tb, *tb2;
@@ -224,13 +224,13 @@ DRead(register struct fcache * fid, register int page)
     MObtainWriteLock(&tb->lock, 260);
     MReleaseWriteLock(&afs_bufferLock);
     tb->lockers++;
-    if (page * AFS_BUFFER_PAGESIZE >= fid->chunkBytes) {
+    if (page * AFS_BUFFER_PAGESIZE >= fid->f.chunkBytes) {
        dirp_Zap(tb->fid);
        tb->lockers--;
        MReleaseWriteLock(&tb->lock);
        return NULL;
     }
-    tfile = afs_CFileOpen(fid->inode);
+    tfile = afs_CFileOpen(fid->f.inode);
     code =
        afs_CFileRead(tfile, tb->page * AFS_BUFFER_PAGESIZE, tb->data,
                      AFS_BUFFER_PAGESIZE);
@@ -273,7 +273,7 @@ FixupBucket(register struct buffer *ap)
 
 /* lp is pointer to a fairly-old buffer */
 static struct buffer *
-afs_newslot(struct fcache * afid, afs_int32 apage, register struct buffer *lp)
+afs_newslot(struct dcache * afid, afs_int32 apage, register struct buffer *lp)
 {
     /* Find a usable buffer slot */
     register afs_int32 i;
@@ -340,7 +340,7 @@ afs_newslot(struct fcache * afid, afs_int32 apage, register struct buffer *lp)
     }
 
     if (lp->dirty) {
-       tfile = afs_CFileOpen(lp->fid->inode);
+       tfile = afs_CFileOpen(lp->fid->f.inode);
        afs_CFileWrite(tfile, lp->page * AFS_BUFFER_PAGESIZE, lp->data,
                       AFS_BUFFER_PAGESIZE);
        lp->dirty = 0;
@@ -432,7 +432,7 @@ DVOffset(register void *ap)
  * method of DRead...
  */
 void
-DZap(struct fcache * fid)
+DZap(struct dcache * fid)
 {
     register int i;
     /* Destroy all buffers pertaining to a particular fid. */
@@ -469,7 +469,7 @@ DFlush(void)
            tb->lockers++;
            MReleaseReadLock(&afs_bufferLock);
            if (tb->dirty) {
-               tfile = afs_CFileOpen(tb->fid->inode);
+               tfile = afs_CFileOpen(tb->fid->f.inode);
                afs_CFileWrite(tfile, tb->page * AFS_BUFFER_PAGESIZE,
                               tb->data, AFS_BUFFER_PAGESIZE);
                tb->dirty = 0;  /* Clear the dirty flag */
@@ -484,7 +484,7 @@ DFlush(void)
 }
 
 void *
-DNew(register struct fcache * fid, register int page)
+DNew(register struct dcache * fid, register int page)
 {
     /* Same as read, only do *not* even try to read the page, since it probably doesn't exist. */
     register struct buffer *tb;
@@ -494,6 +494,11 @@ DNew(register struct fcache * fid, register int page)
        MReleaseWriteLock(&afs_bufferLock);
        return 0;
     }
+    /* extend the chunk, if needed */
+    if ((page + 1) * AFS_BUFFER_PAGESIZE > fid->f.chunkBytes) {
+        afs_AdjustSize(fid, (page + 1) * AFS_BUFFER_PAGESIZE);
+        afs_WriteDCache(fid, 1);
+    }
     MObtainWriteLock(&tb->lock, 265);
     MReleaseWriteLock(&afs_bufferLock);
     tb->lockers++;
index 6124c27..a347b00 100644 (file)
@@ -686,7 +686,7 @@ afs_HashOutDCache(struct dcache *adc)
     AFS_STATCNT(afs_glink);
 #endif
     /* we know this guy's in the LRUQ.  We'll move dude into DCQ below */
-    DZap(&adc->f);
+    DZap(adc);
     /* if this guy is in the hash table, pull him out */
     if (adc->f.fid.Fid.Volume != 0) {
        /* remove entry from first hash chains */
@@ -2038,7 +2038,7 @@ afs_GetDCache(register struct vcache *avc, afs_size_t abyte,
         * Right now, we only have one tool, and it's a hammer.  So, we
         * fetch the whole file.
         */
-       DZap(&tdc->f);  /* pages in cache may be old */
+       DZap(tdc);      /* pages in cache may be old */
 #ifdef  IHINT
        if (file = tdc->ihint) {
            if (tdc->f.inode == file->inum)
@@ -2415,7 +2415,7 @@ afs_GetDCache(register struct vcache *avc, afs_size_t abyte,
            afs_CFileClose(file);
            ZapDCE(tdc);        /* sets DFEntryMod */
            if (vType(avc) == VDIR) {
-               DZap(&tdc->f);
+               DZap(tdc);
            }
            ReleaseWriteLock(&tdc->lock);
            afs_PutDCache(tdc);
index a8c3a3b..4dbf33d 100644 (file)
@@ -1717,7 +1717,7 @@ DECL_PIOCTL(PNewStatMount)
     Check_AtSys(avc, ain, &sysState, areq);
     ObtainReadLock(&tdc->lock);
     do {
-       code = afs_dir_Lookup(&tdc->f, sysState.name, &tfid.Fid);
+       code = afs_dir_Lookup(tdc, sysState.name, &tfid.Fid);
     } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
     ReleaseReadLock(&tdc->lock);
     afs_PutDCache(tdc);                /* we're done with the data */
@@ -2397,7 +2397,7 @@ DECL_PIOCTL(PRemoveMount)
     Check_AtSys(avc, ain, &sysState, areq);
     ObtainReadLock(&tdc->lock);
     do {
-       code = afs_dir_Lookup(&tdc->f, sysState.name, &tfid.Fid);
+       code = afs_dir_Lookup(tdc, sysState.name, &tfid.Fid);
     } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
     ReleaseReadLock(&tdc->lock);
     bufp = sysState.name;
@@ -2468,10 +2468,10 @@ DECL_PIOCTL(PRemoveMount)
        ObtainWriteLock(&tdc->lock, 661);
        if (afs_LocalHero(avc, tdc, &OutDirStatus, 1)) {
            /* we can do it locally */
-           code = afs_dir_Delete(&tdc->f, bufp);
+           code = afs_dir_Delete(tdc, bufp);
            if (code) {
                ZapDCE(tdc);    /* surprise error -- invalid value */
-               DZap(&tdc->f);
+               DZap(tdc);
            }
        }
        ReleaseWriteLock(&tdc->lock);
@@ -3503,7 +3503,7 @@ DECL_PIOCTL(PFlushMount)
     Check_AtSys(avc, ain, &sysState, areq);
     ObtainReadLock(&tdc->lock);
     do {
-       code = afs_dir_Lookup(&tdc->f, sysState.name, &tfid.Fid);
+       code = afs_dir_Lookup(tdc, sysState.name, &tfid.Fid);
     } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
     ReleaseReadLock(&tdc->lock);
     afs_PutDCache(tdc);                /* we're done with the data */
index a185eaf..3346459 100644 (file)
@@ -31,12 +31,12 @@ extern void afs_FreeAllAxs(struct axscache **headp);
 
 /* afs_buffer.c */
 extern void DInit(int abuffers);
-extern void *DRead(register struct fcache * fid, register int page);
+extern void *DRead(register struct dcache * fid, register int page);
 extern void DRelease(register struct buffer *bp, int flag);
 extern int DVOffset(register void *ap);
-extern void DZap(struct fcache * fid);
+extern void DZap(struct dcache * fid);
 extern void DFlush(void);
-extern void *DNew(register struct fcache * fid, register int page);
+extern void *DNew(register struct dcache * fid, register int page);
 extern void shutdown_bufferpackage(void);
 
 /* afs_call.c */
index 41c65ce..6f7560b 100644 (file)
@@ -898,7 +898,7 @@ afs_InvalidateAllSegments(struct vcache *avc)
        ObtainWriteLock(&tdc->lock, 679);
        ZapDCE(tdc);
        if (vType(avc) == VDIR)
-           DZap(&tdc->f);
+           DZap(tdc);
        ReleaseWriteLock(&tdc->lock);
        afs_PutDCache(tdc);
     }