Lines Matching refs:b
55 VtBlock *b; in vtcachealloc() local
71 b = &c->block[i]; in vtcachealloc()
72 b->addr = NilBlock; in vtcachealloc()
73 b->c = c; in vtcachealloc()
74 b->data = p; in vtcachealloc()
75 b->heap = i; in vtcachealloc()
76 c->heap[i] = b; in vtcachealloc()
119 VtBlock *b; in vtcachedump() local
122 b = &c->block[i]; in vtcachedump()
124 i, b->type, b->score, b->iostate, b->addr, b->ref, b->nlock); in vtcachedump()
133 VtBlock *b; in cachecheck() local
153 b = &c->block[i]; in cachecheck()
154 if(b->data != &c->mem[i * size]) in cachecheck()
156 if(b->ref && b->heap == BadHeap) in cachecheck()
158 else if(b->addr != NilBlock) in cachecheck()
164 b = &c->block[i]; in cachecheck()
165 if(b->ref){ in cachecheck()
172 upheap(int i, VtBlock *b) in upheap() argument
179 c = b->c; in upheap()
184 if(b->used - now >= bb->used - now) in upheap()
189 c->heap[i] = b; in upheap()
190 b->heap = i; in upheap()
196 downheap(int i, VtBlock *b) in downheap() argument
203 c = b->c; in downheap()
212 if(b->used - now <= bb->used - now) in downheap()
217 c->heap[i] = b; in downheap()
218 b->heap = i; in downheap()
227 heapdel(VtBlock *b) in heapdel() argument
232 c = b->c; in heapdel()
234 si = b->heap; in heapdel()
237 b->heap = BadHeap; in heapdel()
241 b = c->heap[c->nheap]; in heapdel()
242 i = upheap(si, b); in heapdel()
244 downheap(i, b); in heapdel()
252 heapins(VtBlock *b) in heapins() argument
254 assert(b->heap == BadHeap); in heapins()
255 upheap(b->c->nheap++, b); in heapins()
266 VtBlock *b; in vtcachebumpblock() local
277 b = c->heap[0]; in vtcachebumpblock()
278 heapdel(b); in vtcachebumpblock()
280 assert(b->heap == BadHeap); in vtcachebumpblock()
281 assert(b->ref == 0); in vtcachebumpblock()
286 if(b->prev){ in vtcachebumpblock()
287 *(b->prev) = b->next; in vtcachebumpblock()
288 if(b->next) in vtcachebumpblock()
289 b->next->prev = b->prev; in vtcachebumpblock()
290 b->prev = nil; in vtcachebumpblock()
294 if(0)fprint(2, "droping %x:%V\n", b->addr, b->score); in vtcachebumpblock()
296 b->ref = 1; in vtcachebumpblock()
297 b->iostate = BioEmpty; in vtcachebumpblock()
298 return b; in vtcachebumpblock()
309 VtBlock *b; in vtcachelocal() local
317 b = &c->block[addr-1]; in vtcachelocal()
318 if(b->addr == NilBlock || b->iostate != BioLocal) in vtcachelocal()
321 if(b->type != type) in vtcachelocal()
322 sysfatal("vtcachelocal: block has wrong type %d != %d", b->type, type); in vtcachelocal()
325 b->ref++; in vtcachelocal()
328 qlock(&b->lk); in vtcachelocal()
329 b->nlock = 1; in vtcachelocal()
330 b->pc = getcallerpc(&c); in vtcachelocal()
331 return b; in vtcachelocal()
337 VtBlock *b; in vtcacheallocblock() local
340 b = vtcachebumpblock(c); in vtcacheallocblock()
341 b->iostate = BioLocal; in vtcacheallocblock()
342 b->type = type; in vtcacheallocblock()
343 b->addr = (b - c->block)+1; in vtcacheallocblock()
344 vtzeroextend(type, b->data, 0, c->blocksize); in vtcacheallocblock()
345 vtlocaltoglobal(b->addr, b->score); in vtcacheallocblock()
348 qlock(&b->lk); in vtcacheallocblock()
349 b->nlock = 1; in vtcacheallocblock()
350 b->pc = getcallerpc(&c); in vtcacheallocblock()
351 return b; in vtcacheallocblock()
361 VtBlock *b; in vtcacheglobal() local
372 b = vtcachelocal(c, addr, type); in vtcacheglobal()
373 if(b) in vtcacheglobal()
374 b->pc = getcallerpc(&c); in vtcacheglobal()
375 return b; in vtcacheglobal()
384 for(b = c->hash[h]; b != nil; b = b->next){ in vtcacheglobal()
385 if(b->addr != NilBlock || memcmp(b->score, score, VtScoreSize) != 0 || b->type != type) in vtcacheglobal()
387 heapdel(b); in vtcacheglobal()
388 b->ref++; in vtcacheglobal()
391 fprint(2, "vtcacheglobal %V %d => found in cache %p; locking\n", score, type, b); in vtcacheglobal()
392 qlock(&b->lk); in vtcacheglobal()
393 b->nlock = 1; in vtcacheglobal()
394 if(b->iostate == BioVentiError){ in vtcacheglobal()
399 vtblockput(b); in vtcacheglobal()
405 b->pc = getcallerpc(&c); in vtcacheglobal()
406 return b; in vtcacheglobal()
412 b = vtcachebumpblock(c); in vtcacheglobal()
413 b->addr = NilBlock; in vtcacheglobal()
414 b->type = type; in vtcacheglobal()
415 memmove(b->score, score, VtScoreSize); in vtcacheglobal()
417 b->next = c->hash[h]; in vtcacheglobal()
418 c->hash[h] = b; in vtcacheglobal()
419 if(b->next != nil) in vtcacheglobal()
420 b->next->prev = &b->next; in vtcacheglobal()
421 b->prev = &c->hash[h]; in vtcacheglobal()
432 fprint(2, "vtcacheglobal %V %d => bumped; locking %p\n", score, type, b); in vtcacheglobal()
433 qlock(&b->lk); in vtcacheglobal()
434 b->nlock = 1; in vtcacheglobal()
438 n = vtread(c->z, score, type, b->data, c->blocksize); in vtcacheglobal()
444 b->iostate = BioVentiError; in vtcacheglobal()
445 vtblockput(b); in vtcacheglobal()
448 vtzeroextend(type, b->data, n, c->blocksize); in vtcacheglobal()
449 b->iostate = BioVenti; in vtcacheglobal()
450 b->nlock = 1; in vtcacheglobal()
453 b->pc = getcallerpc(&b); in vtcacheglobal()
454 return b; in vtcacheglobal()
464 vtblockduplock(VtBlock *b) in vtblockduplock() argument
466 assert(b->nlock > 0); in vtblockduplock()
467 b->nlock++; in vtblockduplock()
475 vtblockput(VtBlock* b) in vtblockput() argument
479 if(b == nil) in vtblockput()
482 if(0)fprint(2, "vtblockput: %d: %x %d %d\n", getpid(), b->addr, c->nheap, b->iostate); in vtblockput()
484 fprint(2, "vtblockput %p from %p\n", b, getcallerpc(&b)); in vtblockput()
486 if(--b->nlock > 0) in vtblockput()
496 assert(b->nlock == 0); in vtblockput()
497 b->nlock = 1; in vtblockput()
499 qunlock(&b->lk); in vtblockput()
500 c = b->c; in vtblockput()
503 if(--b->ref > 0){ in vtblockput()
508 assert(b->ref == 0); in vtblockput()
509 switch(b->iostate){ in vtblockput()
512 b->used = c->now++; in vtblockput()
515 heapins(b); in vtblockput()
524 vtblockwrite(VtBlock *b) in vtblockwrite() argument
531 if(b->iostate != BioLocal){ in vtblockwrite()
536 c = b->c; in vtblockwrite()
537 n = vtzerotruncate(b->type, b->data, c->blocksize); in vtblockwrite()
539 if(c->write(c->z, score, b->type, b->data, n) < 0) in vtblockwrite()
542 memmove(b->score, score, VtScoreSize); in vtblockwrite()
545 b->addr = NilBlock; /* now on venti */ in vtblockwrite()
546 b->iostate = BioVenti; in vtblockwrite()
548 b->next = c->hash[h]; in vtblockwrite()
549 c->hash[h] = b; in vtblockwrite()
550 if(b->next != nil) in vtblockwrite()
551 b->next->prev = &b->next; in vtblockwrite()
552 b->prev = &c->hash[h]; in vtblockwrite()
564 vtblockcopy(VtBlock *b) in vtblockcopy() argument
569 bb = vtcacheallocblock(b->c, b->type); in vtblockcopy()
571 vtblockput(b); in vtblockcopy()
574 memmove(bb->data, b->data, b->c->blocksize); in vtblockcopy()
575 vtblockput(b); in vtblockcopy()
576 bb->pc = getcallerpc(&b); in vtblockcopy()