Add a prefetch method. At the moment it is a no-op.
[bluesky.git] / bluesky / file.c
index 7b11e70..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;