void bluesky_inode_start_sync(BlueSkyInode *inode, BlueSkyStoreAsync *barrier);
+void bluesky_block_touch(BlueSkyInode *inode, uint64_t i);
+void bluesky_block_fetch(BlueSkyFS *fs, BlueSkyBlock *block,
+ BlueSkyStoreAsync *barrier);
void bluesky_block_flush(BlueSkyFS *fs, BlueSkyBlock *block,
BlueSkyStoreAsync *barrier);
void bluesky_file_flush(BlueSkyInode *inode, BlueSkyStoreAsync *barrier);
uint64_t inum);
void bluesky_directory_dump(BlueSkyInode *dir);
-void bluesky_block_touch(BlueSkyInode *inode, uint64_t i);
-void bluesky_block_fetch(BlueSkyFS *fs, BlueSkyBlock *block);
void bluesky_file_truncate(BlueSkyInode *inode, uint64_t size);
void bluesky_file_write(BlueSkyInode *inode, uint64_t offset,
const char *data, gint len);
block->data = bluesky_string_new(g_malloc0(block_len), block_len);
break;
case BLUESKY_BLOCK_REF:
- bluesky_block_fetch(inode->fs, block);
+ bluesky_block_fetch(inode->fs, block, NULL);
g_assert(block->type == BLUESKY_BLOCK_CACHED);
/* Fall through */
case BLUESKY_BLOCK_CACHED:
memset(buf, 0, bytes);
break;
case BLUESKY_BLOCK_REF:
- bluesky_block_fetch(inode->fs, b);
+ bluesky_block_fetch(inode->fs, b, NULL);
/* Fall through */
case BLUESKY_BLOCK_CACHED:
case BLUESKY_BLOCK_DIRTY:
/* Read the given block from cloud-backed storage if the data is not already
* cached. */
-void bluesky_block_fetch(BlueSkyFS *fs, BlueSkyBlock *block)
+static void block_fetch_completion(BlueSkyStoreAsync *async, gpointer data)
+{
+ BlueSkyBlock *block = (BlueSkyBlock *)data;
+
+ bluesky_string_unref(block->data);
+ block->data = async->data;
+ bluesky_string_ref(block->data);
+ block->type = BLUESKY_BLOCK_CACHED;
+}
+
+void bluesky_block_fetch(BlueSkyFS *fs, BlueSkyBlock *block,
+ BlueSkyStoreAsync *barrier)
{
if (block->type != BLUESKY_BLOCK_REF)
return;
- BlueSkyRCStr *string = bluesky_store_get(fs->store, block->ref);
+ BlueSkyStoreAsync *async = bluesky_store_async_new(fs->store);
+ async->op = STORE_OP_GET;
+ async->key = g_strdup(block->ref);
+ bluesky_store_async_add_notifier(async, (GFunc)block_fetch_completion, block);
+ bluesky_store_async_submit(async);
- bluesky_string_unref(block->data);
- block->data = string;
- block->type = BLUESKY_BLOCK_CACHED;
+ if (barrier != NULL)
+ bluesky_store_add_barrier(barrier, async);
+ else
+ bluesky_store_async_wait(async);
}
/* Write the given block to cloud-backed storage and mark it clean. */