Lines Matching refs:bhp
85 BUFHDR_T *bhp;
128 for ( i = 0, bhp = bufhdr_table; i < NUM_BUFS; bhp++, i++ ) {
129 bhp->lru.next = i+1;
130 bhp->lru.prev = i-1;
131 bhp->flags = 0; /* All Flags off */
132 bhp->refcount = 0;
133 bhp->wait_proc = -1; /* No sleepers */
134 LISTPE_INIT ( hash, bhp, i ); /* Hash chains */
189 BUFHDR_T *bhp;
192 for ( bhp = LRUP;
193 bhp->flags & (BUF_PINNED|BUF_IO_IN_PROGRESS);
194 bhp = LISTP_NEXTP (bufhdr_table, lru, bhp ) ) {
196 if ( bhp->lru.next == lruid ) {
204 if ( bhp->flags & BUF_DIRTY ) {
209 fd = bf_fid_to_fd(bhp->id.file_id);
211 error_log1 ("Invalid fid %d\n", bhp->id.file_id);
214 if ( bf_put_page(fd, bhp) < 0 ) {
219 ndx = BUF_HASH ( bhp->id.file_id, bhp->id.obj_id );
220 LISTP_REMOVE(bufhdr_table, hash, bhp);
221 if ( buf_hash_table[ndx] == (bhp-bufhdr_table) ) {
222 if ( bhp->hash.next != (bhp-bufhdr_table) ) {
223 buf_hash_table[ndx] = bhp->hash.next;
228 INIT_BUF(bhp);
230 return(bhp);
243 BUFHDR_T *bhp;
267 bhp = bf_assign_buf ( ndx, &fobj, BF_PIN|BF_DIRTY|BF_EMPTY, &len );
272 if ( bhp ) {
273 return ((ADDR_T)(buf_table+(bhp-bufhdr_table)));
300 BUFHDR_T *bhp;
321 for ( bhp = bufhdr_table+bufid;
322 !OBJ_EQ (bhp->id, fobj) || !(bhp->flags & BUF_VALID);
323 bhp = LISTP_NEXTP ( bufhdr_table, hash, bhp ) ) {
325 if ( bhp->hash.next == bufid ) {
331 bhp->flags |= BUF_PINNED;
332 bhp->refcount++;
335 buf_table + (bhp-bufhdr_table), bhp->refcount);
339 bhp->flags |= BUF_DIRTY;
342 while ( bhp->flags & BUF_IO_IN_PROGRESS ) {
345 printf("About to sleep on %d (me: %d\n)\n", bhp->wait_proc,
351 stat = proc_sleep_on ( &(bhp->wait_proc), buf_spinlock );
356 if (!( bhp->flags & BUF_IO_IN_PROGRESS) &&
357 (!OBJ_EQ (bhp->id, fobj) || !(bhp->flags & BUF_VALID))) {
363 MAKE_MRU( bhp );
368 bhp = bf_assign_buf ( ndx, &fobj, flags, len );
372 if ( bhp && bhp->flags & BUF_NEWPAGE ) {
379 if ( bhp ) {
380 return ((ADDR_T)(buf_table+(bhp-bufhdr_table)));
398 BUFHDR_T *bhp;
408 for ( bhp = bufhdr_table, i = 0; i < NUM_BUFS; bhp++, i++ ) {
409 if (bhp->id.file_id == fid) {
410 if ((bhp->flags & BF_DIRTY) && (bf_put_page( fd, bhp ) < 0)) {
413 bhp->id.file_id = -1;
434 BUFHDR_T *bhp;
458 bhp = &bufhdr_table[bufid];
462 bhp->flags |= set_flags;
464 bhp->refcount++;
471 bhp->refcount--;
472 if ( bhp->refcount ) {
477 bhp->flags &= ~unset_flags;
478 MAKE_MRU(bhp);
573 bf_put_page ( fd, bhp )
575 BUFHDR_T *bhp;
579 assert ( (bhp-bufhdr_table) < NUM_BUFS );
580 if ( lseek ( fd, bhp->id.obj_id << BUFSHIFT, L_SET ) < 0 ) {
583 bhp->flags |= BUF_IO_IN_PROGRESS;
587 nbytes = write(fd, buf_table[bhp-bufhdr_table], BUFSIZE);
597 bhp->flags &= ~(BUF_DIRTY|BUF_IO_IN_PROGRESS);
608 BUFHDR_T *bhp;
612 bhp = bf_newbuf();
613 if ( !bhp ) {
616 OBJ_ASSIGN ( (*obj), bhp->id );
618 buf_hash_table[ndx] = bhp-bufhdr_table;
620 LISTPE_INSERT ( bufhdr_table, hash, bhp, buf_hash_table[ndx] );
623 bhp->flags |= BUF_VALID;
625 bhp->flags |= BUF_PINNED;
626 bhp->refcount++;
629 buf_table + (bhp-bufhdr_table), bhp->refcount);
635 bhp->flags |= ~BUF_IO_ERROR;
644 bhp->flags |= BUF_IO_IN_PROGRESS;
651 bhp->flags &= ~BUF_IO_IN_PROGRESS;
652 bhp->flags |= ~BUF_IO_ERROR;
655 *len = read(fd, buf_table[bhp-bufhdr_table], BUFSIZE);
659 bhp->flags &= ~BUF_IO_IN_PROGRESS;
660 bhp->flags |= ~BUF_IO_ERROR;
666 bhp->flags &= ~BUF_IO_IN_PROGRESS;
667 if ( bhp->wait_proc != -1 ) {
671 bhp->wait_proc);
673 proc_wake_id ( bhp->wait_proc );
674 bhp->wait_proc = -1;
676 MAKE_MRU(bhp);
680 bhp->flags |= BUF_DIRTY;
682 bhp->flags |= BUF_NEWPAGE;
684 return ( bhp );
718 BUFHDR_T *bhp;
723 for ( bhp = bufhdr_table, i = 0; i < NUM_BUFS; bhp++, i++ ) {
725 bhp->id.file_id, bhp->id.obj_id,
726 bhp->lru.next, bhp->lru.prev,
727 bhp->hash.next, bhp->hash.prev,
728 bhp->wait_proc, bhp->flags, bhp->refcount );
735 bhp = bufhdr_table+id;
737 bhp->id.file_id, bhp->id.obj_id,
738 bhp->lru.next, bhp->lru.prev,
739 bhp->hash.next, bhp->hash.prev,
740 bhp->wait_proc, bhp->flags, bhp->refcount );