From e82b1340a79a1341d5d1e72cf85287756ded837c Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 22 Jul 2010 12:20:45 +0000 Subject: [PATCH] * checksumfs_lookup(): The flags return parameter was never set, leading to weird behavior when running in kernel. * checksumfs_io(): Try to lock with timeout when the request is VIP. This works around a potential quasi-deadlock: Most write support FS hooks potentially allocate memory (e.g. in block_cache_get*()) while holding a write lock to a node. When memory is low they have to wait for pages to become available. The page writer might block on such node which in turn would prevent modified pages from becoming eligible for recycling. Should only in rare low memory cases have led to a problem. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37687 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../system/kernel/file_corruption/fs/checksumfs.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/tests/system/kernel/file_corruption/fs/checksumfs.cpp b/src/tests/system/kernel/file_corruption/fs/checksumfs.cpp index 23b2d73856..a0de2ab7eb 100644 --- a/src/tests/system/kernel/file_corruption/fs/checksumfs.cpp +++ b/src/tests/system/kernel/file_corruption/fs/checksumfs.cpp @@ -975,6 +975,7 @@ checksumfs_get_vnode(fs_volume* fsVolume, ino_t id, fs_vnode* vnode, vnode->private_node = node; vnode->ops = &gCheckSumFSVnodeOps; *_type = node->Mode(); + *_flags = 0; return B_OK; } @@ -1083,7 +1084,15 @@ checksumfs_io(fs_volume* fsVolume, fs_vnode* vnode, void* cookie, } // Read-lock the file -- we'll unlock it in the finished hook. - file->ReadLock(); + if (io_request_is_vip(request)) { + // We cannot wait for the node lock indefinitely. So try read-locking + // with a timeout (0.1 s). + if (!file->ReadLockWithTimeout(B_RELATIVE_TIMEOUT, 100000)) { + notify_io_request(request, B_BUSY); + RETURN_ERROR(B_BUSY); + } + } else + file->ReadLock(); RETURN_ERROR(do_iterative_fd_io(volume->FD(), request, iterative_io_get_vecs_hook, iterative_io_finished_hook, file));