Initial support for cache modules.
Also fixed a minor bug in dec_vnode_ref_count(): the unusued vnode counter was not decremented again when one vnode was removed. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10336 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include <vfs.h>
|
#include <vfs.h>
|
||||||
#include <vm.h>
|
#include <vm.h>
|
||||||
#include <vm_cache.h>
|
#include <vm_cache.h>
|
||||||
|
#include <file_cache.h>
|
||||||
#include <khash.h>
|
#include <khash.h>
|
||||||
#include <lock.h>
|
#include <lock.h>
|
||||||
#include <kerrors.h>
|
#include <kerrors.h>
|
||||||
@@ -52,7 +53,7 @@
|
|||||||
|
|
||||||
#define MAX_SYM_LINKS SYMLINKS_MAX
|
#define MAX_SYM_LINKS SYMLINKS_MAX
|
||||||
|
|
||||||
const static uint32 kMaxUnusedVnodes = 512;
|
const static uint32 kMaxUnusedVnodes = 8192;
|
||||||
// This is the maximum number of unused vnodes that the system
|
// This is the maximum number of unused vnodes that the system
|
||||||
// will keep around.
|
// will keep around.
|
||||||
// It may be chosen with respect to the available memory or enhanced
|
// It may be chosen with respect to the available memory or enhanced
|
||||||
@@ -645,10 +646,10 @@ dec_vnode_ref_count(struct vnode *vnode, bool reenter)
|
|||||||
// there are too many unused vnodes so we free the oldest one
|
// there are too many unused vnodes so we free the oldest one
|
||||||
// ToDo: evaluate this mechanism
|
// ToDo: evaluate this mechanism
|
||||||
vnode = (struct vnode *)list_remove_head_item(&sUnusedVnodeList);
|
vnode = (struct vnode *)list_remove_head_item(&sUnusedVnodeList);
|
||||||
|
|
||||||
hash_remove(sVnodeTable, vnode);
|
hash_remove(sVnodeTable, vnode);
|
||||||
vnode->busy = true;
|
vnode->busy = true;
|
||||||
freeNode = true;
|
freeNode = true;
|
||||||
|
sUnusedVnodes--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1532,6 +1533,7 @@ get_new_fd(int type, struct vnode *vnode, fs_cookie cookie, int openMode, bool k
|
|||||||
return B_NO_MORE_FDS;
|
return B_NO_MORE_FDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cache_node_opened(vnode->cache, vnode->device, vnode->id);
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2369,7 +2371,7 @@ vfs_init(kernel_args *args)
|
|||||||
if (mutex_init(&sVnodeMutex, "vfs_vnode_lock") < 0)
|
if (mutex_init(&sVnodeMutex, "vfs_vnode_lock") < 0)
|
||||||
panic("vfs_init: error allocating vnode lock\n");
|
panic("vfs_init: error allocating vnode lock\n");
|
||||||
|
|
||||||
return 0;
|
return file_cache_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user