Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2678 → Rev 2679

/trunk/uspace/srv/vfs/vfs_unlink.c
40,9 → 40,9
 
/**
* This futex prevents the race between a triplet-to-VFS-node resolution and a
* concurrent VFS_UNLINK or VFS_RMDIR operation.
* concurrent VFS operation which modifies the file system namespace.
*/
atomic_t unlink_futex = FUTEX_INITIALIZER;
atomic_t namespace_futex = FUTEX_INITIALIZER;
 
/**
* @}
/trunk/uspace/srv/vfs/vfs_open.c
93,7 → 93,7
* find/create-and-lock the VFS node corresponding to the looked-up
* triplet.
*/
futex_down(&unlink_futex);
futex_down(&namespace_futex);
 
/*
* 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(&unlink_futex);
futex_up(&namespace_futex);
ipc_answer_0(rid, rc);
free(path);
return;
113,7 → 113,7
free(path);
 
vfs_node_t *node = vfs_node_get(&triplet);
futex_up(&unlink_futex);
futex_up(&namespace_futex);
 
/*
* Get ourselves a file descriptor and the corresponding vfs_file_t
/trunk/uspace/srv/vfs/vfs_mount.c
154,9 → 154,9
 
/*
* Lookup the root node of the filesystem being mounted.
* In this case, we don't need to take the unlink_futex as the root node
* cannot be removed. However, we do take a reference to it so that
* we can track how many times it has been mounted.
* In this case, we don't need to take the namespace_futex as the root
* node cannot be removed. However, we do take a reference to it so
* that we can track how many times it has been mounted.
*/
int rc;
vfs_triplet_t mounted_root;
182,13 → 182,13
/*
* We already have the root FS.
*/
futex_down(&unlink_futex);
futex_down(&namespace_futex);
rc = vfs_lookup_internal(buf, size, &mp, NULL);
if (rc != EOK) {
/*
* The lookup failed for some reason.
*/
futex_up(&unlink_futex);
futex_up(&namespace_futex);
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(&unlink_futex);
futex_up(&namespace_futex);
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(&unlink_futex);
futex_up(&namespace_futex);
} else {
/*
* We still don't have the root file system mounted.
/trunk/uspace/srv/vfs/vfs.h
134,6 → 134,9
VFS_TRIPLET; /**< Identity of the node. */
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;
} vfs_node_t;
 
/**
169,7 → 172,8
extern uint8_t *plb; /**< Path Lookup Buffer */
extern link_t plb_head; /**< List of active PLB entries. */
 
extern atomic_t unlink_futex; /**< VFS_{CREATE|OPEN|UNLINK} serialization. */
/** Holding this futex prevents extern changes in file system namespace. */
atomic_t namespace_futex;
 
extern int vfs_grab_phone(int);
extern void vfs_release_phone(int);
/trunk/uspace/srv/vfs/vfs_node.c
146,6 → 146,7
node->dev_handle = triplet->fs_handle;
node->index = triplet->index;
link_initialize(&node->nh_link);
futex_initialize(&node->contents_futex, 1);
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,6 → 39,7
#include <ipc/ipc.h>
#include <async.h>
#include <errno.h>
#include <futex.h>
 
static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read)
{
80,6 → 81,12
return;
}
 
/*
* 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);
 
int fs_phone = vfs_grab_phone(file->node->fs_handle);
/*
108,6 → 115,11
size_t bytes = IPC_GET_ARG1(answer);
 
/*
* Unlock the VFS node.
*/
futex_up(&file->node->contents_futex);
 
/*
* Update the position pointer.
*/
file->pos += bytes;