Changeset 5f4cfb1e in mainline


Ignore:
Timestamp:
2007-09-28T10:36:31Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
13125d3
Parents:
566d798d
Message:

VFS work.
Upon FS registration via VFS_REGISTER, the client is assigned a unique file
system handle. When generating the VFS_LOOKUP request in VFS, we also need to
pass the device handle. Add function to transform file system handle to phone.
Implement basic multi-call VFS request serialization on VFS side.

Location:
uspace/srv
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat.c

    r566d798d r5f4cfb1e  
    4343#include <unistd.h>
    4444#include <stdio.h>
    45 #include <as.h>>
     45#include <as.h>
    4646#include "../../vfs/vfs.h"
    4747
     
    6565
    6666uint8_t *plb_ro = NULL;
     67
     68int fs_handle = 0;
    6769
    6870/**
     
    156158         * Request sharing the Path Lookup Buffer with VFS.
    157159         */
    158         rc = ipc_call_sync_3(vfs_phone, IPC_M_AS_AREA_RECV, plb_ro, PLB_SIZE, 0,
    159             NULL, NULL, NULL);
     160        rc = ipc_call_sync_3(vfs_phone, IPC_M_AS_AREA_RECV, (ipcarg_t) plb_ro,
     161            PLB_SIZE, 0, NULL, NULL, NULL);
    160162        if (rc) {
    161163                async_wait_for(req, NULL);
     
    164166         
    165167        /*
     168         * Pick up the answer for the request to the VFS_REQUEST call.
     169         */
     170        async_wait_for(req, NULL);
     171        fs_handle = (int) IPC_GET_ARG1(answer);
     172        dprintf("FAT filesystem registered, fs_handle=%d.\n", fs_handle);
     173
     174        /*
    166175         * Create a connection fibril to handle the callback connection.
    167176         */
     
    173182         */
    174183        async_set_client_connection(fat_connection);
    175 
    176         /*
    177          * Pick up the answer for the request to the VFS_REQUEST call.
    178          */
    179         async_wait_for(req, NULL);
    180         dprintf("FAT filesystem registered.\n");
    181184
    182185        async_create_manager();
  • uspace/srv/vfs/vfs.h

    r566d798d r5f4cfb1e  
    9393        link_t fs_link;
    9494        vfs_info_t vfs_info;
     95        int fs_handle;
     96        atomic_t phone_futex;   /**< Phone serializing futex. */
    9597        ipcarg_t phone;
    9698} fs_info_t;
     
    143145extern link_t plb_head;         /**< List of active PLB entries. */
    144146
     147extern int vfs_grab_phone(int);
     148extern void vfs_release_phone(int);
     149
    145150extern int vfs_lookup_internal(char *path, size_t len, vfs_node_t *result);
    146151
  • uspace/srv/vfs/vfs_lookup.c

    r566d798d r5f4cfb1e  
    126126
    127127        ipc_call_t answer;
    128         int phone = 0;          /* TODO */
    129         aid_t req = async_send_2(phone, VFS_LOOKUP, (ipcarg_t) first,
    130             (ipcarg_t) last, &answer);
     128        int phone = vfs_grab_phone(rootfs->fs_handle);
     129        aid_t req = async_send_3(phone, VFS_LOOKUP, (ipcarg_t) first,
     130            (ipcarg_t) last, (ipcarg_t) rootfs->dev_handle, &answer);
     131        vfs_release_phone(phone);
    131132
    132133        ipcarg_t rc;
  • uspace/srv/vfs/vfs_register.c

    r566d798d r5f4cfb1e  
    4848#include <as.h>
    4949#include <libadt/list.h>
     50#include <assert.h>
    5051#include "vfs.h"
    5152
    5253atomic_t fs_head_futex = FUTEX_INITIALIZER;
    5354link_t fs_head;
     55
     56atomic_t fs_handle_next = {
     57        .count = 1
     58};
    5459
    5560/** Verify the VFS info structure.
     
    306311        /*
    307312         * That was it. The FS has been registered.
    308          */
    309         ipc_answer_fast(rid, EOK, 0, 0);
    310         dprintf("\"%s\" filesystem successfully registered.\n",
    311             fs_info->vfs_info.name);
    312 
     313         * In reply to the VFS_REGISTER request, we assign the client file
     314         * system a global file system handle.
     315         */
     316        fs_info->fs_handle = (int) atomic_postinc(&fs_handle_next);
     317        ipc_answer_fast(rid, EOK, (ipcarg_t) fs_info->fs_handle, 0);
     318        dprintf("\"%s\" filesystem successfully registered, handle=%d.\n",
     319            fs_info->vfs_info.name, fs_info->fs_handle);
     320
     321}
     322
     323/** For a given file system handle, implement policy for allocating a phone.
     324 *
     325 * @param handle        File system handle.
     326 *
     327 * @return              Phone over which a multi-call request can be safely
     328 *                      sent. Return 0 if no phone was found.
     329 */
     330int vfs_grab_phone(int handle)
     331{
     332        /*
     333         * For now, we don't try to be very clever and very fast.
     334         * We simply lookup the phone in the fs_head list. We currently don't
     335         * open any additional phones (even though that itself would be pretty
     336         * straightforward; housekeeping multiple open phones to a FS task would
     337         * be more demanding). Instead, we simply take the respective
     338         * phone_futex and keep it until vfs_release_phone().
     339         */
     340        futex_down(&fs_head_futex);
     341        link_t *cur;
     342        fs_info_t *fs;
     343        for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
     344                fs = list_get_instance(cur, fs_info_t, fs_link);
     345                if (fs->fs_handle == handle) {
     346                        futex_up(&fs_head_futex);
     347                        /*
     348                         * For now, take the futex unconditionally.
     349                         * Oh yeah, serialization rocks.
     350                         * It will be up'ed in vfs_release_phone().
     351                         */
     352                        futex_down(&fs->phone_futex);
     353                        return fs->phone;
     354                }
     355        }
     356        futex_up(&fs_head_futex);
     357        return 0;
     358}
     359
     360/** Tell VFS that the phone is in use for any request.
     361 *
     362 * @param phone         Phone to FS task.
     363 */
     364void vfs_release_phone(int phone)
     365{
     366        bool found = false;
     367
     368        futex_down(&fs_head_futex);
     369        link_t *cur;
     370        for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
     371                fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
     372                if (fs->phone == phone) {
     373                        found = true;
     374                        futex_up(&fs_head_futex);
     375                        futex_up(&fs->phone_futex);
     376                        return;
     377                }
     378        }
     379        futex_up(&fs_head_futex);
     380
     381        /*
     382         * Not good to get here.
     383         */
     384        assert(found == true);
    313385}
    314386
Note: See TracChangeset for help on using the changeset viewer.