From: Michael Vrable Date: Fri, 5 Mar 2010 22:25:29 +0000 (-0800) Subject: Start fetch of all blocks in a read at the start of the read operation. X-Git-Url: https://git.vrable.net/?a=commitdiff_plain;h=7d9e06cc3154631da14e573648940c4d6176ae9a;p=bluesky.git Start fetch of all blocks in a read at the start of the read operation. --- diff --git a/bluesky/file.c b/bluesky/file.c index 822c2c8..66f84e7 100644 --- a/bluesky/file.c +++ b/bluesky/file.c @@ -157,6 +157,25 @@ void bluesky_file_read(BlueSkyInode *inode, uint64_t offset, g_return_if_fail(offset < inode->size); g_return_if_fail(len <= inode->size - offset); + /* Start fetches on any data blocks that we will need for this read. */ + BlueSkyStoreAsync *barrier = bluesky_store_async_new(inode->fs->store); + barrier->op = STORE_OP_BARRIER; + uint64_t start_block, end_block; + start_block = offset / BLUESKY_BLOCK_SIZE; + end_block = (offset + len - 1) / BLUESKY_BLOCK_SIZE; + g_print("Start prefetch on blocks %"PRIi64" .. %"PRIi64"\n", + start_block, end_block); + for (uint64_t i = start_block; i <= end_block; i++) { + BlueSkyBlock *b = &g_array_index(inode->blocks, BlueSkyBlock, + i); + if (b->type == BLUESKY_BLOCK_REF) + bluesky_block_fetch(inode->fs, b, barrier); + } + bluesky_store_async_submit(barrier); + bluesky_store_async_wait(barrier); + bluesky_store_async_unref(barrier); + g_print("Prefetch complete.\n"); + while (len > 0) { uint64_t block_num = offset / BLUESKY_BLOCK_SIZE; gint block_offset = offset % BLUESKY_BLOCK_SIZE;