Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4554 → Rev 4555

/trunk/uspace/srv/vfs/vfs_ops.c
43,7 → 43,6
#include <stdlib.h>
#include <string.h>
#include <bool.h>
#include <futex.h>
#include <fibril_sync.h>
#include <adt/list.h>
#include <unistd.h>
1131,9 → 1130,9
* VFS_DESTROY'ed after the last reference to it is dropped.
*/
vfs_node_t *node = vfs_node_get(&lr);
futex_down(&nodes_futex);
fibril_mutex_lock(&nodes_mutex);
node->lnkcnt--;
futex_up(&nodes_futex);
fibril_mutex_unlock(&nodes_mutex);
fibril_rwlock_write_unlock(&namespace_rwlock);
vfs_node_put(node);
ipc_answer_0(rid, EOK);
1282,9 → 1281,9
free(new);
return;
}
futex_down(&nodes_futex);
fibril_mutex_lock(&nodes_mutex);
new_node->lnkcnt--;
futex_up(&nodes_futex);
fibril_mutex_unlock(&nodes_mutex);
break;
default:
fibril_rwlock_write_unlock(&namespace_rwlock);
1304,9 → 1303,9
free(new);
return;
}
futex_down(&nodes_futex);
fibril_mutex_lock(&nodes_mutex);
old_node->lnkcnt++;
futex_up(&nodes_futex);
fibril_mutex_unlock(&nodes_mutex);
/* Destroy the link for the old name. */
rc = vfs_lookup_internal(oldc, L_UNLINK, NULL, NULL);
if (rc != EOK) {
1319,9 → 1318,9
free(new);
return;
}
futex_down(&nodes_futex);
fibril_mutex_lock(&nodes_mutex);
old_node->lnkcnt--;
futex_up(&nodes_futex);
fibril_mutex_unlock(&nodes_mutex);
fibril_rwlock_write_unlock(&namespace_rwlock);
vfs_node_put(old_node);
if (new_node)
/trunk/uspace/srv/vfs/vfs.h
36,7 → 36,6
#include <ipc/ipc.h>
#include <adt/list.h>
#include <fibril_sync.h>
#include <futex.h>
#include <sys/types.h>
#include <devmap.h>
#include <bool.h>
145,7 → 144,7
off_t pos;
} vfs_file_t;
 
extern futex_t nodes_futex;
extern fibril_mutex_t nodes_mutex;
 
extern link_t fs_head; /**< List of registered file systems. */
 
158,7 → 157,7
size_t len; /**< Number of characters in this PLB entry. */
} plb_entry_t;
 
extern futex_t plb_futex; /**< Futex protecting plb and plb_head. */
extern fibril_mutex_t plb_mutex;/**< Mutex protecting plb and plb_head. */
extern uint8_t *plb; /**< Path Lookup Buffer */
extern link_t plb_head; /**< List of active PLB entries. */
 
/trunk/uspace/srv/vfs/vfs_node.c
38,7 → 38,6
#include "vfs.h"
#include <stdlib.h>
#include <string.h>
#include <futex.h>
#include <fibril_sync.h>
#include <adt/hash_table.h>
#include <assert.h>
45,8 → 44,8
#include <async.h>
#include <errno.h>
 
/** Futex protecting the VFS node hash table. */
futex_t nodes_futex = FUTEX_INITIALIZER;
/** Mutex protecting the VFS node hash table. */
FIBRIL_MUTEX_INITIALIZE(nodes_mutex);
 
#define NODES_BUCKETS_LOG 8
#define NODES_BUCKETS (1 << NODES_BUCKETS_LOG)
89,9 → 88,9
*/
void vfs_node_addref(vfs_node_t *node)
{
futex_down(&nodes_futex);
fibril_mutex_lock(&nodes_mutex);
_vfs_node_addref(node);
futex_up(&nodes_futex);
fibril_mutex_unlock(&nodes_mutex);
}
 
/** Decrement reference count of a VFS node.
105,7 → 104,7
bool free_vfs_node = false;
bool free_fs_node = false;
 
futex_down(&nodes_futex);
fibril_mutex_lock(&nodes_mutex);
if (node->refcnt-- == 1) {
/*
* We are dropping the last reference to this node.
121,7 → 120,7
if (!node->lnkcnt)
free_fs_node = true;
}
futex_up(&nodes_futex);
fibril_mutex_unlock(&nodes_mutex);
 
if (free_fs_node) {
/*
161,12 → 160,12
link_t *tmp;
vfs_node_t *node;
 
futex_down(&nodes_futex);
fibril_mutex_lock(&nodes_mutex);
tmp = hash_table_find(&nodes, key);
if (!tmp) {
node = (vfs_node_t *) malloc(sizeof(vfs_node_t));
if (!node) {
futex_up(&nodes_futex);
fibril_mutex_unlock(&nodes_mutex);
return NULL;
}
memset(node, 0, sizeof(vfs_node_t));
193,7 → 192,7
assert(node->type == result->type || result->type == VFS_NODE_UNKNOWN);
 
_vfs_node_addref(node);
futex_up(&nodes_futex);
fibril_mutex_unlock(&nodes_mutex);
 
return node;
}
/trunk/uspace/srv/vfs/vfs_lookup.c
42,13 → 42,13
#include <string.h>
#include <stdarg.h>
#include <bool.h>
#include <futex.h>
#include <fibril_sync.h>
#include <adt/list.h>
#include <vfs/canonify.h>
 
#define min(a, b) ((a) < (b) ? (a) : (b))
 
futex_t plb_futex = FUTEX_INITIALIZER;
FIBRIL_MUTEX_INITIALIZE(plb_mutex);
link_t plb_head; /**< PLB entry ring buffer. */
uint8_t *plb = NULL;
 
92,7 → 92,7
va_end(ap);
}
futex_down(&plb_futex);
fibril_mutex_lock(&plb_mutex);
 
plb_entry_t entry;
link_initialize(&entry.plb_link);
119,7 → 119,7
/*
* The buffer cannot absorb the path.
*/
futex_up(&plb_futex);
fibril_mutex_unlock(&plb_mutex);
return ELIMIT;
}
} else {
127,7 → 127,7
/*
* The buffer cannot absorb the path.
*/
futex_up(&plb_futex);
fibril_mutex_unlock(&plb_mutex);
return ELIMIT;
}
}
146,7 → 146,7
*/
list_append(&entry.plb_link, &plb_head);
futex_up(&plb_futex);
fibril_mutex_unlock(&plb_mutex);
 
/*
* Copy the path into PLB.
168,7 → 168,7
async_wait_for(req, &rc);
vfs_release_phone(phone);
futex_down(&plb_futex);
fibril_mutex_lock(&plb_mutex);
list_remove(&entry.plb_link);
/*
* Erasing the path from PLB will come handy for debugging purposes.
175,7 → 175,7
*/
memset(&plb[first], 0, cnt1);
memset(plb, 0, cnt2);
futex_up(&plb_futex);
fibril_mutex_unlock(&plb_mutex);
 
if ((rc == EOK) && (result)) {
result->triplet.fs_handle = (fs_handle_t) IPC_GET_ARG1(answer);
/trunk/uspace/srv/vfs/vfs_file.c
57,7 → 57,7
* first VFS_OPEN operation.
*
* This resource being per-connection and, in the first place, per-fibril, we
* don't need to protect it by a futex.
* don't need to protect it by a mutex.
*/
fibril_local vfs_file_t **files = NULL;