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
+2 -2
View File
@@ -87,9 +87,9 @@ void vfs_acquire_vnode(void *vnode);
status_t vfs_get_cookie_from_fd(int fd, void **_cookie);
bool vfs_can_page(void *vnode, void *cookie);
status_t vfs_read_pages(void *vnode, void *cookie, off_t pos,
const iovec *vecs, size_t count, size_t *_numBytes);
const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter);
status_t vfs_write_pages(void *vnode, void *cookie, off_t pos,
const iovec *vecs, size_t count, size_t *_numBytes);
const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter);
status_t vfs_get_vnode_cache(void *vnode, struct vm_cache_ref **_cache, bool allocate);
status_t vfs_get_file_map( void *_vnode, off_t offset, size_t size,
struct file_io_vec *vecs, size_t *_count);
+1 -1
View File
@@ -27,7 +27,7 @@ void vm_cache_release_ref(vm_cache_ref *cache_ref);
vm_page *vm_cache_lookup_page(vm_cache_ref *cacheRef, off_t page);
void vm_cache_insert_page(vm_cache_ref *cacheRef, vm_page *page, off_t offset);
void vm_cache_remove_page(vm_cache_ref *cacheRef, vm_page *page);
status_t vm_cache_write_modified(vm_cache_ref *ref);
status_t vm_cache_write_modified(vm_cache_ref *ref, bool fsReenter);
status_t vm_cache_set_minimal_commitment(vm_cache_ref *ref, off_t commitment);
status_t vm_cache_resize(vm_cache_ref *cacheRef, off_t newSize);
status_t vm_cache_insert_area(vm_cache_ref *cacheRef, vm_area *area);
+1 -1
View File
@@ -34,7 +34,7 @@ status_t vm_page_set_state(vm_page *page, int state);
size_t vm_page_num_pages(void);
size_t vm_page_num_free_pages(void);
status_t vm_page_write_modified(vm_cache *cache);
status_t vm_page_write_modified(vm_cache *cache, bool fsReenter);
vm_page *vm_page_allocate_page(int state);
status_t vm_page_allocate_pages(int pageState, vm_page **pages, uint32 numPages);
+7 -4
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2005, Axel Dörfler, [email protected].
* Copyright 2002-2006, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@@ -137,9 +137,12 @@ typedef struct vm_store_ops {
void (*destroy)(struct vm_store *backing_store);
status_t (*commit)(struct vm_store *backing_store, off_t size);
bool (*has_page)(struct vm_store *backing_store, off_t offset);
status_t (*read)(struct vm_store *backing_store, off_t offset, const iovec *vecs, size_t count, size_t *_numBytes);
status_t (*write)(struct vm_store *backing_store, off_t offset, const iovec *vecs, size_t count, size_t *_numBytes);
status_t (*fault)(struct vm_store *backing_store, struct vm_address_space *aspace, off_t offset);
status_t (*read)(struct vm_store *backing_store, off_t offset, const iovec *vecs,
size_t count, size_t *_numBytes, bool fsReenter);
status_t (*write)(struct vm_store *backing_store, off_t offset, const iovec *vecs,
size_t count, size_t *_numBytes, bool fsReenter);
status_t (*fault)(struct vm_store *backing_store, struct vm_address_space *aspace,
off_t offset);
void (*acquire_ref)(struct vm_store *backing_store);
void (*release_ref)(struct vm_store *backing_store);
} vm_store_ops;