dread-do-validation-20041012
[openafs.git] / src / afs / afs_buffer.c
index f80b719..0b56b26 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)[0])) & PHFIDMASK) \
+#define pHash(fid,page) ((((afs_int32)((fid)->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(afs_inode_t * afid, afs_int32 apage,
+static struct buffer *afs_newslot(struct fcache * afid, afs_int32 apage,
                                  register struct buffer *lp);
 
 static int dinit_flag = 0;
@@ -149,8 +149,8 @@ DInit(int abuffers)
     return;
 }
 
-char *
-DRead(register afs_inode_t * fid, register int page)
+void *
+DRead(register struct fcache * fid, register int page)
 {
     /* Read a page from the disk. */
     register struct buffer *tb, *tb2;
@@ -224,14 +224,13 @@ DRead(register afs_inode_t * fid, register int page)
     MObtainWriteLock(&tb->lock, 260);
     MReleaseWriteLock(&afs_bufferLock);
     tb->lockers++;
-    tfile = afs_CFileOpen(fid[0]);
-    if (page * AFS_BUFFER_PAGESIZE >= tfile->size) {
+    if (page * AFS_BUFFER_PAGESIZE >= fid->chunkBytes) {
        dirp_Zap(tb->fid);
        tb->lockers--;
        MReleaseWriteLock(&tb->lock);
-       afs_CFileClose(tfile);
        return NULL;
     }
+    tfile = afs_CFileOpen(fid->inode);
     code =
        afs_CFileRead(tfile, tb->page * AFS_BUFFER_PAGESIZE, tb->data,
                      AFS_BUFFER_PAGESIZE);
@@ -274,7 +273,7 @@ FixupBucket(register struct buffer *ap)
 
 /* lp is pointer to a fairly-old buffer */
 static struct buffer *
-afs_newslot(afs_inode_t * afid, afs_int32 apage, register struct buffer *lp)
+afs_newslot(struct fcache * afid, afs_int32 apage, register struct buffer *lp)
 {
     /* Find a usable buffer slot */
     register afs_int32 i;
@@ -341,7 +340,7 @@ afs_newslot(afs_inode_t * afid, afs_int32 apage, register struct buffer *lp)
     }
 
     if (lp->dirty) {
-       tfile = afs_CFileOpen(lp->fid[0]);
+       tfile = afs_CFileOpen(lp->fid->inode);
        afs_CFileWrite(tfile, lp->page * AFS_BUFFER_PAGESIZE, lp->data,
                       AFS_BUFFER_PAGESIZE);
        lp->dirty = 0;
@@ -433,7 +432,7 @@ DVOffset(register void *ap)
  * method of DRead...
  */
 void
-DZap(afs_inode_t * fid)
+DZap(struct fcache * fid)
 {
     register int i;
     /* Destroy all buffers pertaining to a particular fid. */
@@ -470,7 +469,7 @@ DFlush(void)
            tb->lockers++;
            MReleaseReadLock(&afs_bufferLock);
            if (tb->dirty) {
-               tfile = afs_CFileOpen(tb->fid[0]);
+               tfile = afs_CFileOpen(tb->fid->inode);
                afs_CFileWrite(tfile, tb->page * AFS_BUFFER_PAGESIZE,
                               tb->data, AFS_BUFFER_PAGESIZE);
                tb->dirty = 0;  /* Clear the dirty flag */
@@ -484,8 +483,8 @@ DFlush(void)
     MReleaseReadLock(&afs_bufferLock);
 }
 
-char *
-DNew(register afs_inode_t * fid, register int page)
+void *
+DNew(register struct fcache * 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;