Add an inode map data structure to track the location of inodes in logs.
[bluesky.git] / bluesky / cloudlog.c
index 0356c7d..40067fd 100644 (file)
@@ -265,6 +265,16 @@ BlueSkyCloudPointer bluesky_cloudlog_serialize(BlueSkyCloudLog *log,
     g_string_append_len(state->data, (const char *)&header, sizeof(header));
     g_string_append_len(state->data, log->data->data, log->data->len);
 
+    /* If the object we flushed was an inode, update the inode map. */
+    if (log->type == LOGTYPE_INODE) {
+        g_mutex_lock(fs->lock);
+        InodeMapEntry *entry = bluesky_inode_map_lookup(fs->inode_map,
+                                                        log->inum, 1);
+        entry->id = log->id;
+        entry->location = log->location;
+        g_mutex_unlock(fs->lock);
+    }
+
     /* TODO: We should mark the objects as committed on the cloud until the
      * data is flushed and acknowledged. */
     log->pending_write |= CLOUDLOG_CLOUD;