* 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
This commit is contained in:
@@ -56,23 +56,24 @@ extern status_t block_cache_set_dirty(void *_cache, off_t blockNumber,
|
||||
extern void block_cache_put(void *_cache, off_t blockNumber);
|
||||
|
||||
/* file cache */
|
||||
extern void *file_cache_create(dev_t mountID, ino_t vnodeID, off_t size,
|
||||
int fd);
|
||||
extern void *file_cache_create(dev_t mountID, ino_t vnodeID, off_t size);
|
||||
extern void file_cache_delete(void *_cacheRef);
|
||||
extern status_t file_cache_set_size(void *_cacheRef, off_t size);
|
||||
extern status_t file_cache_sync(void *_cache);
|
||||
extern status_t file_cache_invalidate_file_map(void *_cacheRef, off_t offset,
|
||||
off_t size);
|
||||
|
||||
extern status_t file_cache_read_pages(void *_cacheRef, off_t offset,
|
||||
const iovec *vecs, size_t count, size_t *_numBytes);
|
||||
extern status_t file_cache_write_pages(void *_cacheRef, off_t offset,
|
||||
const iovec *vecs, size_t count, size_t *_numBytes);
|
||||
extern status_t file_cache_read(void *_cacheRef, off_t offset, void *bufferBase,
|
||||
size_t *_size);
|
||||
extern status_t file_cache_write(void *_cacheRef, off_t offset,
|
||||
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,
|
||||
const void *buffer, size_t *_size);
|
||||
|
||||
/* file map */
|
||||
extern void *file_map_create(dev_t mountID, ino_t vnodeID);
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -92,10 +92,10 @@ typedef struct file_system_module_info {
|
||||
bool (*can_page)(fs_volume fs, fs_vnode vnode, fs_cookie cookie);
|
||||
status_t (*read_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
||||
off_t pos, const iovec *vecs, size_t count, size_t *_numBytes,
|
||||
bool mayBlock, bool reenter);
|
||||
bool reenter);
|
||||
status_t (*write_pages)(fs_volume fs, fs_vnode vnode, fs_cookie cookie,
|
||||
off_t pos, const iovec *vecs, size_t count, size_t *_numBytes,
|
||||
bool mayBlock, bool reenter);
|
||||
bool reenter);
|
||||
|
||||
/* cache file access */
|
||||
status_t (*get_file_map)(fs_volume fs, fs_vnode vnode, off_t offset,
|
||||
@@ -251,6 +251,18 @@ extern status_t remove_vnode(dev_t mountID, ino_t vnodeID);
|
||||
extern status_t unremove_vnode(dev_t mountID, ino_t vnodeID);
|
||||
extern status_t get_vnode_removed(dev_t mountID, ino_t vnodeID,
|
||||
bool* removed);
|
||||
extern status_t read_pages(int fd, off_t pos, const struct iovec *vecs,
|
||||
size_t count, size_t *_numBytes, bool fsReenter);
|
||||
extern status_t write_pages(int fd, off_t pos, const struct iovec *vecs,
|
||||
size_t count, size_t *_numBytes, bool fsReenter);
|
||||
extern status_t read_file_io_vec_pages(int fd,
|
||||
const struct file_io_vec *fileVecs, size_t fileVecCount,
|
||||
const struct iovec *vecs, size_t vecCount,
|
||||
uint32 *_vecIndex, size_t *_vecOffset, size_t *_bytes);
|
||||
extern status_t write_file_io_vec_pages(int fd,
|
||||
const struct file_io_vec *fileVecs, size_t fileVecCount,
|
||||
const struct iovec *vecs, size_t vecCount,
|
||||
uint32 *_vecIndex, size_t *_vecOffset, size_t *_bytes);
|
||||
|
||||
// Deprecated! Will disappear soon!
|
||||
extern status_t notify_listener(int op, dev_t device, ino_t parentNode,
|
||||
|
||||
@@ -820,13 +820,16 @@
|
||||
#define file_cache_delete fssh_file_cache_delete
|
||||
#define file_cache_set_size fssh_file_cache_set_size
|
||||
#define file_cache_sync fssh_file_cache_sync
|
||||
#define file_cache_invalidate_file_map fssh_file_cache_invalidate_file_map
|
||||
|
||||
#define file_cache_read_pages fssh_file_cache_read_pages
|
||||
#define file_cache_write_pages fssh_file_cache_write_pages
|
||||
#define file_cache_read fssh_file_cache_read
|
||||
#define file_cache_write fssh_file_cache_write
|
||||
|
||||
/* file map */
|
||||
#define file_map_create fssh_file_map_create
|
||||
#define file_map_delete fssh_file_map_delete
|
||||
#define file_map_set_size fssh_file_map_set_size
|
||||
#define file_map_invalidate fssh_file_map_invalidate
|
||||
#define file_map_translate fssh_file_map_translate
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// #pragma mark - fssh_fs_index.h
|
||||
@@ -893,6 +896,10 @@
|
||||
#define remove_vnode fssh_remove_vnode
|
||||
#define unremove_vnode fssh_unremove_vnode
|
||||
#define get_vnode_removed fssh_get_vnode_removed
|
||||
#define read_pages fssh_read_pages
|
||||
#define write_pages fssh_write_pages
|
||||
#define read_file_io_vec_pages fssh_read_file_io_vec_pages
|
||||
#define write_file_io_vec_pages fssh_write_file_io_vec_pages
|
||||
|
||||
#define notify_entry_created fssh_notify_entry_created
|
||||
#define notify_entry_removed fssh_notify_entry_removed
|
||||
|
||||
@@ -69,26 +69,30 @@ extern void fssh_block_cache_put(void *_cache,
|
||||
|
||||
/* file cache */
|
||||
extern void * fssh_file_cache_create(fssh_mount_id mountID,
|
||||
fssh_vnode_id vnodeID, fssh_off_t size, int fd);
|
||||
fssh_vnode_id vnodeID, fssh_off_t size);
|
||||
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);
|
||||
extern fssh_status_t fssh_file_cache_invalidate_file_map(void *_cacheRef,
|
||||
fssh_off_t offset, fssh_off_t size);
|
||||
|
||||
extern fssh_status_t fssh_file_cache_read_pages(void *_cacheRef,
|
||||
fssh_off_t offset, const fssh_iovec *vecs,
|
||||
fssh_size_t count, fssh_size_t *_numBytes);
|
||||
extern fssh_status_t fssh_file_cache_write_pages(void *_cacheRef,
|
||||
fssh_off_t offset, const fssh_iovec *vecs,
|
||||
fssh_size_t count, fssh_size_t *_numBytes);
|
||||
extern fssh_status_t fssh_file_cache_read(void *_cacheRef, fssh_off_t offset,
|
||||
void *bufferBase, fssh_size_t *_size);
|
||||
extern fssh_status_t fssh_file_cache_write(void *_cacheRef,
|
||||
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,
|
||||
fssh_off_t offset, const void *buffer,
|
||||
fssh_size_t *_size);
|
||||
|
||||
/* file map */
|
||||
extern void * fssh_file_map_create(fssh_mount_id mountID,
|
||||
fssh_vnode_id vnodeID);
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -96,12 +96,10 @@ typedef struct fssh_file_system_module_info {
|
||||
fssh_fs_cookie cookie);
|
||||
fssh_status_t (*read_pages)(fssh_fs_volume fs, fssh_fs_vnode vnode,
|
||||
fssh_fs_cookie cookie, fssh_off_t pos, const fssh_iovec *vecs,
|
||||
fssh_size_t count, fssh_size_t *_numBytes, bool mayBlock,
|
||||
bool reenter);
|
||||
fssh_size_t count, fssh_size_t *_numBytes, bool reenter);
|
||||
fssh_status_t (*write_pages)(fssh_fs_volume fs, fssh_fs_vnode vnode,
|
||||
fssh_fs_cookie cookie, fssh_off_t pos, const fssh_iovec *vecs,
|
||||
fssh_size_t count, fssh_size_t *_numBytes, bool mayBlock,
|
||||
bool reenter);
|
||||
fssh_size_t count, fssh_size_t *_numBytes, bool reenter);
|
||||
|
||||
/* cache file access */
|
||||
fssh_status_t (*get_file_map)(fssh_fs_volume fs, fssh_fs_vnode vnode,
|
||||
@@ -293,6 +291,22 @@ extern fssh_status_t fssh_unremove_vnode(fssh_mount_id mountID,
|
||||
fssh_vnode_id vnodeID);
|
||||
extern fssh_status_t fssh_get_vnode_removed(fssh_mount_id mountID,
|
||||
fssh_vnode_id vnodeID, bool* removed);
|
||||
extern fssh_status_t fssh_read_pages(int fd, fssh_off_t pos,
|
||||
const struct fssh_iovec *vecs, fssh_size_t count,
|
||||
fssh_size_t *_numBytes, bool fsReenter);
|
||||
extern fssh_status_t fssh_write_pages(int fd, fssh_off_t pos,
|
||||
const struct fssh_iovec *vecs, fssh_size_t count,
|
||||
fssh_size_t *_numBytes, bool fsReenter);
|
||||
extern fssh_status_t fssh_read_file_io_vec_pages(int fd,
|
||||
const struct fssh_file_io_vec *fileVecs,
|
||||
fssh_size_t fileVecCount, const struct fssh_iovec *vecs,
|
||||
fssh_size_t vecCount, uint32_t *_vecIndex,
|
||||
fssh_size_t *_vecOffset, fssh_size_t *_bytes);
|
||||
extern fssh_status_t fssh_write_file_io_vec_pages(int fd,
|
||||
const struct fssh_file_io_vec *fileVecs,
|
||||
fssh_size_t fileVecCount, const struct fssh_iovec *vecs,
|
||||
fssh_size_t vecCount, uint32_t *_vecIndex,
|
||||
fssh_size_t *_vecOffset, fssh_size_t *_bytes);
|
||||
|
||||
extern fssh_status_t fssh_notify_entry_created(fssh_mount_id device,
|
||||
fssh_vnode_id directory, const char *name, fssh_vnode_id node);
|
||||
|
||||
@@ -94,11 +94,9 @@ void vfs_acquire_vnode(struct vnode *vnode);
|
||||
status_t vfs_get_cookie_from_fd(int fd, void **_cookie);
|
||||
bool vfs_can_page(struct vnode *vnode, void *cookie);
|
||||
status_t vfs_read_pages(struct vnode *vnode, void *cookie, off_t pos,
|
||||
const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock,
|
||||
bool fsReenter);
|
||||
const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter);
|
||||
status_t vfs_write_pages(struct vnode *vnode, void *cookie, off_t pos,
|
||||
const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock,
|
||||
bool fsReenter);
|
||||
const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter);
|
||||
status_t vfs_get_vnode_cache(struct vnode *vnode, struct vm_cache **_cache,
|
||||
bool allocate);
|
||||
status_t vfs_get_file_map(struct vnode *vnode, off_t offset, size_t size,
|
||||
|
||||
@@ -223,11 +223,9 @@ typedef struct vm_store_ops {
|
||||
status_t (*commit)(struct vm_store *backingStore, off_t size);
|
||||
bool (*has_page)(struct vm_store *backingStore, off_t offset);
|
||||
status_t (*read)(struct vm_store *backingStore, off_t offset,
|
||||
const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock,
|
||||
bool fsReenter);
|
||||
const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter);
|
||||
status_t (*write)(struct vm_store *backingStore, off_t offset,
|
||||
const iovec *vecs, size_t count, size_t *_numBytes, bool mayBlock,
|
||||
bool fsReenter);
|
||||
const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter);
|
||||
status_t (*fault)(struct vm_store *backingStore,
|
||||
struct vm_address_space *aspace, off_t offset);
|
||||
status_t (*acquire_unreferenced_ref)(struct vm_store *backingStore);
|
||||
|
||||
Reference in New Issue
Block a user