37 #if defined(LIBC_SCCS) && !defined(lint) 38 static char sccsid[] =
"@(#)hash_buf.c 8.5 (Berkeley) 7/15/94";
57 #include <sys/param.h> 68 #include "../include/db.h" 76 #define BUF_REMOVE(B) { \ 77 (B)->prev->next = (B)->next; \ 78 (B)->next->prev = (B)->prev; \ 82 #define BUF_INSERT(B, P) { \ 83 (B)->next = (P)->next; \ 86 (B)->next->prev = (B); \ 89 #define MRU hashp->bufhead.next 90 #define LRU hashp->bufhead.prev 92 #define MRU_INSERT(B) BUF_INSERT((B), &hashp->bufhead) 93 #define LRU_INSERT(B) BUF_INSERT((B), LRU) 113 register int is_disk, segment_ndx = 0;
120 if (!bp || (bp->
addr != addr))
126 segment_ndx = addr & (hashp->SGSIZE - 1);
129 segp = hashp->
dir[addr >> hashp->SSHIFT];
131 assert(segp !=
NULL);
133 bp =
PTROF(segp[segment_ndx]);
134 is_disk_mask =
ISDISK(segp[segment_ndx]);
135 is_disk = is_disk_mask || !hashp->
new_file;
139 bp =
newbuf(hashp, addr, prev_bp);
145 (
BUFHEAD *)((ptrdiff_t)bp | is_disk_mask);
183 memset(bp, 0xff,
sizeof(
BUFHEAD));
190 memset(bp->
page, 0xff, hashp->BSIZE);
208 oaddr = shortp[shortp[0] - 1];
221 segment_ndx = bp->
addr & (hashp->SGSIZE - 1);
222 segp = hashp->
dir[bp->
addr >> hashp->SSHIFT];
224 assert(segp !=
NULL);
229 ISDISK(segp[segment_ndx])))
232 segp[segment_ndx] =
NULL;
239 for (xbp = bp; xbp->
ovfl;) {
240 next_xbp = xbp->
ovfl;
246 (oaddr != xbp->
addr))
252 oaddr = shortp[shortp[0] - 1];
267 (void)fprintf(stderr,
"NEWBUF1: %d->ovfl was %d is now %d\n",
277 (void)fprintf(stderr,
"NEWBUF2: %d->ovfl was %d is now %d\n",
279 (bp ? bp->
addr : 0));
298 npages = (nbytes + hashp->BSIZE - 1) >> hashp->BSHIFT;
301 hashp->
nbufs = npages;
317 int do_free, to_disk;
int __buf_free(HTAB *hashp, int do_free, int to_disk)
static BUFHEAD *newbuf __P((HTAB *, u_int32_t, BUFHEAD *))
int __put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap)
void __reclaim_buf(HTAB *hashp, BUFHEAD *bp)
int __get_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_disk, int is_bitmap)
BUFHEAD * __get_buf(HTAB *hashp, u_int32_t addr, BUFHEAD *prev_bp, int newpage)
static BUFHEAD * newbuf(HTAB *hashp, u_int32_t addr, BUFHEAD *prev_bp)
void __buf_init(HTAB *hashp, int nbytes)