Changeset 34ca870 in mainline


Ignore:
Timestamp:
2009-06-17T21:07:56Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6ebe721
Parents:
61d2315
Message:

Handle each VFS request using a dedicated connection.

Location:
uspace/srv/vfs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs_lookup.c

    r61d2315 r34ca870  
    164164            (ipcarg_t) root->dev_handle, (ipcarg_t) lflag, (ipcarg_t) index,
    165165            &answer);
    166         vfs_release_phone(phone);
    167166       
    168167        ipcarg_t rc;
    169168        async_wait_for(req, &rc);
     169        vfs_release_phone(phone);
    170170       
    171171        futex_down(&plb_futex);
     
    209209            (ipcarg_t) result->triplet.index, &answer);
    210210       
    211         vfs_release_phone(phone);
    212211       
    213212        ipcarg_t rc;
    214213        async_wait_for(req, &rc);
     214        vfs_release_phone(phone);
    215215       
    216216        if (rc == EOK) {
  • uspace/srv/vfs/vfs_ops.c

    r61d2315 r34ca870  
    144144                            str_size(opts));
    145145                        if (rc != EOK) {
     146                                async_wait_for(msg, NULL);
    146147                                vfs_release_phone(phone);
    147                                 async_wait_for(msg, NULL);
    148148                                fibril_rwlock_write_unlock(&namespace_rwlock);
    149149                                ipc_answer_0(rid, rc);
    150150                                return;
    151151                        }
     152                        async_wait_for(msg, &rc);
    152153                        vfs_release_phone(phone);
    153                         async_wait_for(msg, &rc);
    154154                       
    155155                        if (rc != EOK) {
     
    198198        int mountee_phone = vfs_grab_phone(fs_handle);
    199199        assert(mountee_phone >= 0);
    200         vfs_release_phone(mountee_phone);
    201200
    202201        phone = vfs_grab_phone(mp_res.triplet.fs_handle);
     
    210209        rc = async_req_1_0(phone, IPC_M_CONNECTION_CLONE, mountee_phone);
    211210        if (rc != EOK) {
     211                async_wait_for(msg, NULL);
     212                vfs_release_phone(mountee_phone);
    212213                vfs_release_phone(phone);
    213                 async_wait_for(msg, NULL);
    214214                /* Mount failed, drop reference to mp_node. */
    215215                if (mp_node)
     
    219219                return;
    220220        }
     221
     222        vfs_release_phone(mountee_phone);
    221223       
    222224        /* send the mount options */
    223225        rc = ipc_data_write_start(phone, (void *)opts, str_size(opts));
    224226        if (rc != EOK) {
     227                async_wait_for(msg, NULL);
    225228                vfs_release_phone(phone);
    226                 async_wait_for(msg, NULL);
    227229                /* Mount failed, drop reference to mp_node. */
    228230                if (mp_node)
     
    232234                return;
    233235        }
     236        async_wait_for(msg, &rc);
    234237        vfs_release_phone(phone);
    235         async_wait_for(msg, &rc);
    236238       
    237239        if (rc == EOK) {
     
    756758        msg = async_send_2(fs_phone, IPC_GET_METHOD(*request),
    757759            file->node->dev_handle, file->node->index, &answer);
    758        
    759         vfs_release_phone(fs_phone);
    760760
    761761        /* Wait for reply from the FS server. */
    762762        ipcarg_t rc;
    763763        async_wait_for(msg, &rc);
    764        
     764
     765        vfs_release_phone(fs_phone);
    765766        fibril_mutex_unlock(&file->lock);
    766767       
     
    792793            file->node->dev_handle, file->node->index, &answer);
    793794
    794         vfs_release_phone(fs_phone);
    795 
    796795        /* Wait for reply from the FS server. */
    797796        ipcarg_t rc;
    798797        async_wait_for(msg, &rc);
    799798       
     799        vfs_release_phone(fs_phone);
    800800        fibril_mutex_unlock(&file->lock);
    801801       
     
    819819         */
    820820        fibril_mutex_lock(&file->lock);
    821        
    822821        int fs_phone = vfs_grab_phone(file->node->fs_handle);
    823822       
     
    828827            file->node->dev_handle, file->node->index, &answer);
    829828
    830         vfs_release_phone(fs_phone);
    831        
    832829        /* Wait for reply from the FS server. */
    833830        ipcarg_t rc;
    834831        async_wait_for(msg, &rc);
    835        
     832
     833        vfs_release_phone(fs_phone);
    836834        fibril_mutex_unlock(&file->lock);
    837835       
     
    924922        ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
    925923
    926         vfs_release_phone(fs_phone);
    927        
    928924        /* Wait for reply from the FS server. */
    929925        ipcarg_t rc;
    930926        async_wait_for(msg, &rc);
     927       
     928        vfs_release_phone(fs_phone);
    931929       
    932930        size_t bytes = IPC_GET_ARG1(answer);
  • uspace/srv/vfs/vfs_register.c

    r61d2315 r34ca870  
    286286int vfs_grab_phone(fs_handle_t handle)
    287287{
    288         /*
    289          * For now, we don't try to be very clever and very fast.
    290          * We simply lookup the phone in the fs_head list. We currently don't
    291          * open any additional phones (even though that itself would be pretty
    292          * straightforward; housekeeping multiple open phones to a FS task would
    293          * be more demanding). Instead, we simply take the respective
    294          * phone_futex and keep it until vfs_release_phone().
     288        int phone;
     289
     290        /*
     291         * For now, we don't try to be very clever and very fast.  We simply
     292         * lookup the phone in the fs_head list and duplicate it.  The duplicate
     293         * phone will be returned to the client and the client will use it for
     294         * communication.  In the future, we should cache the connections so
     295         * that they do not have to be reestablished over and over again.
    295296         */
    296297        fibril_mutex_lock(&fs_head_lock);
     
    302303                        fibril_mutex_unlock(&fs_head_lock);
    303304                        fibril_mutex_lock(&fs->phone_lock);
    304                         return fs->phone;
     305                        phone = ipc_connect_me_to(fs->phone, 0, 0, 0);
     306                        fibril_mutex_unlock(&fs->phone_lock);
     307
     308                        assert(phone > 0);
     309                        return phone;
    305310                }
    306311        }
     
    309314}
    310315
    311 /** Tell VFS that the phone is in use for any request.
     316/** Tell VFS that the phone is not needed anymore.
    312317 *
    313318 * @param phone         Phone to FS task.
     
    315320void vfs_release_phone(int phone)
    316321{
    317         bool found = false;
    318 
    319         fibril_mutex_lock(&fs_head_lock);
    320         link_t *cur;
    321         for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
    322                 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
    323                 if (fs->phone == phone) {
    324                         found = true;
    325                         fibril_mutex_unlock(&fs_head_lock);
    326                         fibril_mutex_unlock(&fs->phone_lock);
    327                         return;
    328                 }
    329         }
    330         fibril_mutex_unlock(&fs_head_lock);
    331 
    332         /*
    333          * Not good to get here.
    334          */
    335         assert(found == true);
     322        /* TODO: implement connection caching */
     323        ipc_hangup(phone);
    336324}
    337325
Note: See TracChangeset for help on using the changeset viewer.