Changeset f57f8ea in mainline


Ignore:
Timestamp:
2008-01-02T20:25:24Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9413c0d
Parents:
215e375
Message:

Rename unlink_futex to namespace_futex and introduce a new futex for serializing
concurrent access to a VFS node's contents by multiple clients.

Location:
uspace/srv/vfs
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs.h

    r215e375 rf57f8ea  
    135135        unsigned refcnt;        /**< Usage counter. */
    136136        link_t nh_link;         /**< Node hash-table link. */
     137
     138        /** Holding this futex prevents modifications of the node's contents. */
     139        atomic_t contents_futex;
    137140} vfs_node_t;
    138141
     
    170173extern link_t plb_head;         /**< List of active PLB entries. */
    171174
    172 extern atomic_t unlink_futex;   /**< VFS_{CREATE|OPEN|UNLINK} serialization. */
     175/** Holding this futex prevents extern changes in file system namespace. */
     176atomic_t namespace_futex;
    173177
    174178extern int vfs_grab_phone(int);
  • uspace/srv/vfs/vfs_mount.c

    r215e375 rf57f8ea  
    155155        /*
    156156         * Lookup the root node of the filesystem being mounted.
    157          * In this case, we don't need to take the unlink_futex as the root node
    158          * cannot be removed. However, we do take a reference to it so that
    159          * we can track how many times it has been mounted.
     157         * In this case, we don't need to take the namespace_futex as the root
     158         * node cannot be removed. However, we do take a reference to it so
     159         * that we can track how many times it has been mounted.
    160160         */
    161161        int rc;
     
    183183                 * We already have the root FS.
    184184                 */
    185                 futex_down(&unlink_futex);
     185                futex_down(&namespace_futex);
    186186                rc = vfs_lookup_internal(buf, size, &mp, NULL);
    187187                if (rc != EOK) {
     
    189189                         * The lookup failed for some reason.
    190190                         */
    191                         futex_up(&unlink_futex);
     191                        futex_up(&namespace_futex);
    192192                        futex_up(&rootfs_futex);
    193193                        vfs_node_put(mr_node);  /* failed -> drop reference */
     
    198198                mp_node = vfs_node_get(&mp);
    199199                if (!mp_node) {
    200                         futex_up(&unlink_futex);
     200                        futex_up(&namespace_futex);
    201201                        futex_up(&rootfs_futex);
    202202                        vfs_node_put(mr_node);  /* failed -> drop reference */
     
    210210                 * This prevents the mount point from being deleted.
    211211                 */
    212                 futex_up(&unlink_futex);
     212                futex_up(&namespace_futex);
    213213        } else {
    214214                /*
  • uspace/srv/vfs/vfs_node.c

    r215e375 rf57f8ea  
    147147                node->index = triplet->index;
    148148                link_initialize(&node->nh_link);
     149                futex_initialize(&node->contents_futex, 1);
    149150                hash_table_insert(&nodes, key, &node->nh_link);
    150151        } else {
  • uspace/srv/vfs/vfs_open.c

    r215e375 rf57f8ea  
    9494         * triplet.
    9595         */
    96         futex_down(&unlink_futex);
     96        futex_down(&namespace_futex);
    9797
    9898        /*
     
    102102        rc = vfs_lookup_internal(path, size, &triplet, NULL);
    103103        if (rc) {
    104                 futex_up(&unlink_futex);
     104                futex_up(&namespace_futex);
    105105                ipc_answer_0(rid, rc);
    106106                free(path);
     
    114114
    115115        vfs_node_t *node = vfs_node_get(&triplet);
    116         futex_up(&unlink_futex);
     116        futex_up(&namespace_futex);
    117117
    118118        /*
  • uspace/srv/vfs/vfs_rdwr.c

    r215e375 rf57f8ea  
    4040#include <async.h>
    4141#include <errno.h>
     42#include <futex.h>
    4243
    4344static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read)
     
    8182        }
    8283
     84        /*
     85         * Lock the file's node so that no other client can read/write to it at
     86         * the same time.
     87         */
     88        futex_down(&file->node->contents_futex);
     89
    8390        int fs_phone = vfs_grab_phone(file->node->fs_handle);   
    8491       
     
    109116
    110117        /*
     118         * Unlock the VFS node.
     119         */
     120        futex_up(&file->node->contents_futex);
     121
     122        /*
    111123         * Update the position pointer.
    112124         */
  • uspace/srv/vfs/vfs_unlink.c

    r215e375 rf57f8ea  
    4141/**
    4242 * This futex prevents the race between a triplet-to-VFS-node resolution and a
    43  * concurrent VFS_UNLINK or VFS_RMDIR operation.
     43 * concurrent VFS operation which modifies the file system namespace.
    4444 */
    45 atomic_t unlink_futex = FUTEX_INITIALIZER;
     45atomic_t namespace_futex = FUTEX_INITIALIZER;
    4646
    4747/**
Note: See TracChangeset for help on using the changeset viewer.