Add a lookup_last method to the multi-store backend.
[bluesky.git] / bluesky / file.c
index a6f6a15..a4a8108 100644 (file)
@@ -192,6 +192,16 @@ void bluesky_file_read(BlueSkyInode *inode, uint64_t offset,
     }
 #endif
 
+    uint64_t start_block, end_block;
+    start_block = offset / BLUESKY_BLOCK_SIZE;
+    end_block = (offset + len - 1) / BLUESKY_BLOCK_SIZE;
+    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_cloudlog_prefetch(b->ref);
+    }
+
     while (len > 0) {
         uint64_t block_num = offset / BLUESKY_BLOCK_SIZE;
         gint block_offset = offset % BLUESKY_BLOCK_SIZE;
@@ -241,7 +251,7 @@ void bluesky_block_flush(BlueSkyInode *inode, BlueSkyBlock *block,
 
     g_assert(block->ref == NULL);
 
-    BlueSkyCloudLog *cloudlog = bluesky_cloudlog_new(fs);
+    BlueSkyCloudLog *cloudlog = bluesky_cloudlog_new(fs, NULL);
     cloudlog->type = LOGTYPE_DATA;
     cloudlog->inum = inode->inum;
     cloudlog->data = block->dirty;      // String ownership is transferred