kernel/fs: Add support for setting custom VMCaches in vnodes.

This adds one (private) VFS function, and checks in all usages of
the vnode->cache as a VMVnodeCache that it really is one. (Generic
usages, for the moment just the ReleaseRef() calls in vnode
destruction, are intentionally not touched.)

This will be used by ramfs to set the cache from its own,
so that map_file() calls on a ramfs can work.
This commit is contained in:
Augustin Cavalier
2019-08-31 20:38:18 -04:00
parent 69c34116f0
commit a9be0efb2e
3 changed files with 32 additions and 4 deletions
+4 -2
View File
@@ -932,6 +932,8 @@ cache_prefetch_vnode(struct vnode* vnode, off_t offset, size_t size)
VMCache* cache;
if (vfs_get_vnode_cache(vnode, &cache, false) != B_OK)
return;
if (cache->type != CACHE_TYPE_VNODE)
return;
file_cache_ref* ref = ((VMVnodeCache*)cache)->FileCacheRef();
off_t fileSize = cache->virtual_end;
@@ -1029,7 +1031,7 @@ cache_node_opened(struct vnode* vnode, int32 fdType, VMCache* cache,
return;
off_t size = -1;
if (cache != NULL) {
if (cache != NULL && cache->type == CACHE_TYPE_VNODE) {
file_cache_ref* ref = ((VMVnodeCache*)cache)->FileCacheRef();
if (ref != NULL)
size = cache->virtual_end;
@@ -1048,7 +1050,7 @@ cache_node_closed(struct vnode* vnode, int32 fdType, VMCache* cache,
return;
int32 accessType = 0;
if (cache != NULL) {
if (cache != NULL && cache->type == CACHE_TYPE_VNODE) {
// ToDo: set accessType
}