/trunk/uspace/srv/vfs/vfs.h |
---|
36,6 → 36,7 |
#include <ipc/ipc.h> |
#include <libadt/list.h> |
#include <atomic.h> |
#include <rwlock.h> |
#include <sys/types.h> |
#include <bool.h> |
135,8 → 136,8 |
unsigned refcnt; /**< Usage counter. */ |
link_t nh_link; /**< Node hash-table link. */ |
/** Holding this futex prevents modifications of the node's contents. */ |
atomic_t contents_futex; |
/** Holding this rwlock prevents modifications of the node's contents. */ |
atomic_t contents_rwlock; |
} vfs_node_t; |
/** |
/trunk/uspace/srv/vfs/vfs_node.c |
---|
40,6 → 40,7 |
#include <string.h> |
#include <atomic.h> |
#include <futex.h> |
#include <rwlock.h> |
#include <libadt/hash_table.h> |
/** Futex protecting the VFS node hash table. */ |
146,7 → 147,7 |
node->dev_handle = triplet->fs_handle; |
node->index = triplet->index; |
link_initialize(&node->nh_link); |
futex_initialize(&node->contents_futex, 1); |
rwlock_initialize(&node->contents_rwlock); |
hash_table_insert(&nodes, key, &node->nh_link); |
} else { |
node = hash_table_get_instance(tmp, vfs_node_t, nh_link); |
/trunk/uspace/srv/vfs/vfs_rdwr.c |
---|
39,7 → 39,7 |
#include <ipc/ipc.h> |
#include <async.h> |
#include <errno.h> |
#include <futex.h> |
#include <rwlock.h> |
static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read) |
{ |
85,7 → 85,10 |
* Lock the file's node so that no other client can read/write to it at |
* the same time. |
*/ |
futex_down(&file->node->contents_futex); |
if (read) |
rwlock_reader_lock(&file->node->contents_rwlock); |
else |
rwlock_writer_lock(&file->node->contents_rwlock); |
int fs_phone = vfs_grab_phone(file->node->fs_handle); |
117,7 → 120,10 |
/* |
* Unlock the VFS node. |
*/ |
futex_up(&file->node->contents_futex); |
if (read) |
rwlock_reader_unlock(&file->node->contents_rwlock); |
else |
rwlock_writer_unlock(&file->node->contents_rwlock); |
/* |
* Update the position pointer. |