MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / reuse

Function reuse

dep/hfsutils/libhfs/block.c:394–429  ·  view source on GitHub ↗

* NAME: reuse() * DESCRIPTION: free a bucket for reuse, flushing if necessary */

Source from the content-addressed store, hash-verified

392 * DESCRIPTION: free a bucket for reuse, flushing if necessary
393 */
394static
395int reuse(bcache *cache, bucket *b, unsigned long bnum)
396{
397 bucket *chain[HFS_BLOCKBUFSZ], *bptr;
398 int i;
399
400# ifdef DEBUG
401 if (INUSE(b))
402 fprintf(stderr, "BLOCK: CACHE reusing bucket containing "
403 "vol 0x%lx block %lu:%u\n",
404 (unsigned long) cache->vol, b->bnum, b->count);
405# endif
406
407 if (INUSE(b) && DIRTY(b))
408 {
409 /* flush most recently unused buckets */
410
411 for (bptr = b, i = 0; i < HFS_BLOCKBUFSZ; ++i)
412 {
413 chain[i] = bptr;
414 bptr = bptr->cprev;
415 }
416
417 if (flushbuckets(cache->vol, chain, HFS_BLOCKBUFSZ) == -1)
418 goto fail;
419 }
420
421 b->flags &= ~HFS_BUCKET_INUSE;
422 b->count = 1;
423 b->bnum = bnum;
424
425 return 0;
426
427fail:
428 return -1;
429}
430
431/*
432 * NAME: cplace()

Callers 1

getbucketFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected