+/* Minimize resources consumed the inode map. This should only be called once
+ * an updated inode map has been serialized to the cloud, and will replace
+ * cloud log objects with skeletal versions that just reference the data
+ * location in the cloud (rather than pinning all object data in memory). */
+void bluesky_inode_map_minimize(BlueSkyFS *fs)
+{
+ GSequenceIter *i = g_sequence_get_begin_iter(fs->inode_map);
+ while (!g_sequence_iter_is_end(i)) {
+ InodeMapRange *range = (InodeMapRange *)g_sequence_get(i);
+
+ if (range->serialized != NULL)
+ bluesky_cloudlog_erase(range->serialized);
+
+ GSequenceIter *j;
+ for (j = g_sequence_get_begin_iter(range->map_entries);
+ !g_sequence_iter_is_end(j); j = g_sequence_iter_next(j))
+ {
+ InodeMapEntry *entry = (InodeMapEntry *)g_sequence_get(j);
+ BlueSkyCloudLog *item = entry->item;
+ if (item != NULL) {
+ g_mutex_lock(item->lock);
+ if (g_atomic_int_get(&item->refcount) == 1) {
+ bluesky_cloudlog_erase(item);
+ }
+ g_mutex_unlock(item->lock);
+ } else {
+ g_warning("Null item for inode map entry %"PRIu64"!",
+ entry->inum);
+ }
+ }
+
+ i = g_sequence_iter_next(i);
+ }
+}
+