Lines Matching refs:bhp

86     BUFHDR_T	*bhp;
129 for ( i = 0, bhp = bufhdr_table; i < NUM_BUFS; bhp++, i++ ) {
130 bhp->lru.next = i+1;
131 bhp->lru.prev = i-1;
132 bhp->flags = 0; /* All Flags off */
133 bhp->refcount = 0;
134 bhp->wait_proc = -1; /* No sleepers */
135 LISTPE_INIT ( hash, bhp, i ); /* Hash chains */
190 BUFHDR_T *bhp;
193 for ( bhp = LRUP;
194 bhp->flags & (BUF_PINNED|BUF_IO_IN_PROGRESS);
195 bhp = LISTP_NEXTP (bufhdr_table, lru, bhp ) ) {
197 if ( bhp->lru.next == lruid ) {
205 if ( bhp->flags & BUF_DIRTY ) {
210 fd = bf_fid_to_fd(bhp->id.file_id);
212 error_log1 ("Invalid fid %d\n", bhp->id.file_id);
215 if ( bf_put_page(fd, bhp) < 0 ) {
220 ndx = BUF_HASH ( bhp->id.file_id, bhp->id.obj_id );
221 LISTP_REMOVE(bufhdr_table, hash, bhp);
222 if ( buf_hash_table[ndx] == (bhp-bufhdr_table) ) {
223 if ( bhp->hash.next != (bhp-bufhdr_table) ) {
224 buf_hash_table[ndx] = bhp->hash.next;
229 INIT_BUF(bhp);
231 return(bhp);
244 BUFHDR_T *bhp;
268 bhp = bf_assign_buf ( ndx, &fobj, BF_PIN|BF_DIRTY|BF_EMPTY, &len );
273 if ( bhp ) {
274 return ((ADDR_T)(buf_table+(bhp-bufhdr_table)));
301 BUFHDR_T *bhp;
322 for ( bhp = bufhdr_table+bufid;
323 !OBJ_EQ (bhp->id, fobj) || !(bhp->flags & BUF_VALID);
324 bhp = LISTP_NEXTP ( bufhdr_table, hash, bhp ) ) {
326 if ( bhp->hash.next == bufid ) {
332 bhp->flags |= BUF_PINNED;
333 bhp->refcount++;
336 buf_table + (bhp-bufhdr_table), bhp->refcount);
340 bhp->flags |= BUF_DIRTY;
343 while ( bhp->flags & BUF_IO_IN_PROGRESS ) {
346 printf("About to sleep on %d (me: %d\n)\n", bhp->wait_proc,
352 stat = proc_sleep_on ( &(bhp->wait_proc), buf_spinlock );
357 if (!( bhp->flags & BUF_IO_IN_PROGRESS) &&
358 (!OBJ_EQ (bhp->id, fobj) || !(bhp->flags & BUF_VALID))) {
364 MAKE_MRU( bhp );
369 bhp = bf_assign_buf ( ndx, &fobj, flags, len );
373 if ( bhp && bhp->flags & BUF_NEWPAGE ) {
380 if ( bhp ) {
381 return ((ADDR_T)(buf_table+(bhp-bufhdr_table)));
399 BUFHDR_T *bhp;
409 for ( bhp = bufhdr_table, i = 0; i < NUM_BUFS; bhp++, i++ ) {
410 if (bhp->id.file_id == fid) {
411 if ((bhp->flags & BF_DIRTY) && (bf_put_page( fd, bhp ) < 0)) {
414 bhp->id.file_id = -1;
435 BUFHDR_T *bhp;
459 bhp = &bufhdr_table[bufid];
463 bhp->flags |= set_flags;
465 bhp->refcount++;
472 bhp->refcount--;
473 if ( bhp->refcount ) {
478 bhp->flags &= ~unset_flags;
479 MAKE_MRU(bhp);
574 bf_put_page ( fd, bhp )
576 BUFHDR_T *bhp;
580 assert ( (bhp-bufhdr_table) < NUM_BUFS );
581 if ( lseek ( fd, bhp->id.obj_id << BUFSHIFT, L_SET ) < 0 ) {
584 bhp->flags |= BUF_IO_IN_PROGRESS;
588 nbytes = write(fd, buf_table[bhp-bufhdr_table], BUFSIZE);
598 bhp->flags &= ~(BUF_DIRTY|BUF_IO_IN_PROGRESS);
609 BUFHDR_T *bhp;
613 bhp = bf_newbuf();
614 if ( !bhp ) {
617 OBJ_ASSIGN ( (*obj), bhp->id );
619 buf_hash_table[ndx] = bhp-bufhdr_table;
621 LISTPE_INSERT ( bufhdr_table, hash, bhp, buf_hash_table[ndx] );
624 bhp->flags |= BUF_VALID;
626 bhp->flags |= BUF_PINNED;
627 bhp->refcount++;
630 buf_table + (bhp-bufhdr_table), bhp->refcount);
636 bhp->flags |= ~BUF_IO_ERROR;
645 bhp->flags |= BUF_IO_IN_PROGRESS;
652 bhp->flags &= ~BUF_IO_IN_PROGRESS;
653 bhp->flags |= ~BUF_IO_ERROR;
656 *len = read(fd, buf_table[bhp-bufhdr_table], BUFSIZE);
660 bhp->flags &= ~BUF_IO_IN_PROGRESS;
661 bhp->flags |= ~BUF_IO_ERROR;
667 bhp->flags &= ~BUF_IO_IN_PROGRESS;
668 if ( bhp->wait_proc != -1 ) {
672 bhp->wait_proc);
674 proc_wake_id ( bhp->wait_proc );
675 bhp->wait_proc = -1;
677 MAKE_MRU(bhp);
681 bhp->flags |= BUF_DIRTY;
683 bhp->flags |= BUF_NEWPAGE;
685 return ( bhp );
719 BUFHDR_T *bhp;
724 for ( bhp = bufhdr_table, i = 0; i < NUM_BUFS; bhp++, i++ ) {
726 bhp->id.file_id, bhp->id.obj_id,
727 bhp->lru.next, bhp->lru.prev,
728 bhp->hash.next, bhp->hash.prev,
729 bhp->wait_proc, bhp->flags, bhp->refcount );
736 bhp = bufhdr_table+id;
738 bhp->id.file_id, bhp->id.obj_id,
739 bhp->lru.next, bhp->lru.prev,
740 bhp->hash.next, bhp->hash.prev,
741 bhp->wait_proc, bhp->flags, bhp->refcount );