From: Michael Vrable Date: Wed, 9 Dec 2009 19:34:11 +0000 (-0800) Subject: Track when cached file data is written out. X-Git-Url: https://git.vrable.net/?a=commitdiff_plain;h=b34b242b34388a3eb26bad5135cdf629ab69b70a;p=bluesky.git Track when cached file data is written out. --- diff --git a/bluesky/bluesky-private.h b/bluesky/bluesky-private.h index e51c40f..d5e5d4f 100644 --- a/bluesky/bluesky-private.h +++ b/bluesky/bluesky-private.h @@ -112,6 +112,10 @@ void bluesky_store_add_barrier(BlueSkyStoreAsync *barrier, void bluesky_inode_start_sync(BlueSkyInode *inode, BlueSkyStoreAsync *barrier); +void bluesky_block_flush(BlueSkyFS *fs, BlueSkyBlock *block, + BlueSkyStoreAsync *barrier); +void bluesky_file_flush(BlueSkyInode *inode, BlueSkyStoreAsync *barrier); + #ifdef __cplusplus } #endif diff --git a/bluesky/bluesky.h b/bluesky/bluesky.h index bd598e0..1d9f55c 100644 --- a/bluesky/bluesky.h +++ b/bluesky/bluesky.h @@ -217,8 +217,6 @@ 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_block_flush(BlueSkyFS *fs, BlueSkyBlock *block); -void bluesky_file_flush(BlueSkyInode *inode); void bluesky_file_truncate(BlueSkyInode *inode, uint64_t size); void bluesky_file_write(BlueSkyInode *inode, uint64_t offset, const char *data, gint len); diff --git a/bluesky/file.c b/bluesky/file.c index 8e16e91..3be40f0 100644 --- a/bluesky/file.c +++ b/bluesky/file.c @@ -119,7 +119,6 @@ void bluesky_file_write(BlueSkyInode *inode, uint64_t offset, BlueSkyBlock *b = &g_array_index(inode->blocks, BlueSkyBlock, block_num); memcpy(&b->data->data[block_offset], data, bytes); - bluesky_block_flush(inode->fs, b); offset += bytes; data += bytes; @@ -127,7 +126,6 @@ void bluesky_file_write(BlueSkyInode *inode, uint64_t offset, } bluesky_inode_update_ctime(inode, 1); - //bluesky_inode_flush(inode->fs, inode); } void bluesky_file_read(BlueSkyInode *inode, uint64_t offset, @@ -182,13 +180,9 @@ void bluesky_block_fetch(BlueSkyFS *fs, BlueSkyBlock *block) block->type = BLUESKY_BLOCK_CACHED; } -static void finished(gpointer a, gpointer b) -{ - g_print("Barrier completed!\n"); -} - /* Write the given block to cloud-backed storage and mark it clean. */ -void bluesky_block_flush(BlueSkyFS *fs, BlueSkyBlock *block) +void bluesky_block_flush(BlueSkyFS *fs, BlueSkyBlock *block, + BlueSkyStoreAsync *barrier) { if (block->type != BLUESKY_BLOCK_DIRTY) return; @@ -207,18 +201,13 @@ void bluesky_block_flush(BlueSkyFS *fs, BlueSkyBlock *block) bluesky_string_ref(data); async->data = data; bluesky_store_async_submit(async); + if (barrier != NULL) + bluesky_store_add_barrier(barrier, async); bluesky_store_async_unref(async); g_free(block->ref); block->ref = name; - BlueSkyStoreAsync *barrier = bluesky_store_async_new(fs->store); - barrier->op = STORE_OP_BARRIER; - bluesky_store_add_barrier(barrier, async); - bluesky_store_async_add_notifier(barrier, finished, NULL); - bluesky_store_async_submit(barrier); - bluesky_store_async_unref(barrier); - /* block->type = BLUESKY_BLOCK_CACHED; */ bluesky_string_unref(block->data); block->data = NULL; @@ -229,12 +218,12 @@ void bluesky_block_flush(BlueSkyFS *fs, BlueSkyBlock *block) } /* Flush all blocks in a file to stable storage. */ -void bluesky_file_flush(BlueSkyInode *inode) +void bluesky_file_flush(BlueSkyInode *inode, BlueSkyStoreAsync *barrier) { 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); + bluesky_block_flush(inode->fs, b, barrier); } } diff --git a/bluesky/inode.c b/bluesky/inode.c index 40f40ba..bdf01a1 100644 --- a/bluesky/inode.c +++ b/bluesky/inode.c @@ -229,7 +229,7 @@ void bluesky_inode_start_sync(BlueSkyInode *inode, BlueSkyStoreAsync *barrier) BlueSkyRCStr *data = bluesky_string_new_from_gstring(buf); if (inode->type == BLUESKY_REGULAR) - bluesky_file_flush(inode); + bluesky_file_flush(inode, barrier); char key[64]; sprintf(key, "inode-%016"PRIx64, inode->inum);