/* Write the given block to cloud-backed storage and mark it clean. */
void bluesky_block_flush(BlueSkyFS *fs, BlueSkyBlock *block,
- BlueSkyStoreAsync *barrier)
+ BlueSkyStoreAsync *barrier,
+ GList **log_items)
{
if (block->type != BLUESKY_BLOCK_DIRTY)
return;
g_checksum_update(csum, (const guchar *)data->data, data->len);
gchar *name = g_strdup(g_checksum_get_string(csum));
+ /* Start commit to the local log. */
+ BlueSkyLogItem *log_item = bluesky_log_item_new();
+ log_item->key = g_strdup(name);
+ log_item->data = data;
+ bluesky_string_ref(data);
+ bluesky_log_item_submit(log_item, fs->log);
+ *log_items = g_list_prepend(*log_items, log_item);
+
/* Store the file data asynchronously, and don't bother waiting for a
* response. */
BlueSkyStoreAsync *async = bluesky_store_async_new(fs->store);
}
/* Flush all blocks in a file to stable storage. */
-void bluesky_file_flush(BlueSkyInode *inode, BlueSkyStoreAsync *barrier)
+void bluesky_file_flush(BlueSkyInode *inode, BlueSkyStoreAsync *barrier,
+ 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->fs, b, barrier);
+ bluesky_block_flush(inode->fs, b, barrier, log_items);
}
}