X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=bluesky%2Ffile.c;h=9f4d980b4d52419a301f356a3f93b9314d39bec8;hb=6443fe537efa35cdad192b2d35ea0398cce56c17;hp=ccb45e4eb47d378ae344527a3924b7e041b264a1;hpb=f6697c903221f4f95972b7618f84cf86ff1e6bc0;p=bluesky.git diff --git a/bluesky/file.c b/bluesky/file.c index ccb45e4..9f4d980 100644 --- a/bluesky/file.c +++ b/bluesky/file.c @@ -194,7 +194,16 @@ void bluesky_block_flush(BlueSkyFS *fs, BlueSkyBlock *block) g_checksum_update(csum, data->data, data->len); gchar *name = g_strdup(g_checksum_get_string(csum)); - bluesky_store_put(fs->store, name, data); + /* Store the file data asynchronously, and don't bother waiting for a + * response. */ + BlueSkyStoreAsync *async = bluesky_store_async_new(fs->store); + async->op = STORE_OP_PUT; + async->key = g_strdup(name); + bluesky_string_ref(data); + async->data = data; + bluesky_store_async_submit(async); + bluesky_store_async_unref(async); + g_free(block->ref); block->ref = name; @@ -206,3 +215,14 @@ void bluesky_block_flush(BlueSkyFS *fs, BlueSkyBlock *block) g_checksum_free(csum); //bluesky_string_unref(data); } + +/* Flush all blocks in a file to stable storage. */ +void bluesky_file_flush(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); + bluesky_block_flush(inode->fs, b); + } +}