3 * Copyright (C) 2007-2009 Andre Noll <maan@tuebingen.mpg.de>
5 * Licensed under the GPL v2. For licencing details see COPYING.
8 /* User interface for the object storage layer. */
13 /* Export all declarations in this file. */
14 #pragma GCC visibility push(default)
19 «Describes an object of the object storage layer.»,
22 «void *data», «Pointer to the data of the object.»,
23 «size_t size», «The object's size.»
29 «Flags that change the internal handling of osl tables.»,
32 «OSL_LARGE_TABLE = 1»,
33 «This table will have many rows.»
39 «The three different types of storage for an osl column.»,
43 «All data for this column is stored in one file which gets mmapped
44 by osl_open_table(). This is suitable for columns that do not hold
48 «Each entry is stored on disk and is loaded on demand by
49 open_disk_object(). This is the preferable storage type for large
50 objects that need not be in memory all the time.»,
53 «Objects for columns of this type are volatile: They are only stored
54 in memory and are discarded when the table is closed.»
60 «Additional per-column flags.»,
64 «Build an rbtree for this column. This is only possible if the storage
65 type of the column is either OSL_MAPPED_STORAGE or OSL_NO_STORAGE. In
66 order to lookup objects in the table by using osl_get_row(), the
67 lookup column must have an associated rbtree.
69 See also: osl_storage_type, osl_get_row()»,
72 «The data for this column will have constant size.»,
75 «All values are different. Must be set if OSL_RBTREE is set.»,
78 «Do not free the data for this column (OSL_NO_STORAGE).»
84 «Opaque osl table structure.»
89 «Opaque osl row structure.»
93 «typedef int osl_compare_func(const struct osl_object *obj1, const struct osl_object *obj2)»,
94 «Comparator for rbtree nodes.»,
95 «To build an rbtree, a compare function for the objects must be
96 provided. This function takes pointers to the two objects to be
97 compared. It must return -1, zero, or 1, if the first argument is
98 considered to be respectively less than, equal to, or greater than
99 the second. If two members compare as equal, their order in the rbtree
104 «typedef int osl_rbtree_loop_func(struct osl_row *row, void *data)»,
105 «Loop callback function.»,
106 «The osl_rbreee_loop functions take a function pointer of this
107 type. For each node in the rbtree, the given function is called.
109 See also: osl_rbtree_loop(), osl_rbtree_loop_reverse().»
113 «struct osl_column_description»,
114 «Describes one column of an osl table.»,
116 «uint16_t storage_type»,
117 «One of the three possible types of storage. See also:
120 «uint16_t storage_flags»,
121 «Specifies further properties of the column. See also:
125 «The column name determines the name of the directory where all
126 data for this column will be stored. Its hash is stored in the table
127 header. This field is ignored if the storage type is NO_STORAGE.»,
129 «osl_compare_func *compare_function»,
130 «For columns with an associated rbtree, this must point to a function
131 that compares the values of two objects, either a built-in function
132 or a function defined by the application may be supplied. This field
133 is ignored if the column does not have an associated rbtree.
135 See also: osl_storage_flags, osl_compare_func»,
137 «uint32_t data_size»,
138 «If the OSL_FIXED_SIZE flag is set for this column, this value
139 describes the number of bytes of each object of this column. It is
140 ignored, if OSL_FIXED_SIZE is not set.»
145 «struct osl_table_description»,
146 «Describes one osl table.»,
147 «A pointer to the table description is passed to osl_create_table()
148 and osl_open_table(). The osl library calls which operate on an
149 open table refer to the fields of the table description through this
150 pointer. Hence the table description must not be modified or freed
151 before the table is closed.»,
155 «The directory which contains all files of this table. This may be
156 either relative to the cwd or an absolute path.»,
159 «The table name. A subdirectory of dir called name is created at
160 table creation time. It must be a valid name for a subdirectory.
161 In particular, no slashes are allowed in the name.»,
163 «uint16_t num_columns»,
164 «The number of columns of this table.»,
167 «Further table-wide information, see osl_table_flags.»,
169 «struct osl_column_description *column_descriptions»,
170 «The array describing the individual columns of the table.»
176 «Flags to be passed to osl_close_table().»,
179 «OSL_MARK_CLEAN = 1»,
180 «The table header contains a "dirty" flag which indicates whether the
181 table is currently held open by another process. The OSL_MARK_CLEAN
182 flag instructs libosl to clear the dirty flag when the table is
185 «OSL_FREE_VOLATILE = 2»,
186 «If the table contains columns of type OSL_NO_STORAGE and this flag
187 is passed to osl_close_table(), free(3) is called for each object of
188 each column of type OSL_NO_STORAGE.»
194 «Create a new osl table.»,
197 «const struct osl_table_description *desc»,
198 «Pointer to the table description»
207 «Open an osl table.»,
208 «An osl table must be opened before its data can be accessed.»,
210 «const struct osl_table_description *desc»,
211 «Describes the table to be opened»,
213 «struct osl_table **result»,
214 «Contains a pointer to the open table on success.»
216 «The table description given by desc should coincide with the
217 description used at creation time.»,
225 «Close an osl table.»,
228 «struct osl_table *t»,
229 «Pointer to the table to be closed.»,
231 «enum osl_close_flags flags»,
232 «Options for what should be cleaned up.»
234 «If osl_open_table() succeeds, the resulting table pointer must
235 later be passed to this function in order to flush all changes to
236 the file system and to free the resources that were allocated by
245 «Get the row that contains the given object.»,
248 «const struct osl_table *t»,
249 «Pointer to an open osl table»,
252 «The number of the column to be searched»,
254 «const struct osl_object *obj»,
255 «The object to be looked up»,
257 «struct osl_row **result»,
258 «Points to the row containing the given object»
260 «Lookup the given object and return the row containing it. The column
261 specified by col_num must have an associated rbtree.»,
264 «Standard. The result pointer is set to NULL if and only if the
265 function returns negative.»
270 «Retrieve an object identified by row and column.»,
273 «const struct osl_table *t»,
274 «Pointer to an open osl table»,
276 «const struct osl_row *row»,
277 «Pointer to the row»,
282 «struct osl_object *object»,
285 «The column determined by col_num must be of type OSL_MAPPED_STORAGE
286 or OSL_NO_STORAGE, i.e. no disk storage objects may be retrieved by
289 See also: osl_storage_type, osl_open_disk_object().»,
295 «osl_open_disk_object»,
296 «Retrieve an object of type OSL_DISK_STORAGE by row and column.»,
297 «For columns of type OSL_DISK_STORAGE this function must be
298 used to retrieve one of its containing objects. Afterwards,
299 osl_close_disk_object() must be called in order to deallocate the
303 «const struct osl_table *t»,
304 «Pointer to an open osl table»,
306 «const struct osl_row *r»,
307 «Pointer to the row containing the object»,
312 «struct osl_object *obj»,
313 «Points to the result upon successful return»
315 «See also: osl_get_object(), osl_storage_type,
316 osl_close_disk_object().»,
323 «osl_close_disk_object»,
324 «Free resources allocated during osl_open_disk_object().», «
326 «struct osl_object *obj»,
327 «Pointer to the object previously returned by open_disk_object()»
330 «int», «The return value of the underlying call to munmap(2)»
334 «osl_add_and_get_row»,
335 «Add a new row to an osl table and retrieve this row.»,
338 «struct osl_table *t»,
339 «Pointer to an open osl table»,
341 «struct osl_object *objects»,
342 «Array of objects to be added»,
344 «struct osl_row **row»,
347 «The objects parameter must point to an array containing one object
348 per column. The order of the objects in the array is given by the
349 table description of the table. Several sanity checks are performed
350 during object insertion and the function returns without modifying the
351 table if any of these tests fail. In fact, it is atomic in the sense
352 that it either succeeds or leaves the table unchanged (i.e. either
353 all or none of the objects are added to the table).
355 See also: struct osl_table_description, osl_compare_func,
364 «Add a new row to an osl table.»,
367 «struct osl_table *t»,
368 «Same meaning as osl_add_and_get_row()»,
370 «struct osl_object *objects»,
371 «Same meaning as osl_add_and_get_row()»
373 «This is equivalent to calling osl_add_and_get_row(t, objects,
377 «The return value of the underlying call to osl_add_and_get_row()»
382 «Delete a row from an osl table.»,
385 «struct osl_table *t»,
386 «Pointer to an open osl table»,
388 «struct osl_row *row»,
389 «Pointer to the row to delete»
391 «This removes all disk storage objects, removes all rbtree nodes,
392 and frees all volatile objects belonging to the given row. For mapped
393 columns, the data is merely marked invalid and may be pruned from
394 time to time by oslfsck(1).»,
402 «Loop over all nodes in an rbtree.»,
405 «const struct osl_table *t»,
406 «Pointer to an open osl table»,
409 «The column to use for iterating over the elements»,
411 «void *private_data»,
412 «Pointer that gets passed to the callback function»,
414 «osl_rbtree_loop_func *func»,
415 «This callback is called for each node in the rbtree.»
417 «This function does an in-order walk of the rbtree associated with
418 col_num. It is an error if the OSL_RBTREE flag is not set for this
419 column. For each node in the rbtree, the given function func is called
420 with two pointers as arguments: The first osl_row* argument points
421 to the row that contains the object corresponding to the rbtree node
422 currently traversed, and the private_data pointer is passed verbatim as
423 the second argument. The loop terminates either if the callback returns
424 a negative value, or if all nodes of the tree have been visited.»,
427 «Standard. If the termination of the loop was caused by the callback
428 returning a negative value, -E_OSL_LOOP is returned. This is the only
433 «osl_rbtree_loop_reverse»,
434 «Loop over all nodes in an rbtree in reverse order.»,
435 «This function is identical to osl_rbtree_loop(), the only difference
436 is that the tree is walked in reverse order.»,
438 «const struct osl_table *t»,
439 «See osl_rbtree_loop()»,
442 «See osl_rbtree_loop()»,
444 «void *private_data»,
445 «See osl_rbtree_loop()»,
447 «osl_rbtree_loop_func *func»,
448 «See osl_rbtree_loop()»
450 «See also: osl_rbtree_loop().»,
452 «The same return value as osl_rbtree_loop()»
457 «Change an object of an osl table.»,
460 «struct osl_table *t»,
461 «Pointer to an open osl table»,
463 «const struct osl_row *r»,
464 «Pointer to the row containing the object to be updated»,
467 «Number of the column containing the object to be updated»,
469 «struct osl_object *obj»,
470 «Pointer to the replacement object»
472 «This function gets rid of all references to the old object. This
473 includes removal of the rbtree node in case there is an rbtree
474 associated with col_num. It then inserts obj into the table and the
475 rbtree if necessary.»,
483 «Get the number of rows of the given table.»,
486 «const struct osl_table *t»,
487 «Pointer to an open osl table»,
489 «unsigned *num_rows»,
490 «Result is returned here»
492 «The number of rows returned excludes any invalid rows.»,
495 «Positive on success, -E_OSL_BAD_TABLE if t is NULL»
499 «osl_rbtree_first_row»,
500 «Get the row corresponding to the smallest rbtree node of a column.»,
503 «const struct osl_table *t»,
507 «The number of the rbtree column»,
509 «struct osl_row **result»,
510 «A pointer to the first row is returned here»
512 «The rbtree node of the smallest object (with respect to the
513 corresponding compare function) is selected and the row containing
514 this object is returned. It is an error if col_num refers to a column
515 without an associated rbtree.
517 See also: osl_get_nth_row(), osl_rbtree_last_row().»,
523 «osl_rbtree_last_row»,
524 «Get the row corresponding to the greatest rbtree node of a column.»,
525 «This function works just like osl_rbtree_first_row(), the only
526 difference is that the row containing the greatest rather than the
527 smallest object is returned.»,
530 «const struct osl_table *t»,
531 «See osl_rbtree_first_row()»,
534 «See osl_rbtree_first_row()»,
536 «struct osl_row **result»,
537 «See osl_rbtree_first_row()»
539 «See also: osl_get_nth_row(), osl_rbtree_first_row()»,
546 «Get the row with n-th greatest value.»,
549 «const struct osl_table *t»,
550 «Pointer to an open osl table»,
556 «The rank of the desired row»,
558 «struct osl_row **result»,
559 «Row is returned here»
561 «Retrieve the n-th order statistic with respect to the compare
562 function of the rbtree column col_num. In other words, get the row
563 with n-th greatest value in column col_num. It is an error if col_num
564 is not a rbtree column, or if n is larger than the number of rows in
573 «Get the rank of a row.»,
574 «The rank is, by definition, the position of the row in the linear
575 order determined by an in-order tree walk of the rbtree associated
576 with given column number.»,
579 «const struct osl_table *t»,
583 «The row to get the rank of»,
586 «The number of an rbtree column»,
591 «See also: osl_get_nth_row().»,
598 «Get a string describing the error code passed in the argument.»,
604 «This works just like strerror(3). The given number must be an osl
605 error code. The result must not be freed by the caller.»,
608 «The error text corresponding to an osl error code»
612 #pragma GCC visibility pop