if (log->data != NULL)
return;
- int offset;
+ /* There are actually two cases: a full deserialization if we have not ever
+ * read the object before, and a partial deserialization where the metadata
+ * is already in memory and we just need to remap the data. If the object
+ * type has not yet been set, we'll need to read and parse the metadata.
+ * Once that is done, we can fall through the case of remapping the data
+ * itself. */
+ if (log->type == LOGTYPE_UNKNOWN) {
+ BlueSkyRCStr *raw = NULL;
+ if ((log->location_flags | log->pending_write) & CLOUDLOG_JOURNAL) {
+ raw = bluesky_log_map_object(log->fs, -1, log->log_seq,
+ log->log_offset, log->log_size);
+ }
+
+ if (raw == NULL && (log->location_flags & CLOUDLOG_CLOUD)) {
+ log->location_flags &= ~CLOUDLOG_JOURNAL;
+ raw = bluesky_log_map_object(log->fs,
+ log->location.directory,
+ log->location.sequence,
+ log->location.offset,
+ log->location.size);
+ }
+ g_assert(raw != NULL);
+ bluesky_deserialize_cloudlog(log, raw->data, raw->len);
+ bluesky_string_unref(raw);
+ }
+
+ /* At this point all metadata should be available and we need only remap
+ * the object data. */
+
+ int offset;
if ((log->location_flags | log->pending_write) & CLOUDLOG_JOURNAL) {
bluesky_cloudlog_stats_update(log, -1);
offset = log->log_offset + sizeof(struct log_header);
header.size2 = GUINT32_TO_LE(data2->len);
header.size3 = GUINT32_TO_LE(data3->len);
header.id = log->id;
+ header.inum = GUINT64_TO_LE(log->inum);
g_string_append_len(state->data, (const char *)&header, sizeof(header));
g_string_append_len(state->data, data1->str, data1->len);
log->inum, 1);
entry->id = log->id;
entry->location = log->location;
+ entry->item = log;
+ bluesky_cloudlog_ref(entry->item);
g_mutex_unlock(fs->lock);
}