+ block->type = BLUESKY_BLOCK_CACHED;
+ g_atomic_int_add(&fs->cache_dirty, -1);
+}
+
+/* Flush all blocks in a file to stable storage. */
+void bluesky_file_flush(BlueSkyInode *inode, GList **log_items)
+{
+ 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);
+ bluesky_block_flush(inode, b, log_items);
+ }
+}
+
+/* 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) {
+ if (bluesky_verbose) {
+ g_log("bluesky/cache", G_LOG_LEVEL_DEBUG,
+ "Dropping block %d of inode %"PRIu64" from cache",
+ i, inode->inum);
+ g_log("bluesky/cache", G_LOG_LEVEL_DEBUG,
+ " (reference count was %d)", b->data->refcount);
+ }