Added a "reenter" parameter to the {read|write}_pages() functions to give file

systems a chance to know if they have locked already.
This fixes a locking problem in BFS where one thread tried to acquire two read
locks (where someone else trying to acquire a write lock would have caused a
dead lock).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17108 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-04-12 13:34:04 +00:00
parent 4d89d3e7e1
commit 97e069713b
18 changed files with 104 additions and 80 deletions
+10 -6
View File
@@ -317,7 +317,8 @@ pages_io(file_cache_ref *ref, off_t offset, const iovec *vecs, size_t count,
if (size > numBytes)
size = numBytes;
status = vfs_read_pages(ref->device, ref->cookie, fileVecs[0].offset, vecs, count, &size);
status = vfs_read_pages(ref->device, ref->cookie, fileVecs[0].offset, vecs,
count, &size, false);
if (status < B_OK)
return status;
@@ -394,10 +395,13 @@ pages_io(file_cache_ref *ref, off_t offset, const iovec *vecs, size_t count,
}
size_t bytes = size;
if (doWrite)
status = vfs_write_pages(ref->device, ref->cookie, fileVec.offset, tempVecs, tempCount, &bytes);
else
status = vfs_read_pages(ref->device, ref->cookie, fileVec.offset, tempVecs, tempCount, &bytes);
if (doWrite) {
status = vfs_write_pages(ref->device, ref->cookie, fileVec.offset, tempVecs,
tempCount, &bytes, false);
} else {
status = vfs_read_pages(ref->device, ref->cookie, fileVec.offset, tempVecs,
tempCount, &bytes, false);
}
if (status < B_OK)
return status;
@@ -1221,7 +1225,7 @@ file_cache_sync(void *_cacheRef)
if (ref == NULL)
return B_BAD_VALUE;
return vm_cache_write_modified(ref->cache);
return vm_cache_write_modified(ref->cache, true);
}