1bc68bb02SChiyoung Seo/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
27c0433f5SJung-Sang Ahn/*
3bc68bb02SChiyoung Seo *     Copyright 2010 Couchbase, Inc
4bc68bb02SChiyoung Seo *
5bc68bb02SChiyoung Seo *   Licensed under the Apache License, Version 2.0 (the "License");
6bc68bb02SChiyoung Seo *   you may not use this file except in compliance with the License.
7bc68bb02SChiyoung Seo *   You may obtain a copy of the License at
8bc68bb02SChiyoung Seo *
9bc68bb02SChiyoung Seo *       http://www.apache.org/licenses/LICENSE-2.0
10bc68bb02SChiyoung Seo *
11bc68bb02SChiyoung Seo *   Unless required by applicable law or agreed to in writing, software
12bc68bb02SChiyoung Seo *   distributed under the License is distributed on an "AS IS" BASIS,
13bc68bb02SChiyoung Seo *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14bc68bb02SChiyoung Seo *   See the License for the specific language governing permissions and
15bc68bb02SChiyoung Seo *   limitations under the License.
167c0433f5SJung-Sang Ahn */
177c0433f5SJung-Sang Ahn
187c0433f5SJung-Sang Ahn#ifndef _JSAHN_BLOCKCACHE_H
197c0433f5SJung-Sang Ahn#define _JSAHN_BLOCKCACHE_H
207c0433f5SJung-Sang Ahn
217c0433f5SJung-Sang Ahn#include "filemgr.h"
227c0433f5SJung-Sang Ahn
23f693a021SSundar Sridharan#ifdef __cplusplus
24f693a021SSundar Sridharanextern "C" {
25f693a021SSundar Sridharan#endif
26f693a021SSundar Sridharan
2758e43058SJung-Sang Ahntypedef enum {
2800a9594fSJung-Sang Ahn    BCACHE_REQ_CLEAN,
2900a9594fSJung-Sang Ahn    BCACHE_REQ_DIRTY
3058e43058SJung-Sang Ahn} bcache_dirty_t;
3158e43058SJung-Sang Ahn
327c0433f5SJung-Sang Ahnvoid bcache_init(int nblock, int blocksize);
337c0433f5SJung-Sang Ahnint bcache_read(struct filemgr *file, bid_t bid, void *buf);
3400a9594fSJung-Sang Ahnvoid bcache_invalidate_block(struct filemgr *file, bid_t bid);
3558e43058SJung-Sang Ahnint bcache_write(struct filemgr *file, bid_t bid, void *buf, bcache_dirty_t dirty);
36fa5a43c0SJung-Sang Ahnint bcache_write_partial(struct filemgr *file, bid_t bid, void *buf, size_t offset, size_t len);
37818cce61SJung-Sang Ahnvoid bcache_remove_dirty_blocks(struct filemgr *file);
38818cce61SJung-Sang Ahnvoid bcache_remove_clean_blocks(struct filemgr *file);
395f7821baSChiyoung Seobool bcache_remove_file(struct filemgr *file);
40cb0f0747SSundar Sridharanfdb_status bcache_flush(struct filemgr *file);
413d812dfcSJung-Sang Ahnvoid bcache_shutdown();
426a3a5c2dSJung-Sang Ahnuint64_t bcache_get_num_free_blocks();
4336b6ee04SJung-Sang Ahnvoid bcache_print_items();
443b3828dcSJung-Sang Ahnvoid bcache_update_file_status(struct filemgr *file, file_status_t status);
453b3828dcSJung-Sang Ahn
46f693a021SSundar Sridharan#ifdef __cplusplus
47f693a021SSundar Sridharan}
48f693a021SSundar Sridharan#endif
49f693a021SSundar Sridharan
507c0433f5SJung-Sang Ahn#endif