X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=bluesky%2Ffile.c;h=6ba39e3eff30ac32421d42c2211dd210edda69aa;hb=6c5c93c1d6901dee392a809cea3b1eb3efa23f2f;hp=9b9f91649b991b04d66fca2413201536d0a22dff;hpb=353c0424e56002c6a662df81108f2e9c84190cf1;p=bluesky.git diff --git a/bluesky/file.c b/bluesky/file.c index 9b9f916..6ba39e3 100644 --- a/bluesky/file.c +++ b/bluesky/file.c @@ -225,13 +225,9 @@ void bluesky_block_flush(BlueSkyFS *fs, BlueSkyBlock *block, g_free(block->ref); block->ref = name; - /* block->type = BLUESKY_BLOCK_CACHED; */ - bluesky_string_unref(block->data); - block->data = NULL; - block->type = BLUESKY_BLOCK_REF; + block->type = BLUESKY_BLOCK_CACHED; g_checksum_free(csum); - //bluesky_string_unref(data); } /* Flush all blocks in a file to stable storage. */ @@ -244,3 +240,22 @@ void bluesky_file_flush(BlueSkyInode *inode, BlueSkyStoreAsync *barrier) bluesky_block_flush(inode->fs, b, barrier); } } + +/* Drop clean data blocks for a file from cache. */ +void bluesky_file_drop_cached(BlueSkyInode *inode) +{ + g_return_if_fail(inode->type == BLUESKY_REGULAR); + + for (int i = 0; i < inode->blocks->len; i++) { + BlueSkyBlock *b = &g_array_index(inode->blocks, BlueSkyBlock, i); + if (b->type == BLUESKY_BLOCK_CACHED) { + g_log("bluesky/cache", G_LOG_LEVEL_DEBUG, + "Dropping block %d of inode %"PRIu64" from cache", + i, inode->inum); + + bluesky_string_unref(b->data); + b->data = NULL; + b->type = BLUESKY_BLOCK_REF; + } + } +}