}
if (action != 0) {
- bluesky_cloudlog_unref(range->serialized);
+ bluesky_cloudlog_unref_delayed(range->serialized);
range->serialized = NULL;
}
BlueSkyCloudLog *bluesky_inode_map_serialize(BlueSkyFS *fs)
{
+ gboolean updated = FALSE;
GString *buf = g_string_new("");
BlueSkyCloudLog *log = bluesky_cloudlog_new(fs, NULL);
log->type = LOGTYPE_CHECKPOINT;
inum = GUINT64_TO_LE(range->end);
g_string_append_len(buf, (const char *)&inum, sizeof(inum));
- if (range->serialized == NULL)
+ if (range->serialized == NULL) {
bluesky_inode_map_serialize_section(fs, range);
+ updated = TRUE;
+ }
bluesky_cloudlog_ref(range->serialized);
g_array_append_val(log->links, range->serialized);
i = g_sequence_iter_next(i);
}
log->data = bluesky_string_new_from_gstring(buf);
- return log;
+
+ if (updated) {
+ return log;
+ } else {
+ bluesky_cloudlog_unref(log);
+ return NULL;
+ }
}
/* Reconstruct the inode map from data stored in the cloud. */
for (int j = 0; j < section->links->len; j++) {
InodeMapEntry *entry;
entry = bluesky_inode_map_lookup(fs->inode_map, *inum, 1);
- entry->inum = *inum;
+ entry->inum = GUINT64_FROM_LE(*inum);
entry->item = g_array_index(section->links,
- BlueSkyCloudLog *, i);
+ BlueSkyCloudLog *, j);
bluesky_cloudlog_ref(entry->item);
entry->id = entry->item->id;
entry->location = entry->item->location;
+ fs->next_inum = MAX(fs->next_inum, entry->inum + 1);
inum++;
}
g_mutex_unlock(section->lock);
g_print("Last cloud log segment: %s\n", last_segment);
int seq = atoi(last_segment + 13);
+ fs->log_state->location.sequence = seq + 1;
BlueSkyRCStr *last = bluesky_store_get(fs->store, last_segment);
g_free(last_segment);
g_mutex_unlock(commit->lock);
bluesky_inode_map_deserialize(fs, commit);
- bluesky_cloudlog_unref(commit);
+ //bluesky_cloudlog_unref(commit);
return TRUE;
}