1 /* Blue Sky: File Systems in the Cloud
3 * Copyright (C) 2010 The Regents of the University of California
4 * Written by Michael Vrable <mvrable@cs.ucsd.edu>
16 #include "bluesky-private.h"
18 /* Proxy component of the file system cleaner. This consists effectively of
19 * code for merging multiple versions of the file system logs: that generated
20 * by us and that generated by the in-cloud cleaner. Other logic, such as for
21 * rewriting log segments where needed and deleting old segments, is handled by
22 * the in-cloud cleaner component. */
24 /* Check the cleaner's logs to find the a more recent checkpoint record. This
25 * should be called occasionally to see if the cleaner has done any work since
27 void bluesky_cleaner_find_checkpoint(BlueSkyFS *fs)
29 char *prefix = g_strdup_printf("log-%08d", BLUESKY_CLOUD_DIR_CLEANER);
30 char *last_segment = bluesky_store_lookup_last(fs->store, prefix);
32 if (last_segment == NULL)
35 g_print("Last cloud log segment: %s\n", last_segment);
36 int seq = atoi(last_segment + 13);
39 if (seq <= fs->log_state->latest_cleaner_seq_seen)
42 g_print("New log segment appeared in cleaner directory: %d\n", seq);
44 BlueSkyCacheFile *cachefile;
45 cachefile = bluesky_cachefile_lookup(fs, BLUESKY_CLOUD_DIR_CLEANER, seq,
47 while (!cachefile->complete)
48 g_cond_wait(cachefile->cond, cachefile->lock);
50 g_print("Downloaded latest cleaner segment.\n");
52 int64_t offset = -1, length = 0;
54 const BlueSkyRangesetItem *item;
55 item = bluesky_rangeset_lookup_next(cachefile->items, offset + 1);
59 length = item->length;
63 g_print("Last object: %"PRIu64" + %"PRIu64"\n", offset, length);
66 bluesky_cachefile_unref(cachefile);
67 g_mutex_unlock(cachefile->lock);