It's not a good idea to write back large files while keeping the vnode busy.
The low memory handler now has two passes which should help there; however, it might also accidently remove recently used vnodes, too. We could mark the clean ones in some way if that turns out to be a problem. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22678 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -921,7 +921,7 @@ vnode_low_memory_handler(void */*data*/, int32 level)
|
|||||||
{
|
{
|
||||||
TRACE(("vnode_low_memory_handler(level = %ld)\n", level));
|
TRACE(("vnode_low_memory_handler(level = %ld)\n", level));
|
||||||
|
|
||||||
int32 count = 1;
|
uint32 count = 1;
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case B_NO_LOW_MEMORY:
|
case B_NO_LOW_MEMORY:
|
||||||
return;
|
return;
|
||||||
@@ -936,10 +936,44 @@ vnode_low_memory_handler(void */*data*/, int32 level)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32 i = 0; i < count; i++) {
|
if (count > sUnusedVnodes)
|
||||||
|
count = sUnusedVnodes;
|
||||||
|
|
||||||
|
// first, write back the modified pages of some unused vnodes
|
||||||
|
|
||||||
|
uint32 freeCount = count;
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < count; i++) {
|
||||||
|
mutex_lock(&sVnodeMutex);
|
||||||
|
struct vnode *vnode = (struct vnode *)list_remove_head_item(
|
||||||
|
&sUnusedVnodeList);
|
||||||
|
if (vnode == NULL) {
|
||||||
|
mutex_unlock(&sVnodeMutex);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
inc_vnode_ref_count(vnode);
|
||||||
|
sUnusedVnodes--;
|
||||||
|
|
||||||
|
mutex_unlock(&sVnodeMutex);
|
||||||
|
|
||||||
|
if (vnode->cache != NULL)
|
||||||
|
vm_cache_write_modified(vnode->cache, false);
|
||||||
|
|
||||||
|
dec_vnode_ref_count(vnode, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// and then free them
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < freeCount; i++) {
|
||||||
mutex_lock(&sVnodeMutex);
|
mutex_lock(&sVnodeMutex);
|
||||||
|
|
||||||
struct vnode *vnode = (struct vnode *)list_remove_head_item(&sUnusedVnodeList);
|
// We're removing vnodes from the tail of the list - hoping it's
|
||||||
|
// one of those we have just written back; otherwise we'll write
|
||||||
|
// back the vnode with the busy flag turned on, and that might
|
||||||
|
// take some time.
|
||||||
|
struct vnode *vnode = (struct vnode *)list_remove_tail_item(
|
||||||
|
&sUnusedVnodeList);
|
||||||
if (vnode == NULL) {
|
if (vnode == NULL) {
|
||||||
mutex_unlock(&sVnodeMutex);
|
mutex_unlock(&sVnodeMutex);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user