link_directories("${LIBS3_BUILD_DIR}/lib")
add_library(bluesky SHARED
- crypto.c dir.c file.c init.c inode.c serialize.c store.c s3store.c
- util.c)
+ cache.c crypto.c dir.c file.c init.c inode.c serialize.c store.c
+ s3store.c util.c)
add_executable(bluesky-test main.c)
-set(CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}")
+set(CMAKE_C_FLAGS "-Wall -std=gnu99 ${CMAKE_C_FLAGS}")
set(INSTALL_RPATH_USE_LINK_PATH 1)
include_directories(${GLIB_INCLUDE_DIRS})
gint bluesky_dirent_compare(gconstpointer a, gconstpointer b,
gpointer unused);
+void bluesky_flushd_invoke(BlueSkyFS *fs);
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+/* Blue Sky: File Systems in the Cloud
+ *
+ * Copyright (C) 2009 The Regents of the University of California
+ * Written by Michael Vrable <mvrable@cs.ucsd.edu>
+ *
+ * TODO: Licensing
+ */
+
+#include <stdint.h>
+#include <glib.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "bluesky-private.h"
+
+/* Filesystem caching and cache coherency. */
+
+static void flushd_inode(gpointer key, gpointer value, gpointer user_data)
+{
+ BlueSkyFS *fs = (BlueSkyFS *)user_data;
+
+ BlueSkyInode *inode = (BlueSkyInode *)value;
+
+ if (inode->change_count == inode->change_commit)
+ return;
+
+ g_log("bluesky/flushd", G_LOG_LEVEL_DEBUG,
+ "Starting flush of inode %"PRIu64, inode->inum);
+
+ if (inode->type == BLUESKY_REGULAR)
+ bluesky_file_flush(inode);
+ bluesky_inode_flush(fs, inode);
+}
+
+/* Scan through the cache for dirty data and start flushing it to stable
+ * storage. This does not guarantee that data is committed when it returns.
+ * Instead, this can be called occasionally to ensure that dirty data is
+ * gradually flushed. */
+void bluesky_flushd_invoke(BlueSkyFS *fs)
+{
+ g_log("bluesky/flushd", G_LOG_LEVEL_DEBUG,
+ "Writeout process invoked");
+
+ g_mutex_lock(fs->lock);
+ g_hash_table_foreach(fs->inodes, flushd_inode, fs);
+ g_mutex_unlock(fs->lock);
+}
g_hash_table_insert(fs->inodes, &inode->inum, inode);
}
-/* Synchronize an inode to stable storage. */
+/* Deprecated: Synchronize an inode to stable storage. */
void bluesky_inode_flush(BlueSkyFS *fs, BlueSkyInode *inode)
{
GString *buf = g_string_new("");
bluesky_store_async_unref(async);
}
+/* Start writeback of an inode and all associated data. */
+void bluesky_inode_start_sync(BlueSkyInode *inode)
+{
+ GString *buf = g_string_new("");
+ bluesky_serialize_inode(buf, inode);
+ BlueSkyRCStr *data = bluesky_string_new_from_gstring(buf);
+
+ char key[64];
+ sprintf(key, "inode-%016"PRIx64, inode->inum);
+
+ BlueSkyStoreAsync *async = bluesky_store_async_new(fs->store);
+ async->op = STORE_OP_PUT;
+ async->key = g_strdup(key);
+ async->data = data;
+ bluesky_store_async_submit(async);
+ bluesky_store_async_unref(async);
+}
+
/* Fetch an inode from stable storage. */
void bluesky_inode_fetch(BlueSkyFS *fs, uint64_t inum)
{
static void op_complete(gpointer a, gpointer b)
{
- BlueSkyStoreAsync *async = (BlueSkyStoreAsync *)a;
BlueSkyStoreAsync *barrier = (BlueSkyStoreAsync *)b;
g_mutex_lock(barrier->lock);