X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=bluesky%2Fimap.c;h=63182562ca2cbd5f90aacc6169ae799690f04d8c;hb=0a5db8fb9777ff872240053593fd86af71360ee8;hp=c496f99081db149bd6bdbb0fc9343656d0d00442;hpb=ee9d70dbec3dd064793bb51576dcb9064c2ae470;p=bluesky.git diff --git a/bluesky/imap.c b/bluesky/imap.c index c496f99..6318256 100644 --- a/bluesky/imap.c +++ b/bluesky/imap.c @@ -145,6 +145,7 @@ static void bluesky_inode_map_serialize_section(BlueSkyFS *fs, InodeMapEntry *entry = (InodeMapEntry *)g_sequence_get(i); uint64_t inum = GUINT64_TO_LE(entry->inum); g_string_append_len(buf, (const char *)&inum, sizeof(inum)); + bluesky_cloudlog_ref(entry->item); g_array_append_val(log->links, entry->item); i = g_sequence_iter_next(i); } @@ -189,6 +190,23 @@ BlueSkyCloudLog *bluesky_inode_map_serialize(BlueSkyFS *fs) } } +/* 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); + + i = g_sequence_iter_next(i); + } +} + /* Reconstruct the inode map from data stored in the cloud. */ static void bluesky_inode_map_deserialize(BlueSkyFS *fs, BlueSkyCloudLog *imap) { @@ -214,8 +232,6 @@ static void bluesky_inode_map_deserialize(BlueSkyFS *fs, BlueSkyCloudLog *imap) entry->item = g_array_index(section->links, 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++; }