2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #ifndef CM_DISKCACHE_H
11 #define CM_DISKCACHE_H
15 #define DCHash(v, c) ((((v)->vnode + (v)->volume + (c))) & (afs_dhashsize-1))
17 #define CACHE_INFO_FILE "cacheInfo"
19 #define CACHE_INFO_MAGIC 0x34564321
20 #define CACHE_FILE_MAGIC 0x78931230
21 #define CACHE_FILES_PER_DIR 1000
22 #define CACHE_INFO_UPDATES_PER_WRITE 1
24 #define DPRINTF if (0) printf
26 /* kept on disk and in dcache entries */
28 cm_fid_t fid; /* Fid for this file */
29 int32 modTime; /* last time this entry was modified */
30 /*afs_hyper_t versionNo; /* Associated data version number */
32 int chunk; /* Relative chunk number */
33 int chunkBytes; /* Num bytes in this chunk */
34 char states; /* Has this chunk been modified? */
35 int accessOrd; /* change to 64 bit later */
36 #define DISK_CACHE_EMPTY 0
37 #define DISK_CACHE_USED 1
38 int index; /* absolute chunk number */
40 /*char pad[464]; /* pad up to 512 bytes */
43 /* in-memory chunk file control block */
44 typedef struct cm_diskcache {
51 int openfd; /* open file descriptor */
52 struct cm_diskcache *hash_next;
53 struct cm_diskcache *hash_prev;
54 unsigned long refCount;
58 typedef struct cm_cacheInfoHdr {
60 int chunks; /* total chunks in cache */
62 char pad[500]; /* pad up to 512 bytes */
65 typedef struct cm_cacheFileHdr {
70 /* external functions */
72 /* Initialize the disk cache */
74 /* Get chunk from the cache or allocate a new chunk */
75 int diskcache_Get(cm_fid_t *fid, osi_hyper_t *offset, char *buf, int size, int *dataVersion, int *dataCount, cm_diskcache_t **dcpRet);
76 /* Write out buffer to disk */
77 int diskcache_Update(cm_diskcache_t *dcp, char *buf, int size, int dataVersion);
78 /* we accessed this chunk, so move to MRU */
79 void diskcache_Touch(cm_diskcache_t *dcp);
81 #endif /* CM_DISKCACHE_H */