* get_vnode() did not decrease the sUnusedVnodes counter when taking one node
of that list. * Added a vfs_free_unused_vnodes() function that calls the low memory handler directly. * create_sem_etc() now calls the above function in case there are no semaphores available anymore; this usually frees up to 2 semaphores per node (one from the cache if there is a file cache attached, and eventually one from the file system). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16610 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
9c2db284a8
commit
9f6376a0c7
@ -96,6 +96,7 @@ status_t vfs_get_fs_node_from_path(mount_id mountID, const char *path,
|
||||
status_t vfs_stat_vnode(void *_vnode, struct stat *stat);
|
||||
status_t vfs_get_vnode_name(void *vnode, char *name, size_t nameSize);
|
||||
status_t vfs_get_cwd(mount_id *_mountID, vnode_id *_vnodeID);
|
||||
void vfs_free_unused_vnodes(int32 level);
|
||||
|
||||
/* special module convenience call */
|
||||
status_t vfs_get_module_path(const char *basePath, const char *moduleName,
|
||||
|
@ -816,6 +816,7 @@ restart:
|
||||
if (vnode->ref_count == 0) {
|
||||
// this vnode has been unused before
|
||||
list_remove_item(&sUnusedVnodeList, vnode);
|
||||
sUnusedVnodes--;
|
||||
}
|
||||
inc_vnode_ref_count(vnode);
|
||||
} else {
|
||||
@ -2816,6 +2817,13 @@ vfs_get_cwd(mount_id *_mountID, vnode_id *_vnodeID)
|
||||
}
|
||||
|
||||
|
||||
extern "C" void
|
||||
vfs_free_unused_vnodes(int32 level)
|
||||
{
|
||||
vnode_low_memory_handler(NULL, level);
|
||||
}
|
||||
|
||||
|
||||
extern "C" bool
|
||||
vfs_can_page(void *_vnode, void *cookie)
|
||||
{
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include <debug.h>
|
||||
#include <thread.h>
|
||||
#include <team.h>
|
||||
#include <vfs.h>
|
||||
#include <vm_low_memory.h>
|
||||
#include <vm_page.h>
|
||||
#include <boot/kernel_args.h>
|
||||
|
||||
@ -257,7 +259,21 @@ create_sem_etc(int32 count, const char *name, team_id owner)
|
||||
char *tempName;
|
||||
size_t nameLength;
|
||||
|
||||
if (sSemsActive == false || sUsedSems == sMaxSems)
|
||||
if (sSemsActive == false)
|
||||
return B_NO_MORE_SEMS;
|
||||
|
||||
if (sUsedSems == sMaxSems) {
|
||||
// The vnode cache may have collected lots of semaphores.
|
||||
// Freeing some unused vnodes should improve our situation.
|
||||
// TODO: maybe create a generic "low resources" handler, instead
|
||||
// of only the specialised low memory thing?
|
||||
vfs_free_unused_vnodes(B_LOW_MEMORY_WARNING);
|
||||
}
|
||||
if (sUsedSems == sMaxSems) {
|
||||
// try again with more enthusiasm
|
||||
vfs_free_unused_vnodes(B_LOW_MEMORY_CRITICAL);
|
||||
}
|
||||
if (sUsedSems == sMaxSems)
|
||||
return B_NO_MORE_SEMS;
|
||||
|
||||
if (name == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user