2007-04-27 16:17:22 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2004-2007, Haiku Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _FSSH_FS_CACHE_H
|
|
|
|
#define _FSSH_FS_CACHE_H
|
|
|
|
|
|
|
|
//! File System File and Block Caches
|
|
|
|
|
|
|
|
|
|
|
|
#include "fssh_fs_interface.h"
|
|
|
|
|
|
|
|
|
|
|
|
typedef void (*fssh_transaction_notification_hook)(int32_t id, void *data);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* transactions */
|
|
|
|
extern int32_t fssh_cache_start_transaction(void *_cache);
|
|
|
|
extern fssh_status_t fssh_cache_sync_transaction(void *_cache, int32_t id);
|
|
|
|
extern fssh_status_t fssh_cache_end_transaction(void *_cache, int32_t id,
|
|
|
|
fssh_transaction_notification_hook hook,
|
|
|
|
void *data);
|
|
|
|
extern fssh_status_t fssh_cache_abort_transaction(void *_cache, int32_t id);
|
|
|
|
extern int32_t fssh_cache_detach_sub_transaction(void *_cache,
|
|
|
|
int32_t id, fssh_transaction_notification_hook hook,
|
|
|
|
void *data);
|
|
|
|
extern fssh_status_t fssh_cache_abort_sub_transaction(void *_cache,
|
|
|
|
int32_t id);
|
|
|
|
extern fssh_status_t fssh_cache_start_sub_transaction(void *_cache,
|
|
|
|
int32_t id);
|
|
|
|
extern fssh_status_t fssh_cache_next_block_in_transaction(void *_cache,
|
|
|
|
int32_t id, uint32_t *_cookie,
|
|
|
|
fssh_off_t *_blockNumber, void **_data,
|
|
|
|
void **_unchangedData);
|
|
|
|
extern int32_t fssh_cache_blocks_in_transaction(void *_cache,
|
|
|
|
int32_t id);
|
|
|
|
extern int32_t fssh_cache_blocks_in_sub_transaction(void *_cache,
|
|
|
|
int32_t id);
|
|
|
|
|
|
|
|
/* block cache */
|
|
|
|
extern void fssh_block_cache_delete(void *_cache, bool allowWrites);
|
|
|
|
extern void * fssh_block_cache_create(int fd, fssh_off_t numBlocks,
|
|
|
|
fssh_size_t blockSize, bool readOnly);
|
|
|
|
extern fssh_status_t fssh_block_cache_sync(void *_cache);
|
|
|
|
extern fssh_status_t fssh_block_cache_sync_etc(void *_cache,
|
|
|
|
fssh_off_t blockNumber, fssh_size_t numBlocks);
|
|
|
|
extern fssh_status_t fssh_block_cache_make_writable(void *_cache,
|
|
|
|
fssh_off_t blockNumber, int32_t transaction);
|
|
|
|
extern void * fssh_block_cache_get_writable_etc(void *_cache,
|
|
|
|
fssh_off_t blockNumber, fssh_off_t base,
|
|
|
|
fssh_off_t length, int32_t transaction);
|
|
|
|
extern void * fssh_block_cache_get_writable(void *_cache,
|
|
|
|
fssh_off_t blockNumber, int32_t transaction);
|
|
|
|
extern void * fssh_block_cache_get_empty(void *_cache,
|
|
|
|
fssh_off_t blockNumber, int32_t transaction);
|
|
|
|
extern const void * fssh_block_cache_get_etc(void *_cache,
|
|
|
|
fssh_off_t blockNumber, fssh_off_t base,
|
|
|
|
fssh_off_t length);
|
|
|
|
extern const void * fssh_block_cache_get(void *_cache,
|
|
|
|
fssh_off_t blockNumber);
|
|
|
|
extern fssh_status_t fssh_block_cache_set_dirty(void *_cache,
|
|
|
|
fssh_off_t blockNumber, bool isDirty,
|
|
|
|
int32_t transaction);
|
|
|
|
extern void fssh_block_cache_put(void *_cache,
|
|
|
|
fssh_off_t blockNumber);
|
|
|
|
|
|
|
|
/* file cache */
|
|
|
|
extern void * fssh_file_cache_create(fssh_mount_id mountID,
|
* Extracted file_map API out of the file cache - it's now an optional service
that can be used by file systems.
* Changed the way the file cache works: instead of reading/writing to the
underlying device directly, it can now be used for any data source, ie.
also network file systems.
* As a result, the former pages_io() moved to the VFS layer, and can now be
called by a file system via {read|write}_file_io_vec_pages() (naming
suggestions are always welcomed :-)). It now gets an FD, and uses that to
communicate with the device (via its fs_{read|write}_pages() hooks).
* The file_cache_{read|write}() functions must now be called without holding
an I/O relevant file system lock. That allows the file cache to prepare the
pages without colliding with the page writer, IOW the "mayBlock" flag can
go into the attic again (yay!).
* This also results in a much better performance when the system does I/O and
is low on memory, as the page writer can now finally write back some pages,
and that even without maxing out the CPU :)
* The API changes put slightly more burden on the fs_{read|write}_pages()
hooks, but in combination with the file_map it's still pretty straight
forward. It just will have to dispatch the call to the underlying device
directly, usually it will just call its fs_{read|write}_pages() hooks
via the above mentioned calls.
* Ported BFS and FAT to the new API, the latter has not been tested, though.
* Also ported the API changes to the fs_shell. I also completely removed its
file cache level page handling - the downside is that device access is no
longer cached (ie. depends on the host OS now), the upside is that the code
is greatly simplified.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22886 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-11-11 00:19:52 +03:00
|
|
|
fssh_vnode_id vnodeID, fssh_off_t size);
|
2007-04-27 16:17:22 +04:00
|
|
|
extern void fssh_file_cache_delete(void *_cacheRef);
|
|
|
|
extern fssh_status_t fssh_file_cache_set_size(void *_cacheRef,
|
|
|
|
fssh_off_t size);
|
|
|
|
extern fssh_status_t fssh_file_cache_sync(void *_cache);
|
|
|
|
|
* Extracted file_map API out of the file cache - it's now an optional service
that can be used by file systems.
* Changed the way the file cache works: instead of reading/writing to the
underlying device directly, it can now be used for any data source, ie.
also network file systems.
* As a result, the former pages_io() moved to the VFS layer, and can now be
called by a file system via {read|write}_file_io_vec_pages() (naming
suggestions are always welcomed :-)). It now gets an FD, and uses that to
communicate with the device (via its fs_{read|write}_pages() hooks).
* The file_cache_{read|write}() functions must now be called without holding
an I/O relevant file system lock. That allows the file cache to prepare the
pages without colliding with the page writer, IOW the "mayBlock" flag can
go into the attic again (yay!).
* This also results in a much better performance when the system does I/O and
is low on memory, as the page writer can now finally write back some pages,
and that even without maxing out the CPU :)
* The API changes put slightly more burden on the fs_{read|write}_pages()
hooks, but in combination with the file_map it's still pretty straight
forward. It just will have to dispatch the call to the underlying device
directly, usually it will just call its fs_{read|write}_pages() hooks
via the above mentioned calls.
* Ported BFS and FAT to the new API, the latter has not been tested, though.
* Also ported the API changes to the fs_shell. I also completely removed its
file cache level page handling - the downside is that device access is no
longer cached (ie. depends on the host OS now), the upside is that the code
is greatly simplified.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22886 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-11-11 00:19:52 +03:00
|
|
|
extern fssh_status_t fssh_file_cache_read(void *_cacheRef, void *cookie,
|
|
|
|
fssh_off_t offset, void *bufferBase,
|
|
|
|
fssh_size_t *_size);
|
|
|
|
extern fssh_status_t fssh_file_cache_write(void *_cacheRef, void *cookie,
|
2007-04-27 16:17:22 +04:00
|
|
|
fssh_off_t offset, const void *buffer,
|
|
|
|
fssh_size_t *_size);
|
|
|
|
|
* Extracted file_map API out of the file cache - it's now an optional service
that can be used by file systems.
* Changed the way the file cache works: instead of reading/writing to the
underlying device directly, it can now be used for any data source, ie.
also network file systems.
* As a result, the former pages_io() moved to the VFS layer, and can now be
called by a file system via {read|write}_file_io_vec_pages() (naming
suggestions are always welcomed :-)). It now gets an FD, and uses that to
communicate with the device (via its fs_{read|write}_pages() hooks).
* The file_cache_{read|write}() functions must now be called without holding
an I/O relevant file system lock. That allows the file cache to prepare the
pages without colliding with the page writer, IOW the "mayBlock" flag can
go into the attic again (yay!).
* This also results in a much better performance when the system does I/O and
is low on memory, as the page writer can now finally write back some pages,
and that even without maxing out the CPU :)
* The API changes put slightly more burden on the fs_{read|write}_pages()
hooks, but in combination with the file_map it's still pretty straight
forward. It just will have to dispatch the call to the underlying device
directly, usually it will just call its fs_{read|write}_pages() hooks
via the above mentioned calls.
* Ported BFS and FAT to the new API, the latter has not been tested, though.
* Also ported the API changes to the fs_shell. I also completely removed its
file cache level page handling - the downside is that device access is no
longer cached (ie. depends on the host OS now), the upside is that the code
is greatly simplified.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22886 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-11-11 00:19:52 +03:00
|
|
|
/* file map */
|
|
|
|
extern void * fssh_file_map_create(fssh_mount_id mountID,
|
2007-11-13 13:34:48 +03:00
|
|
|
fssh_vnode_id vnodeID, fssh_off_t size);
|
* Extracted file_map API out of the file cache - it's now an optional service
that can be used by file systems.
* Changed the way the file cache works: instead of reading/writing to the
underlying device directly, it can now be used for any data source, ie.
also network file systems.
* As a result, the former pages_io() moved to the VFS layer, and can now be
called by a file system via {read|write}_file_io_vec_pages() (naming
suggestions are always welcomed :-)). It now gets an FD, and uses that to
communicate with the device (via its fs_{read|write}_pages() hooks).
* The file_cache_{read|write}() functions must now be called without holding
an I/O relevant file system lock. That allows the file cache to prepare the
pages without colliding with the page writer, IOW the "mayBlock" flag can
go into the attic again (yay!).
* This also results in a much better performance when the system does I/O and
is low on memory, as the page writer can now finally write back some pages,
and that even without maxing out the CPU :)
* The API changes put slightly more burden on the fs_{read|write}_pages()
hooks, but in combination with the file_map it's still pretty straight
forward. It just will have to dispatch the call to the underlying device
directly, usually it will just call its fs_{read|write}_pages() hooks
via the above mentioned calls.
* Ported BFS and FAT to the new API, the latter has not been tested, though.
* Also ported the API changes to the fs_shell. I also completely removed its
file cache level page handling - the downside is that device access is no
longer cached (ie. depends on the host OS now), the upside is that the code
is greatly simplified.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22886 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-11-11 00:19:52 +03:00
|
|
|
extern void fssh_file_map_delete(void *_map);
|
|
|
|
extern void fssh_file_map_set_size(void *_map, fssh_off_t size);
|
|
|
|
extern void fssh_file_map_invalidate(void *_map, fssh_off_t offset,
|
|
|
|
fssh_off_t size);
|
|
|
|
extern fssh_status_t fssh_file_map_translate(void *_map, fssh_off_t offset,
|
|
|
|
fssh_size_t size, struct fssh_file_io_vec *vecs,
|
|
|
|
fssh_size_t *_count);
|
|
|
|
|
2007-04-27 16:17:22 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _FSSH_FS_CACHE_H */
|