xref: /4.0.0/forestdb/src/blockcache.h (revision 5f7821ba)
1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 *     Copyright 2010 Couchbase, Inc
4 *
5 *   Licensed under the Apache License, Version 2.0 (the "License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 */
17
18#ifndef _JSAHN_BLOCKCACHE_H
19#define _JSAHN_BLOCKCACHE_H
20
21#include "filemgr.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27typedef enum {
28    BCACHE_REQ_CLEAN,
29    BCACHE_REQ_DIRTY
30} bcache_dirty_t;
31
32void bcache_init(int nblock, int blocksize);
33int bcache_read(struct filemgr *file, bid_t bid, void *buf);
34void bcache_invalidate_block(struct filemgr *file, bid_t bid);
35int bcache_write(struct filemgr *file, bid_t bid, void *buf, bcache_dirty_t dirty);
36int bcache_write_partial(struct filemgr *file, bid_t bid, void *buf, size_t offset, size_t len);
37void bcache_remove_dirty_blocks(struct filemgr *file);
38void bcache_remove_clean_blocks(struct filemgr *file);
39bool bcache_remove_file(struct filemgr *file);
40fdb_status bcache_flush(struct filemgr *file);
41void bcache_shutdown();
42uint64_t bcache_get_num_free_blocks();
43void bcache_print_items();
44void bcache_update_file_status(struct filemgr *file, file_status_t status);
45
46#ifdef __cplusplus
47}
48#endif
49
50#endif
51