Lines Matching +full:cache +full:- +full:block
2 * CACHE.C
4 * Block cache for dump
35 typedef struct Block { struct
36 struct Block *b_HNext; /* must be first field */ argument
39 } Block; typedef
45 static Block **BlockHash;
55 Block *base; in cinit()
57 if ((BlockSize = sblock->fs_bsize * BLKFACTOR) > MAXBSIZE) in cinit()
62 msg("Cache %d MB, blocksize = %d\n", in cinit()
65 base = calloc(sizeof(Block), NBlocks); in cinit()
66 BlockHash = calloc(sizeof(Block *), HSize); in cinit()
68 PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); in cinit()
71 base[i].b_Offset = (off_t)-1; in cinit()
81 Block *blk; in cread()
82 Block **pblk; in cread()
83 Block **ppblk; in cread()
89 * If the cache is disabled, or we do not yet know the filesystem in cread()
90 * block size, then revert to pread. Otherwise initialize the in cread()
91 * cache as necessary and continue. in cread()
93 if (cachesize <= 0 || sblock->fs_bsize == 0) in cread()
99 * If the request crosses a cache block boundary, or the in cread()
100 * request is larger or equal to the cache block size, in cread()
101 * revert to pread(). Full-block-reads are typically in cread()
102 * one-time calls and caching would be detrimental. in cread()
104 mask = ~(off_t)(BlockSize - 1); in cread()
106 ((offset ^ (offset + nbytes - 1)) & mask) != 0) { in cread()
111 * Obtain and access the cache block. Cache a successful in cread()
119 if (((blk->b_Offset ^ offset) & mask) == 0) in cread()
122 pblk = &blk->b_HNext; in cread()
127 blk->b_Offset = offset & mask; in cread()
128 n = pread(fd, blk->b_Data, BlockSize, blk->b_Offset); in cread()
130 blk->b_Offset = (off_t)-1; in cread()
135 bcopy(blk->b_Data + (offset - blk->b_Offset), buf, nbytes); in cread()
136 *pblk = blk->b_HNext; in cread()
137 blk->b_HNext = BlockHash[hi]; in cread()