2007-04-25 12:07:30 +00:00
|
|
|
/*
|
2008-01-13 17:18:29 +00:00
|
|
|
* Copyright 2004-2008, Haiku Inc. All Rights Reserved.
|
2004-11-12 16:35:24 +00:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
|
*/
|
2004-09-04 17:15:22 +00:00
|
|
|
#ifndef _FS_CACHE_H
|
|
|
|
|
#define _FS_CACHE_H
|
|
|
|
|
|
2007-07-05 14:48:16 +00:00
|
|
|
/*! File System File and Block Caches */
|
2007-04-25 12:07:30 +00:00
|
|
|
|
2004-09-04 17:15:22 +00:00
|
|
|
|
|
|
|
|
#include <fs_interface.h>
|
|
|
|
|
|
|
|
|
|
|
2008-01-13 17:18:29 +00:00
|
|
|
enum {
|
|
|
|
|
TRANSACTION_WRITTEN,
|
|
|
|
|
TRANSACTION_ABORTED,
|
|
|
|
|
TRANSACTION_ENDED
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef void (*transaction_notification_hook)(int32 id, int32 event,
|
|
|
|
|
void *data);
|
2004-11-10 01:57:38 +00:00
|
|
|
|
2004-09-04 17:15:22 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-11-10 01:57:38 +00:00
|
|
|
/* transactions */
|
2004-11-19 20:23:58 +00:00
|
|
|
extern int32 cache_start_transaction(void *_cache);
|
|
|
|
|
extern status_t cache_sync_transaction(void *_cache, int32 id);
|
2007-02-24 23:05:18 +00:00
|
|
|
extern status_t cache_end_transaction(void *_cache, int32 id,
|
|
|
|
|
transaction_notification_hook hook, void *data);
|
2004-11-19 20:23:58 +00:00
|
|
|
extern status_t cache_abort_transaction(void *_cache, int32 id);
|
2007-02-24 23:05:18 +00:00
|
|
|
extern int32 cache_detach_sub_transaction(void *_cache, int32 id,
|
|
|
|
|
transaction_notification_hook hook, void *data);
|
2004-11-19 20:23:58 +00:00
|
|
|
extern status_t cache_abort_sub_transaction(void *_cache, int32 id);
|
|
|
|
|
extern status_t cache_start_sub_transaction(void *_cache, int32 id);
|
2008-01-13 17:18:29 +00:00
|
|
|
extern status_t cache_add_transaction_listener(void *_cache, int32 id,
|
|
|
|
|
transaction_notification_hook hook, void *data);
|
|
|
|
|
extern status_t cache_remove_transaction_listener(void *_cache, int32 id,
|
|
|
|
|
transaction_notification_hook hook, void *data);
|
2007-02-24 23:05:18 +00:00
|
|
|
extern status_t cache_next_block_in_transaction(void *_cache, int32 id,
|
2008-01-18 17:07:18 +00:00
|
|
|
bool mainOnly, long *_cookie, off_t *_blockNumber,
|
|
|
|
|
void **_data, void **_unchangedData);
|
2005-10-19 16:46:17 +00:00
|
|
|
extern int32 cache_blocks_in_transaction(void *_cache, int32 id);
|
2008-01-18 17:07:18 +00:00
|
|
|
extern int32 cache_blocks_in_main_transaction(void *_cache, int32 id);
|
2005-10-19 16:46:17 +00:00
|
|
|
extern int32 cache_blocks_in_sub_transaction(void *_cache, int32 id);
|
2004-11-10 01:57:38 +00:00
|
|
|
|
|
|
|
|
/* block cache */
|
|
|
|
|
extern void block_cache_delete(void *_cache, bool allowWrites);
|
2007-02-24 23:05:18 +00:00
|
|
|
extern void *block_cache_create(int fd, off_t numBlocks, size_t blockSize,
|
|
|
|
|
bool readOnly);
|
2004-11-10 01:57:38 +00:00
|
|
|
extern status_t block_cache_sync(void *_cache);
|
2007-04-25 12:07:30 +00:00
|
|
|
extern status_t block_cache_sync_etc(void *_cache, off_t blockNumber,
|
|
|
|
|
size_t numBlocks);
|
2007-02-24 23:05:18 +00:00
|
|
|
extern status_t block_cache_make_writable(void *_cache, off_t blockNumber,
|
|
|
|
|
int32 transaction);
|
|
|
|
|
extern void *block_cache_get_writable_etc(void *_cache, off_t blockNumber,
|
|
|
|
|
off_t base, off_t length, int32 transaction);
|
|
|
|
|
extern void *block_cache_get_writable(void *_cache, off_t blockNumber,
|
|
|
|
|
int32 transaction);
|
|
|
|
|
extern void *block_cache_get_empty(void *_cache, off_t blockNumber,
|
|
|
|
|
int32 transaction);
|
|
|
|
|
extern const void *block_cache_get_etc(void *_cache, off_t blockNumber,
|
|
|
|
|
off_t base, off_t length);
|
2004-11-10 01:57:38 +00:00
|
|
|
extern const void *block_cache_get(void *_cache, off_t blockNumber);
|
2007-02-24 23:05:18 +00:00
|
|
|
extern status_t block_cache_set_dirty(void *_cache, off_t blockNumber,
|
|
|
|
|
bool isDirty, int32 transaction);
|
2004-11-10 01:57:38 +00:00
|
|
|
extern void block_cache_put(void *_cache, off_t blockNumber);
|
|
|
|
|
|
2004-09-04 17:15:22 +00:00
|
|
|
/* file cache */
|
2007-11-10 21:19:52 +00:00
|
|
|
extern void *file_cache_create(dev_t mountID, ino_t vnodeID, off_t size);
|
2004-09-04 17:15:22 +00:00
|
|
|
extern void file_cache_delete(void *_cacheRef);
|
|
|
|
|
extern status_t file_cache_set_size(void *_cacheRef, off_t size);
|
2004-11-19 20:23:58 +00:00
|
|
|
extern status_t file_cache_sync(void *_cache);
|
2004-09-04 17:15:22 +00:00
|
|
|
|
2007-11-10 21:19:52 +00:00
|
|
|
extern status_t file_cache_read(void *_cacheRef, void *cookie, off_t offset,
|
|
|
|
|
void *bufferBase, size_t *_size);
|
|
|
|
|
extern status_t file_cache_write(void *_cacheRef, void *cookie, off_t offset,
|
2007-02-24 23:05:18 +00:00
|
|
|
const void *buffer, size_t *_size);
|
2004-09-04 17:15:22 +00:00
|
|
|
|
2007-11-10 21:19:52 +00:00
|
|
|
/* file map */
|
2007-11-13 10:34:48 +00:00
|
|
|
extern void *file_map_create(dev_t mountID, ino_t vnodeID, off_t size);
|
2007-11-10 21:19:52 +00:00
|
|
|
extern void file_map_delete(void *_map);
|
|
|
|
|
extern void file_map_set_size(void *_map, off_t size);
|
|
|
|
|
extern void file_map_invalidate(void *_map, off_t offset, off_t size);
|
|
|
|
|
extern status_t file_map_translate(void *_map, off_t offset, size_t size,
|
|
|
|
|
struct file_io_vec *vecs, size_t *_count);
|
|
|
|
|
|
2004-09-04 17:15:22 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* _FS_CACHE_H */
|