xref: /haiku/headers/os/drivers/fs_cache.h (revision 060b02824b1654b57412e1a4e1ec795ed23d044c)
1 /* File System File and Block Caches
2 **
3 ** Distributed under the terms of the Haiku License.
4 */
5 #ifndef _FS_CACHE_H
6 #define _FS_CACHE_H
7 
8 
9 #include <fs_interface.h>
10 
11 
12 typedef void (*transaction_notification_hook)(int32);
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /* transactions */
19 extern int32 cache_transaction_start(void *_cache, transaction_notification_hook hook);
20 extern status_t cache_transaction_sync(void *_cache, int32 id);
21 extern status_t cache_transaction_end(void *_cache, int32 id);
22 extern status_t cache_transaction_abort(void *_cache, int32 id);
23 
24 /* block cache */
25 extern void block_cache_delete(void *_cache, bool allowWrites);
26 extern void *block_cache_create(int fd, off_t numBlocks, size_t blockSize);
27 extern status_t block_cache_sync(void *_cache);
28 
29 extern void *block_cache_get_writable_etc(void *_cache, off_t blockNumber, off_t base, off_t length, int32 transaction);
30 extern void *block_cache_get_writable(void *_cache, off_t blockNumber, int32 transaction);
31 extern void *block_cache_get_empty(void *_cache, off_t blockNumber, int32 transaction);
32 extern const void *block_cache_get_etc(void *_cache, off_t blockNumber, off_t base, off_t length);
33 extern const void *block_cache_get(void *_cache, off_t blockNumber);
34 extern void block_cache_put(void *_cache, off_t blockNumber);
35 
36 /* file cache */
37 extern void *file_cache_create(mount_id mountID, vnode_id vnodeID, off_t size, int fd);
38 extern void file_cache_delete(void *_cacheRef);
39 extern status_t file_cache_set_size(void *_cacheRef, off_t size);
40 
41 extern status_t file_cache_read_pages(void *_cacheRef, off_t offset,
42 					const iovec *vecs, size_t count, size_t *_numBytes);
43 extern status_t file_cache_write_pages(void *_cacheRef, off_t offset,
44 					const iovec *vecs, size_t count, size_t *_numBytes);
45 extern status_t file_cache_read(void *_cacheRef, off_t offset, void *bufferBase, size_t *_size);
46 extern status_t file_cache_write(void *_cacheRef, off_t offset, const void *buffer, size_t *_size);
47 
48 #ifdef __cplusplus
49 }
50 #endif
51 
52 #endif	/* _FS_CACHE_H */
53