1 /* Blue Sky: File Systems in the Cloud
3 * Copyright (C) 2009 The Regents of the University of California
4 * Written by Michael Vrable <mvrable@cs.ucsd.edu>
9 /* Declarations internal to the BlueSky library. This header file should not
10 * be included by any users of the library (such as any filesystem
11 * proxy)--external users should only include bluesky.h. */
13 #ifndef _BLUESKY_PRIVATE_H
14 #define _BLUESKY_PRIVATE_H
22 /* TODO: Make this go away entirely. */
23 BlueSkyFS *bluesky_new_fs(gchar *name);
25 /* Linked list update functions for LRU lists. */
26 void bluesky_list_unlink(GList *head, GList *item);
27 GList *bluesky_list_prepend(GList *head, BlueSkyInode *inode);
28 GList *bluesky_list_append(GList *head, BlueSkyInode *inode);
29 BlueSkyInode *bluesky_list_head(GList *head);
30 BlueSkyInode *bluesky_list_tail(GList *head);
32 /* Serialization and deserialization of filesystem data for storing to
33 * persistent storage. */
34 void bluesky_serialize_superblock(GString *out, BlueSkyFS *fs);
35 BlueSkyFS *bluesky_deserialize_superblock(const gchar *buf);
36 void bluesky_serialize_inode(GString *out, BlueSkyInode *inode);
37 gboolean bluesky_deserialize_inode(BlueSkyInode *inode, const gchar *buf);
39 /* Storage layer. Requests can be performed asynchronously, so these objects
40 * help keep track of operations in progress. */
46 STORE_OP_BARRIER, // Waits for other selected operations to complete
50 ASYNC_NEW, // Operation not yet submitted to storage layer
51 ASYNC_PENDING, // Submitted to storage layer
52 ASYNC_RUNNING, // Operation is in progress
53 ASYNC_COMPLETE, // Operation finished, results available
56 struct BlueSkyNotifierList;
57 typedef struct _BlueSkyStoreAsync BlueSkyStoreAsync;
58 struct _BlueSkyStoreAsync {
62 GCond *completion_cond; /* Used to wait for operation to complete. */
64 gint refcount; /* Reference count for destruction. */
66 BlueSkyAsyncStatus status;
69 gchar *key; /* Key to read/write */
70 BlueSkyRCStr *data; /* Data read/to write */
72 int result; /* Result code; 0 for success. */
73 struct BlueSkyNotifierList *notifiers;
76 /* The barrier waiting on this operation. Support for more than one
77 * barrier for a single async is not well-supported and should be avoided
79 BlueSkyStoreAsync *barrier;
81 bluesky_time_hires start_time; /* Time operation was submitted. */
82 bluesky_time_hires exec_time; /* Time processing started on operation. */
84 gpointer store_private; /* For use by the storage implementation */
87 /* Support for notification lists. These are lists of one-shot functions which
88 * can be called when certain events--primarily, competed storage
89 * events--occur. Multiple notifiers can be added, but no particular order is
90 * guaranteed for the notification functions to be called. */
91 struct BlueSkyNotifierList {
92 struct BlueSkyNotifierList *next;
94 BlueSkyStoreAsync *async;
95 gpointer user_data; // Passed to the function when called
98 /* The abstraction layer for storage, allowing multiple implementations. */
100 /* Create a new store instance and return a handle to it. */
101 gpointer (*create)(const gchar *path);
103 /* Clean up any resources used by this store. */
104 void (*destroy)(gpointer store);
106 /* Submit an operation (get/put/delete) to the storage layer to be
107 * performed asynchronously. */
108 void (*submit)(gpointer store, BlueSkyStoreAsync *async);
110 /* Clean up any implementation-private data in a BlueSkyStoreAsync. */
111 void (*cleanup)(gpointer store, BlueSkyStoreAsync *async);
112 } BlueSkyStoreImplementation;
114 void bluesky_store_register(const BlueSkyStoreImplementation *impl,
117 BlueSkyStoreAsync *bluesky_store_async_new(BlueSkyStore *store);
118 gpointer bluesky_store_async_get_handle(BlueSkyStoreAsync *async);
119 void bluesky_store_async_ref(BlueSkyStoreAsync *async);
120 void bluesky_store_async_unref(BlueSkyStoreAsync *async);
121 void bluesky_store_async_wait(BlueSkyStoreAsync *async);
122 void bluesky_store_async_add_notifier(BlueSkyStoreAsync *async,
123 GFunc func, gpointer user_data);
124 void bluesky_store_async_mark_complete(BlueSkyStoreAsync *async);
125 void bluesky_store_async_submit(BlueSkyStoreAsync *async);
126 void bluesky_store_sync(BlueSkyStore *store);
128 void bluesky_store_add_barrier(BlueSkyStoreAsync *barrier,
129 BlueSkyStoreAsync *async);
131 void bluesky_inode_start_sync(BlueSkyInode *inode, BlueSkyStoreAsync *barrier);
133 void bluesky_block_touch(BlueSkyInode *inode, uint64_t i);
134 void bluesky_block_fetch(BlueSkyFS *fs, BlueSkyBlock *block,
135 BlueSkyStoreAsync *barrier);
136 void bluesky_block_flush(BlueSkyFS *fs, BlueSkyBlock *block,
137 BlueSkyStoreAsync *barrier);
138 void bluesky_file_flush(BlueSkyInode *inode, BlueSkyStoreAsync *barrier);
139 void bluesky_file_drop_cached(BlueSkyInode *inode);