Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2680 → Rev 2681

/trunk/uspace/lib/libc/include/rwlock.h
44,6 → 44,9
 
typedef atomic_t rwlock_t;
 
#define RWLOCK_INITIALIZE(rwlock) \
rwlock_t rwlock = FUTEX_INITIALIZER
 
#define rwlock_initialize(rwlock) futex_initialize((rwlock), 1)
#define rwlock_reader_lock(rwlock) futex_down((rwlock))
#define rwlock_writer_lock(rwlock) futex_down((rwlock))
/trunk/uspace/srv/vfs/vfs_unlink.c
35,14 → 35,13
* @brief
*/
 
#include <atomic.h>
#include <futex.h>
#include <rwlock.h>
 
/**
* This futex prevents the race between a triplet-to-VFS-node resolution and a
* This rwlock prevents the race between a triplet-to-VFS-node resolution and a
* concurrent VFS operation which modifies the file system namespace.
*/
atomic_t namespace_futex = FUTEX_INITIALIZER;
RWLOCK_INITIALIZE(namespace_rwlock);
 
/**
* @}
/trunk/uspace/srv/vfs/vfs_open.c
38,7 → 38,7
#include <ipc/ipc.h>
#include <async.h>
#include <errno.h>
#include <futex.h>
#include <rwlock.h>
#include <sys/types.h>
#include <stdlib.h>
#include "vfs.h"
93,7 → 93,7
* find/create-and-lock the VFS node corresponding to the looked-up
* triplet.
*/
futex_down(&namespace_futex);
rwlock_reader_lock(&namespace_rwlock);
 
/*
* The path is now populated and we can call vfs_lookup_internal().
101,7 → 101,7
vfs_triplet_t triplet;
rc = vfs_lookup_internal(path, size, &triplet, NULL);
if (rc) {
futex_up(&namespace_futex);
rwlock_reader_unlock(&namespace_rwlock);
ipc_answer_0(rid, rc);
free(path);
return;
113,7 → 113,7
free(path);
 
vfs_node_t *node = vfs_node_get(&triplet);
futex_up(&namespace_futex);
rwlock_reader_unlock(&namespace_rwlock);
 
/*
* Get ourselves a file descriptor and the corresponding vfs_file_t
/trunk/uspace/srv/vfs/vfs_mount.c
182,13 → 182,13
/*
* We already have the root FS.
*/
futex_down(&namespace_futex);
rwlock_writer_lock(&namespace_rwlock);
rc = vfs_lookup_internal(buf, size, &mp, NULL);
if (rc != EOK) {
/*
* The lookup failed for some reason.
*/
futex_up(&namespace_futex);
rwlock_writer_unlock(&namespace_rwlock);
futex_up(&rootfs_futex);
vfs_node_put(mr_node); /* failed -> drop reference */
free(buf);
197,7 → 197,7
}
mp_node = vfs_node_get(&mp);
if (!mp_node) {
futex_up(&namespace_futex);
rwlock_writer_unlock(&namespace_rwlock);
futex_up(&rootfs_futex);
vfs_node_put(mr_node); /* failed -> drop reference */
free(buf);
209,7 → 209,7
* It will be dropped upon the corresponding VFS_UNMOUNT.
* This prevents the mount point from being deleted.
*/
futex_up(&namespace_futex);
rwlock_writer_unlock(&namespace_rwlock);
} else {
/*
* We still don't have the root file system mounted.
/trunk/uspace/srv/vfs/vfs.h
173,8 → 173,8
extern uint8_t *plb; /**< Path Lookup Buffer */
extern link_t plb_head; /**< List of active PLB entries. */
 
/** Holding this futex prevents extern changes in file system namespace. */
atomic_t namespace_futex;
/** Holding this rwlock prevents changes in file system namespace. */
extern rwlock_t namespace_rwlock;
 
extern int vfs_grab_phone(int);
extern void vfs_release_phone(int);