IDZEBRA
2.2.7
|
Zebra Block File Layer. More...
Go to the source code of this file.
Typedefs | |
typedef struct BFiles_struct * | BFiles |
A collection of BFile(s). More... | |
typedef struct BFile_struct * | BFile |
A Block File. More... | |
Functions | |
BFiles | bfs_create (const char *spec, const char *base) |
creates a Block files collection More... | |
void | bfs_destroy (BFiles bfiles) |
destroys a block files handle More... | |
void | bf_close (BFile bf) |
closes a Block file (may call exit) More... | |
int | bf_close2 (BFile bf) |
closes a Block file More... | |
BFile | bf_open (BFiles bfs, const char *name, int block_size, int wflag) |
opens and returns a Block file handle More... | |
int | bf_read (BFile bf, zint no, int offset, int nbytes, void *buf) |
read from block file (may call exit) More... | |
int | bf_read2 (BFile bf, zint no, int offset, int nbytes, void *buf) ZEBRA_GCC_ATTR((warn_unused_result)) |
read from block file More... | |
int | bf_write (BFile bf, zint no, int offset, int nbytes, const void *buf) |
writes block of bytes to file (may call exit) More... | |
int | bf_write2 (BFile bf, zint no, int offset, int nbytes, const void *buf) ZEBRA_GCC_ATTR((warn_unused_result)) |
writes block of bytes to file More... | |
ZEBRA_RES | bf_cache (BFiles bfs, const char *spec) |
enables or disables shadow for block files More... | |
int | bf_commitExists (BFiles bfs) |
Check if there is content in shadow area (to be committed). More... | |
int | bf_commitExec (BFiles bfs) ZEBRA_GCC_ATTR((warn_unused_result)) |
Executes commit operation. More... | |
void | bf_commitClean (BFiles bfs, const char *spec) |
Cleans shadow files (remove them) More... | |
void | bf_reset (BFiles bfs) |
Removes register and shadow completely. More... | |
int | bfs_register_directory_stat (BFiles bfs, int no, const char **directory, double *used_bytes, double *max_bytes) |
int | bfs_shadow_directory_stat (BFiles bfs, int no, const char **directory, double *used_bytes, double *max_bytes) |
Zebra Block File Layer.
Providers an interface to a file system , AKA persistent storage. The interface allows safe updates - using a shadow file facility.
Definition in file bfile.h.
enables or disables shadow for block files
bfs | block files |
spec | such as "shadow:100M /other:200M"; or NULL to disable |
ZEBRA_OK | successful. spec is OK |
ZEBRA_FAIL | failure. |
Definition at line 95 of file bfile.c.
References BFiles_struct::base, BFiles_struct::cache_fname, BFiles_struct::commit_area, MFile_area_struct::dirs, mf_init(), mf_dir::name, ZEBRA_FAIL, and ZEBRA_OK.
Referenced by bf_commitClean(), tst(), zebra_commit_ex(), zebra_init(), and zebra_register_open().
void bf_close | ( | BFile | bf | ) |
closes a Block file (may call exit)
bf | block file |
Definition at line 139 of file bfile.c.
References bf_close2(), and zebra_exit().
Referenced by bf_open(), dict_bf_close(), isamb_close(), isamc_close(), isams_close(), rec_close(), recindex_close(), tst(), zebra_sort_close(), and zebra_sort_type().
int bf_close2 | ( | BFile | bf | ) |
closes a Block file
bf | block file |
0 | success |
-1 | failure |
Definition at line 121 of file bfile.c.
References BFile_struct::cf, cf_close(), BFile_struct::mf, mf_close(), BFile_struct::rdwr_lock, and zebra_lock_rdwr_destroy().
Referenced by bf_close().
void bf_commitClean | ( | BFiles | bfs, |
const char * | spec | ||
) |
Cleans shadow files (remove them)
bfs | block files |
spec | shadow specification |
Definition at line 321 of file bfile.c.
References bf_cache(), BFiles_struct::commit_area, mf_reset(), and unlink_cache().
Referenced by zebra_commit_ex(), and zebra_end_transaction().
int bf_commitExec | ( | BFiles | bfs | ) |
Executes commit operation.
bfs | block files |
Definition at line 277 of file bfile.c.
References cf_close(), cf_commit(), cf_open(), BFiles_struct::commit_area, inf, mf_close(), mf_open(), open_cache(), and BFiles_struct::register_area.
Referenced by zebra_commit_ex().
int bf_commitExists | ( | BFiles | bfs | ) |
Check if there is content in shadow area (to be committed).
bfs | block files |
1 | there is content in shadow area |
0 | no content in shadow area |
Definition at line 255 of file bfile.c.
References inf, and open_cache().
Referenced by zebra_commit_ex().
opens and returns a Block file handle
bfs | block files |
name | filename |
block_size | block size in bytes |
wflag | 1=opened for read&write, 0=read only |
0 | success |
-1 | failure (can never happen as the code is now) |
Definition at line 150 of file bfile.c.
References bf_close(), BFile_struct::block_size, BFiles_struct::cache_fname, BFile_struct::cf, cf_open(), BFiles_struct::commit_area, BFile_struct::mf, mf_open(), open_cache(), outf, BFile_struct::rdwr_lock, BFiles_struct::register_area, and zebra_lock_rdwr_init().
Referenced by dict_bf_open(), isamb_open2(), isamc_open(), isams_open(), rec_open(), recindex_open(), tst(), and zebra_sort_type().
read from block file (may call exit)
bf | block file handle |
no | block no (first block is 0, second is 1..) |
offset | offset within block to be read |
nbytes | number of bytes to read (0 for whole block) |
buf | raw bytes with content (at least nbytes of size) |
1 | whole block could be read |
0 | whole block could not be read |
Definition at line 205 of file bfile.c.
References bf_read2(), and zebra_exit().
Referenced by alloc_block(), cache_block(), dict_bf_readp(), isamb_open2(), isamc_open(), isamc_read_block(), isams_open(), isams_pp_open(), isams_read_item(), new_block(), open_block(), rec_get_int(), rec_prstat(), rec_release_blocks(), rec_write_tmp_buf(), recindex_read_head(), recindex_read_indx(), tst(), zebra_sort_read(), and zebra_sort_type().
read from block file
bf | block file handle |
no | block no (first block is 0, second is 1..) |
offset | offset within block to be read |
nbytes | number of bytes to read (0 for whole block) |
buf | raw bytes with content (at least nbytes of size) |
1 | whole block could be read |
0 | whole block could not be read |
-1 | error |
Definition at line 216 of file bfile.c.
References BFile_struct::cf, cf_read(), BFile_struct::mf, mf_read(), BFile_struct::rdwr_lock, zebra_lock_rdwr_rlock(), and zebra_lock_rdwr_runlock().
Referenced by bf_read().
void bf_reset | ( | BFiles | bfs | ) |
Removes register and shadow completely.
bfs | block files |
Definition at line 268 of file bfile.c.
References BFiles_struct::commit_area, mf_reset(), BFiles_struct::register_area, and unlink_cache().
Referenced by main(), tst(), and zebra_init().
writes block of bytes to file (may call exit)
bf | block file handle |
no | block no |
offset | within block |
nbytes | number of bytes to write |
buf | buffer to write |
0 | success (block could be written) |
This function can not return a failure. System calls exit(1) if write failed.
Definition at line 232 of file bfile.c.
References bf_write2(), and zebra_exit().
Referenced by cache_block(), close_block(), dict_bf_flush_blocks(), flush_blocks(), isamb_close(), isamc_close(), isamc_merge(), isamc_write_block(), isams_close(), isams_merge(), rec_release_blocks(), rec_write_tmp_buf(), recindex_write_head(), recindex_write_indx(), release_block(), tst(), zebra_sort_add(), and zebra_sort_delete().
writes block of bytes to file
bf | block file handle |
no | block no |
offset | within block |
nbytes | number of bytes to write |
buf | buffer to write |
0 | success (block written) |
-1 | error |
This function can not return a failure. System calls exit(1) if write failed.
Definition at line 243 of file bfile.c.
References BFile_struct::cf, cf_write(), BFile_struct::mf, mf_write(), BFile_struct::rdwr_lock, zebra_lock_rdwr_wlock(), and zebra_lock_rdwr_wunlock().
Referenced by bf_write().
BFiles bfs_create | ( | const char * | spec, |
const char * | base | ||
) |
creates a Block files collection
spec | register specification , e.g. "d1:100M d2:1G" |
base | base directory for register spec (if that is relative path) |
Definition at line 56 of file bfile.c.
References BFiles_struct::base, bfs_destroy(), BFiles_struct::cache_fname, BFiles_struct::commit_area, mf_init(), and BFiles_struct::register_area.
Referenced by main(), tst(), zebra_commit_ex(), zebra_compact(), zebra_end_transaction(), zebra_init(), and zebra_register_open().
void bfs_destroy | ( | BFiles | bfiles | ) |
destroys a block files handle
bfiles | block files handle |
The files in the block files collection are not deleted. Only the handle is freed.
Definition at line 73 of file bfile.c.
References BFiles_struct::base, BFiles_struct::cache_fname, BFiles_struct::commit_area, mf_destroy(), and BFiles_struct::register_area.
Referenced by bfs_create(), main(), tst(), zebra_commit_ex(), zebra_compact(), zebra_end_transaction(), zebra_init(), zebra_register_close(), and zebra_register_open().
int bfs_register_directory_stat | ( | BFiles | bfs, |
int | no, | ||
const char ** | directory, | ||
double * | used_bytes, | ||
double * | max_bytes | ||
) |
Definition at line 338 of file bfile.c.
References mf_area_directory_stat(), and BFiles_struct::register_area.
Referenced by show_bfs_stats().
int bfs_shadow_directory_stat | ( | BFiles | bfs, |
int | no, | ||
const char ** | directory, | ||
double * | used_bytes, | ||
double * | max_bytes | ||
) |
Definition at line 346 of file bfile.c.
References BFiles_struct::commit_area, and mf_area_directory_stat().
Referenced by show_bfs_stats().