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 /* Serialization and deserialization of filesystem data for storing to
26 * persistent storage. */
27 void bluesky_serialize_superblock(GString *out, BlueSkyFS *fs);
28 BlueSkyFS *bluesky_deserialize_superblock(const gchar *buf);
29 void bluesky_serialize_inode(GString *out, BlueSkyInode *inode);
30 gboolean bluesky_deserialize_inode(BlueSkyInode *inode, const gchar *buf);
32 /* Storage layer. Requests can be performed asynchronously, so these objects
33 * help keep track of operations in progress. */
39 STORE_OP_BARRIER, // Waits for other selected operations to complete
43 ASYNC_NEW, // Operation not yet submitted to storage layer
44 ASYNC_PENDING, // Submitted to storage layer
45 ASYNC_RUNNING, // Operation is in progress
46 ASYNC_COMPLETE, // Operation finished, results available
49 struct BlueSkyNotifierList;
50 typedef struct _BlueSkyStoreAsync BlueSkyStoreAsync;
51 struct _BlueSkyStoreAsync {
55 GCond *completion_cond; /* Used to wait for operation to complete. */
57 gint refcount; /* Reference count for destruction. */
59 BlueSkyAsyncStatus status;
62 gchar *key; /* Key to read/write */
63 BlueSkyRCStr *data; /* Data read/to write */
65 int result; /* Result code; 0 for success. */
66 struct BlueSkyNotifierList *notifiers;
69 /* The barrier waiting on this operation. Support for more than one
70 * barrier for a single async is not well-supported and should be avoided
72 BlueSkyStoreAsync *barrier;
74 bluesky_time_hires start_time; /* Time operation was submitted. */
75 bluesky_time_hires exec_time; /* Time processing started on operation. */
77 gpointer store_private; /* For use by the storage implementation */
80 /* Support for notification lists. These are lists of one-shot functions which
81 * can be called when certain events--primarily, competed storage
82 * events--occur. Multiple notifiers can be added, but no particular order is
83 * guaranteed for the notification functions to be called. */
84 struct BlueSkyNotifierList {
85 struct BlueSkyNotifierList *next;
87 BlueSkyStoreAsync *async;
88 gpointer user_data; // Passed to the function when called
91 /* The abstraction layer for storage, allowing multiple implementations. */
93 /* Create a new store instance and return a handle to it. */
94 gpointer (*create)(const gchar *path);
96 /* Clean up any resources used by this store. */
97 void (*destroy)(gpointer store);
99 /* Submit an operation (get/put/delete) to the storage layer to be
100 * performed asynchronously. */
101 void (*submit)(gpointer store, BlueSkyStoreAsync *async);
103 /* Clean up any implementation-private data in a BlueSkyStoreAsync. */
104 void (*cleanup)(gpointer store, BlueSkyStoreAsync *async);
105 } BlueSkyStoreImplementation;
107 void bluesky_store_register(const BlueSkyStoreImplementation *impl,
110 BlueSkyStoreAsync *bluesky_store_async_new(BlueSkyStore *store);
111 gpointer bluesky_store_async_get_handle(BlueSkyStoreAsync *async);
112 void bluesky_store_async_ref(BlueSkyStoreAsync *async);
113 void bluesky_store_async_unref(BlueSkyStoreAsync *async);
114 void bluesky_store_async_wait(BlueSkyStoreAsync *async);
115 void bluesky_store_async_add_notifier(BlueSkyStoreAsync *async,
116 GFunc func, gpointer user_data);
117 void bluesky_store_async_mark_complete(BlueSkyStoreAsync *async);
118 void bluesky_store_async_submit(BlueSkyStoreAsync *async);
119 void bluesky_store_sync(BlueSkyStore *store);
121 void bluesky_store_add_barrier(BlueSkyStoreAsync *barrier,
122 BlueSkyStoreAsync *async);
124 void bluesky_inode_start_sync(BlueSkyInode *inode, BlueSkyStoreAsync *barrier);
126 void bluesky_block_touch(BlueSkyInode *inode, uint64_t i);
127 void bluesky_block_fetch(BlueSkyFS *fs, BlueSkyBlock *block,
128 BlueSkyStoreAsync *barrier);
129 void bluesky_block_flush(BlueSkyFS *fs, BlueSkyBlock *block,
130 BlueSkyStoreAsync *barrier);
131 void bluesky_file_flush(BlueSkyInode *inode, BlueSkyStoreAsync *barrier);
132 void bluesky_file_drop_cached(BlueSkyInode *inode);