Fix to the cleaner when writing out a new inode map.
[bluesky.git] / bluesky / cleaner.c
index b13983e..e2eccc5 100644 (file)
@@ -190,6 +190,10 @@ gboolean needs_merging(BlueSkyFS *fs, BlueSkyCloudPointer location)
     if (location.directory == BLUESKY_CLOUD_DIR_PRIMARY)
         return FALSE;
 
+    if (location.directory == BLUESKY_CLOUD_DIR_CLEANER
+        && location.sequence <= fs->log_state->latest_cleaner_seq_seen)
+        return FALSE;
+
     return TRUE;
 }
 
@@ -206,8 +210,8 @@ void bluesky_cleaner_merge(BlueSkyFS *fs)
     for (int i = 0; i < checkpoint->links->len; i++) {
         BlueSkyCleanerLink *link = &g_array_index(checkpoint->links,
                                                   BlueSkyCleanerLink, i);
-        /*if (!needs_merging(fs, link->location))
-            continue; */
+        if (!needs_merging(fs, link->location))
+            continue;
 
         BlueSkyCleanerItem *imap = cleaner_load_item(fs, link->location);
         if (imap == NULL) {
@@ -219,6 +223,8 @@ void bluesky_cleaner_merge(BlueSkyFS *fs)
         for (int j = 0; j < imap->links->len; j++) {
             BlueSkyCleanerLink *link = &g_array_index(imap->links,
                                                       BlueSkyCleanerLink, j);
+            if (!needs_merging(fs, link->location))
+                continue;
             BlueSkyCleanerItem *inode = cleaner_load_item(fs, link->location);
             if (inode != NULL) {
                 g_print("Got inode %"PRIu64"\n", inode->inum);