1/*
2 * Copyright (c) 2007, 2008, 2009, 2010, 2011, ETH Zurich.
3 * All rights reserved.
4 *
5 * This file is distributed under the terms in the attached LICENSE file.
6 * If you do not find this file, copies can be found by writing to:
7 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
8 */
9
10
11interface bfs "BFS interface" {
12
13/* -----------------------------------------------
14 * Typedefs and structs
15 */
16
17typedef uint64 object_key;
18typedef uint64 chunk_id;
19
20/* From BFS.h */
21typedef enum
22{
23	INVALID_OBJ,
24	BFS_FILE,
25	BFS_DIR
26}  OBJECT_TYPE;
27
28/* From servers.h */
29typedef enum {
30	INVALID_SERVER,
31	DIR_SERVER,
32	STORAGE_SERVER,
33	CLIENT,
34	NAME_SERVER
35} SERVER_TYPE;
36
37/* From DS.h */
38/*
39 * Object open permissions.
40 */
41typedef enum {
42	READ_ONLY,
43	WRITE_ONLY,
44	READ_WRITE
45} OBJECT_ACCESS_PERM;
46
47/* -----------------------------------------------
48 * Storage Server
49 * -----------------------------------------------
50 *
51 * Overview
52 * --------
53 * The storage server implements a log-structured data store,
54 * from which data can be read or written in terms of chunks.
55 * A chunk is a block of data of a specific size with a
56 * unique ID.  A client or directory server can read or
57 * write chunks from the storage by passing the ID of the chunk.
58 */
59
60/* XXX For now we pass the frame cap every time.
61   Not efficient but simple. */
62rpc ss_read_chunk(
63    in chunk_id cid,
64    in uint32   coffset,
65    in uint32   size,
66    in cap      frame,
67    in uint32   foffset);
68
69rpc ss_write_chunk(
70    in chunk_id cid,
71    in uint32   coffset,
72    in uint32   size,
73    in cap      frame,
74    in uint32   foffset);
75
76rpc ss_delete_chunk(
77    in chunk_id cid
78);
79
80message ss_shutdown();
81
82/* -----------------------------------------------
83 * Name Server
84 * -----------------------------------------------
85 *
86 * Overview
87 * --------
88 * The name server implements both a name service and a distributed
89 * lock service.  It keeps track of all the other servers running
90 * in the system, and manages the locking of common state for all
91 * instances the directory server.
92 */
93
94/* Dir and storage servers must register */
95message ns_register_server(uint32 server_type, uint64 server_guid);
96
97/* Servers can request list of currently registered servers */
98/* nb generation increments when the list changes. */
99rpc ns_query_registered_servers(in uint32 server_ordinal,
100    out uint32 generation,
101    out SERVER_TYPE server_type,
102    out uint64 server_guid);
103
104/* Lock/unlock invocations would be more naturally expressed
105 * as call/response with separate failure/success response
106 * messages.  Use RPC here just to simplify the async version.
107 */
108rpc ns_lock(/*in object_key objects*/
109    in object_key object
110    , out errval err);
111
112rpc ns_unlock(in object_key object, out errval err);
113
114/* -----------------------------------------------
115 * Directory Server
116 * -----------------------------------------------
117 *
118 * Overview
119 * --------
120 * The directory server manages the metadata of the file
121 * system on the storage servers and implements the file
122 * system interface for the clients.  It also maintains
123 * a simple data cache of file chunks.
124 *
125 * Multiple directory servers running at the same time
126 * will share common metadata structures and invoke
127 * locking operations on the name server as required.
128 */
129
130/* Create a file or directory.
131 * Returns the key of the object that was created.
132 */
133rpc ds_create(
134    in  OBJECT_TYPE         ob_type,
135    in  OBJECT_ACCESS_PERM  ob_perm,
136    in  String              ob_name[2048],
137    in  uint64              client_id,
138    out object_key          object);
139
140rpc ds_open(
141    in  OBJECT_TYPE         ob_type,
142    in  OBJECT_ACCESS_PERM  ob_perm,
143    in  String              ob_name[2048],
144    in  uint64	            client_id,
145    out object_key          object);
146
147message ds_shutdown();
148
149/* From name server. */
150message ds_invalidate_cache(object_key object);
151
152/* -----------------------------------------------
153 * State Maintenance
154 * -----------------------------------------------
155 * XXX TO DO: make the maintenance of replicated state
156 * be implicit via a consensus protocol.
157 *
158 * Name server can broadcast current list of servers
159 * to all SS and DS servers in the system.  This is a
160 * one-way notification.
161 */
162message ss_notify_registered_servers(uint64 server);
163message ds_notify_registered_servers(uint64 server);
164
165};
166
167