+/* Return a committed cloud log record that can be used as a watermark for how
+ * much of the journal has been written. */
+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_sync(marker);
+
+ g_mutex_lock(marker->lock);
+ while ((marker->pending_write & CLOUDLOG_JOURNAL))
+ g_cond_wait(marker->cond, marker->lock);
+ g_mutex_unlock(marker->lock);
+
+ return marker;
+}
+
+void bluesky_log_write_commit_point(BlueSkyFS *fs, BlueSkyCloudLog *marker)
+{
+ BlueSkyCloudLog *commit = bluesky_cloudlog_new(fs, NULL);
+ commit->type = LOGTYPE_JOURNAL_CHECKPOINT;
+
+ uint32_t seq, offset;
+ seq = GUINT32_TO_LE(marker->log_seq);
+ offset = GUINT32_TO_LE(marker->log_offset);
+ GString *loc = g_string_new("");
+ 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_sync(commit);
+
+ g_mutex_lock(commit->lock);
+ while ((commit->pending_write & CLOUDLOG_JOURNAL))
+ g_cond_wait(commit->cond, commit->lock);
+ g_mutex_unlock(commit->lock);
+
+ bluesky_cloudlog_unref(marker);
+ bluesky_cloudlog_unref(commit);
+}
+