* NAME: cplace() * DESCRIPTION: move a bucket to an appropriate place near head of the chain */
| 433 | * DESCRIPTION: move a bucket to an appropriate place near head of the chain |
| 434 | */ |
| 435 | static |
| 436 | void cplace(bcache *cache, bucket *b) |
| 437 | { |
| 438 | bucket *p; |
| 439 | |
| 440 | for (p = cache->tail->cnext; p->count > 1; p = p->cnext) |
| 441 | --p->count; |
| 442 | |
| 443 | b->cnext->cprev = b->cprev; |
| 444 | b->cprev->cnext = b->cnext; |
| 445 | |
| 446 | if (cache->tail == b) |
| 447 | cache->tail = b->cprev; |
| 448 | |
| 449 | b->cprev = p->cprev; |
| 450 | b->cnext = p; |
| 451 | |
| 452 | p->cprev->cnext = b; |
| 453 | p->cprev = b; |
| 454 | } |
| 455 | |
| 456 | /* |
| 457 | * NAME: hplace() |