afs: Never use GetNewDSlot after init
[openafs.git] / src / afs / afs_chunkops.h
index e99b9d7..3babf89 100644 (file)
@@ -59,10 +59,8 @@ struct afs_cacheOps {
                   afs_int32 len);
     int (*close) (struct osi_file * fp);
     int (*vreadUIO) (afs_dcache_id_t *, struct uio *);
-    int (*vwrite) (struct vcache * avc, struct uio * auio, int aio,
-                  afs_ucred_t * acred, int noLock);
-    struct dcache *(*GetDSlot) (afs_int32 aslot,
-                               struct dcache * tmpdc);
+    int (*vwriteUIO) (struct vcache *, afs_dcache_id_t *, struct uio *);
+    struct dcache *(*GetDSlot) (afs_int32 aslot, int indexvalid, int datavalid);
     struct volume *(*GetVolSlot) (void);
     int (*HandleLink) (struct vcache * avc, struct vrequest * areq);
 };
@@ -73,10 +71,20 @@ struct afs_cacheOps {
 #define        afs_CFileRead(file, offset, data, size) (*(afs_cacheType->fread))(file, offset, data, size)
 #define        afs_CFileWrite(file, offset, data, size) (*(afs_cacheType->fwrite))(file, offset, data, size)
 #define        afs_CFileClose(handle)          (*(afs_cacheType->close))(handle)
-#define        afs_GetDSlot(slot, adc)         (*(afs_cacheType->GetDSlot))(slot, adc)
 #define        afs_GetVolSlot()                (*(afs_cacheType->GetVolSlot))()
 #define        afs_HandleLink(avc, areq)       (*(afs_cacheType->HandleLink))(avc, areq)
 
+/* Use afs_GetValidDSlot to get a dcache from a dcache slot number when we
+ * know the dcache contains data we want (e.g. it's on the hash table) */
+#define        afs_GetValidDSlot(slot) (*(afs_cacheType->GetDSlot))(slot, 1, 1)
+/* Use afs_GetUnusedDSlot when loading a dcache entry that is on the free or
+ * discard lists (the dcache does not contain valid data, but we know the
+ * dcache entry itself exists). */
+#define        afs_GetUnusedDSlot(slot)        (*(afs_cacheType->GetDSlot))(slot, 1, 0)
+/* Use afs_GetNewDSlot only when initializing dcache slots (the given slot
+ * number may not exist at all). */
+#define        afs_GetNewDSlot(slot)   (*(afs_cacheType->GetDSlot))(slot, 0, 0)
+
 /* These memcpys should get optimised to simple assignments when afs_dcache_id_t
  * is simple */
 static_inline void afs_copy_inode(afs_dcache_id_t *dst, afs_dcache_id_t *src) {