Fix to the cleaner when writing out a new inode map.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Thu, 9 Dec 2010 20:12:04 +0000 (12:12 -0800)
committerMichael Vrable <mvrable@cs.ucsd.edu>
Thu, 9 Dec 2010 20:12:04 +0000 (12:12 -0800)
bluesky/cleaner.c
bluesky/log.c
cleaner/cleaner

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);
index 2e5c920..6475b5d 100644 (file)
@@ -443,14 +443,16 @@ BlueSkyCacheFile *bluesky_cachefile_lookup(BlueSkyFS *fs,
             ftruncate(fd, 5 << 20);     // FIXME
             close(fd);
         }
-
-        // If the log file is stored in the cloud, we may need to fetch it
-        if (clouddir >= 0 && start_fetch)
-            cloudlog_fetch_start(map);
     } else {
         g_mutex_lock(map->lock);
     }
 
+
+    /* If the log file is stored in the cloud and has not been fully fetched,
+     * we may need to initiate a fetch now. */
+    if (clouddir >= 0 && start_fetch && !map->complete && !map->fetching)
+        cloudlog_fetch_start(map);
+
     g_mutex_unlock(log->mmap_lock);
     if (map != NULL)
         g_atomic_int_inc(&map->refcount);
index b148b95..675819b 100755 (executable)
@@ -419,7 +419,7 @@ class InodeMap:
         for d in sorted(self.version_vector):
             new_checkpoint.data += struct.pack('<II', d, self.version_vector[d])
 
-        data = self.checkpoint_record.data[self.vvsize:]
+        data = self.checkpoint_record.data[self.vvsize + len(CHECKPOINT_MAGIC):]
         for i in range(len(data) // 16):
             (start, end) = struct.unpack_from("<QQ", data, 16*i)
 
@@ -510,8 +510,8 @@ def run_cleaner(backend, inode_map, log, repack_inodes=False):
         rewrite_inode(backend, inode_map, i, log, i in dirty_inode_data)
 
 if __name__ == '__main__':
-    #backend = S3Backend("mvrable-bluesky", cachedir=".")
-    backend = FileBackend(".")
+    backend = S3Backend("mvrable-bluesky", cachedir=".")
+    #backend = FileBackend(".")
     chkpt = load_checkpoint_record(backend)
     print backend.list()
     imap = InodeMap()