void bluesky_cloudlog_unref(BlueSkyCloudLog *log);
void bluesky_cloudlog_sync(BlueSkyCloudLog *log);
void bluesky_cloudlog_insert(BlueSkyCloudLog *log);
-void bluesky_cloudlog_write_log(BlueSkyFS *fs);
void bluesky_cloudlog_fetch(BlueSkyCloudLog *log);
BlueSkyCloudPointer bluesky_cloudlog_serialize(BlueSkyCloudLog *log,
BlueSkyFS *fs);
return log->location;
}
-static void find_inodes(gpointer key, gpointer value, gpointer user_data)
-{
- BlueSkyCloudLogState *state = (BlueSkyCloudLogState *)user_data;
- BlueSkyCloudLog *item = (BlueSkyCloudLog *)value;
-
- if (item->type != LOGTYPE_INODE)
- return;
-
- bluesky_cloudlog_ref(item);
- state->inode_list = g_list_prepend(state->inode_list, item);
-}
-
/* Finish up a partially-written cloud log segment and flush it to storage. */
void bluesky_cloudlog_flush(BlueSkyFS *fs)
{
state->location.offset = 0;
state->data = g_string_new("");
}
-
-void bluesky_cloudlog_write_log(BlueSkyFS *fs)
-{
- BlueSkyCloudLogState *state = fs->log_state;
- if (state->data == NULL)
- state->data = g_string_new("");
-
- g_mutex_lock(fs->lock);
- g_hash_table_foreach(fs->locations, find_inodes, state);
- g_mutex_unlock(fs->lock);
-
- while (state->inode_list != NULL) {
- BlueSkyCloudLog *log = (BlueSkyCloudLog *)state->inode_list->data;
- bluesky_cloudlog_serialize(log, fs);
- bluesky_cloudlog_unref(log);
- state->inode_list = g_list_delete_link(state->inode_list,
- state->inode_list);
-
- if (state->data->len > CLOUDLOG_SEGMENT_SIZE)
- bluesky_cloudlog_flush(fs);
- }
-
- bluesky_cloudlog_flush(fs);
-}