1 /* Blue Sky: File Systems in the Cloud
3 * Copyright (C) 2009 The Regents of the University of California
4 * Written by Michael Vrable <mvrable@cs.ucsd.edu>
14 #include "bluesky-private.h"
16 /* Filesystem caching and cache coherency. */
18 static void flushd_inode(gpointer key, gpointer value, gpointer user_data)
20 BlueSkyFS *fs = (BlueSkyFS *)user_data;
22 BlueSkyInode *inode = (BlueSkyInode *)value;
24 if (inode->change_count == inode->change_commit)
27 g_log("bluesky/flushd", G_LOG_LEVEL_DEBUG,
28 "Starting flush of inode %"PRIu64, inode->inum);
30 if (inode->type == BLUESKY_REGULAR)
31 bluesky_file_flush(inode);
32 bluesky_inode_flush(fs, inode);
35 /* Scan through the cache for dirty data and start flushing it to stable
36 * storage. This does not guarantee that data is committed when it returns.
37 * Instead, this can be called occasionally to ensure that dirty data is
38 * gradually flushed. */
39 void bluesky_flushd_invoke(BlueSkyFS *fs)
41 g_log("bluesky/flushd", G_LOG_LEVEL_DEBUG,
42 "Writeout process invoked");
44 g_mutex_lock(fs->lock);
45 g_hash_table_foreach(fs->inodes, flushd_inode, fs);
46 g_mutex_unlock(fs->lock);