int location_flags;
int pending_read, pending_write;
+ // If the object is not yet flushed to cloud storage but is written to a
+ // journal file locally, a reference to that journal file so that we can
+ // keep the dirty_refs count updated. When the object is deleted or
+ // becomes clean, decrement the dirty_refs counter of the journal file and
+ // set this pointer to NULL.
+ BlueSkyCacheFile *dirty_journal;
+
// A stable identifier for the object (only changes when authenticated data
// is written out, but stays the same when the in-cloud cleaner relocates
// the object).
uint32_t crc32c_finalize(uint32_t crc);
struct _BlueSkyLog {
+ BlueSkyFS *fs;
char *log_directory;
GAsyncQueue *queue;
int fd, dirfd;
int seq_num;
GSList *committed;
+ /* The currently-open log file. */
+ BlueSkyCacheFile *current_log;
+
/* Cache of log segments which have been memory-mapped. */
GMutex *mmap_lock;
GHashTable *mmap_cache;
size_t len;
BlueSkyFS *fs;
BlueSkyLog *log;
- gboolean fetching, ready;
+ gboolean fetching, ready; // Cloud data: downloading or ready for use
int64_t atime; // Access time, for cache management
+
+ /* Journal: Count of objects which are not yet committed to cloud storage
+ * but need to be; a non-zero value prevents the journal file from being
+ * deleted. */
+ gint dirty_refs;
};
BlueSkyLog *bluesky_log_new(const char *log_directory);
BlueSkyRCStr *bluesky_log_map_object(BlueSkyFS *fs, int log_dir, int log_seq,
int log_offset, int log_size);
void bluesky_mmap_unref(BlueSkyCacheFile *mmap);
+void bluesky_cachefile_unref(BlueSkyCacheFile *cachefile);
+BlueSkyCacheFile *bluesky_cachefile_lookup(BlueSkyFS *fs,
+ int clouddir, int log_seq);
void bluesky_cachefile_gc(BlueSkyFS *fs);
#ifdef __cplusplus