From: Michael Vrable Date: Tue, 19 Oct 2010 01:05:50 +0000 (-0700) Subject: Fix up cloud log state counting. X-Git-Url: http://git.vrable.net/?p=bluesky.git;a=commitdiff_plain;h=c4224e520e4bc28d5546cd55417cd1065655b6ec Fix up cloud log state counting. Counts of cloud log items in various states were not being kept up to date, so that the counts were often wrong. Fix a few cases to make the counts more accurate. --- diff --git a/bluesky/cache.c b/bluesky/cache.c index d1c5c84..1f10ca3 100644 --- a/bluesky/cache.c +++ b/bluesky/cache.c @@ -287,6 +287,12 @@ static gpointer flushd_task(BlueSkyFS *fs) bluesky_cachefile_gc(fs); g_mutex_unlock(fs->flushd_lock); + g_print("\nCloudlog cache: %d dirty, %d writeback, %d journal, %d cloud\n", + g_atomic_int_get(&fs->cache_log_dirty), + g_atomic_int_get(&fs->cache_log_writeback), + g_atomic_int_get(&fs->cache_log_journal), + g_atomic_int_get(&fs->cache_log_cloud)); + return NULL; } diff --git a/bluesky/cloudlog.c b/bluesky/cloudlog.c index 142104f..9d5333f 100644 --- a/bluesky/cloudlog.c +++ b/bluesky/cloudlog.c @@ -282,6 +282,7 @@ void bluesky_cloudlog_fetch(BlueSkyCloudLog *log) * Once that is done, we can fall through the case of remapping the data * itself. */ if (log->type == LOGTYPE_UNKNOWN) { + bluesky_cloudlog_stats_update(log, -1); BlueSkyRCStr *raw = NULL; if ((log->location_flags | log->pending_write) & CLOUDLOG_JOURNAL) { raw = bluesky_log_map_object(log->fs, -1, log->log_seq, @@ -300,6 +301,7 @@ void bluesky_cloudlog_fetch(BlueSkyCloudLog *log) g_assert(raw != NULL); bluesky_deserialize_cloudlog(log, raw->data, raw->len); bluesky_string_unref(raw); + bluesky_cloudlog_stats_update(log, 1); } /* At this point all metadata should be available and we need only remap diff --git a/bluesky/imap.c b/bluesky/imap.c index 9036263..ec27d43 100644 --- a/bluesky/imap.c +++ b/bluesky/imap.c @@ -154,6 +154,7 @@ static void bluesky_inode_map_serialize_section(BlueSkyFS *fs, log->data = bluesky_string_new_from_gstring(buf); bluesky_cloudlog_unref(range->serialized); range->serialized = log; + bluesky_cloudlog_stats_update(log, 1); } BlueSkyCloudLog *bluesky_inode_map_serialize(BlueSkyFS *fs) @@ -182,6 +183,7 @@ BlueSkyCloudLog *bluesky_inode_map_serialize(BlueSkyFS *fs) } log->data = bluesky_string_new_from_gstring(buf); + bluesky_cloudlog_stats_update(log, 1); if (updated) { return log; @@ -327,6 +329,7 @@ gboolean bluesky_checkpoint_load(BlueSkyFS *fs) commit->location.offset = checkpoint - last->data; commit->location.size = checkpoint_size; g_mutex_unlock(commit->lock); + bluesky_cloudlog_stats_update(commit, 1); bluesky_inode_map_deserialize(fs, commit); bluesky_cloudlog_unref(commit); diff --git a/bluesky/log.c b/bluesky/log.c index e5f0321..f52ac01 100644 --- a/bluesky/log.c +++ b/bluesky/log.c @@ -310,6 +310,7 @@ BlueSkyCloudLog *bluesky_log_get_commit_point(BlueSkyFS *fs) BlueSkyCloudLog *marker = bluesky_cloudlog_new(fs, NULL); marker->type = LOGTYPE_JOURNAL_MARKER; marker->data = bluesky_string_new(g_strdup(""), 0); + bluesky_cloudlog_stats_update(marker, 1); bluesky_cloudlog_sync(marker); g_mutex_lock(marker->lock); @@ -332,6 +333,7 @@ void bluesky_log_write_commit_point(BlueSkyFS *fs, BlueSkyCloudLog *marker) g_string_append_len(loc, (const gchar *)&seq, sizeof(seq)); g_string_append_len(loc, (const gchar *)&offset, sizeof(offset)); commit->data = bluesky_string_new_from_gstring(loc); + bluesky_cloudlog_stats_update(commit, 1); bluesky_cloudlog_sync(commit); g_mutex_lock(commit->lock);