Changeset 79ae36dd in mainline for uspace/lib/fs/libfs.c


Ignore:
Timestamp:
2011-06-08T19:01:55Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0eff68e
Parents:
764d71e
Message:

new async framework with integrated exchange tracking

  • strict isolation between low-level IPC and high-level async framework with integrated exchange tracking
    • each IPC connection is represented by an async_sess_t structure
    • each IPC exchange is represented by an async_exch_t structure
    • exchange management is either based on atomic messages (EXCHANGE_ATOMIC), locking (EXCHANGE_SERIALIZE) or connection cloning (EXCHANGE_CLONE)
  • async_obsolete: temporary compatibility layer to keep old async clients working (several pieces of code are currently broken, but only non-essential functionality)
  • IPC_M_PHONE_HANGUP is now method no. 0 (for elegant boolean evaluation)
  • IPC_M_DEBUG_ALL has been renamed to IPC_M_DEBUG
  • IPC_M_PING has been removed (VFS protocol now has VFS_IN_PING)
  • console routines in libc have been rewritten for better abstraction
  • additional use for libc-private header files (FILE structure opaque to the client)
  • various cstyle changes (typos, indentation, missing externs in header files, improved comments, etc.)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/fs/libfs.c

    r764d71e r79ae36dd  
    6767 * code.
    6868 *
    69  * @param vfs_phone Open phone for communication with VFS.
    70  * @param reg       File system registration structure. It will be
    71  *                  initialized by this function.
    72  * @param info      VFS info structure supplied by the file system
    73  *                  implementation.
    74  * @param conn      Connection fibril for handling all calls originating in
    75  *                  VFS.
     69 * @param sess Session for communication with VFS.
     70 * @param reg  File system registration structure. It will be
     71 *             initialized by this function.
     72 * @param info VFS info structure supplied by the file system
     73 *             implementation.
     74 * @param conn Connection fibril for handling all calls originating in
     75 *             VFS.
    7676 *
    7777 * @return EOK on success or a non-zero error code on errror.
    7878 *
    7979 */
    80 int fs_register(int vfs_phone, fs_reg_t *reg, vfs_info_t *info,
     80int fs_register(async_sess_t *sess, fs_reg_t *reg, vfs_info_t *info,
    8181    async_client_conn_t conn)
    8282{
     
    8686         * out-of-order, when it knows that the operation succeeded or failed.
    8787         */
     88       
     89        async_exch_t *exch = async_exchange_begin(sess);
     90       
    8891        ipc_call_t answer;
    89         aid_t req = async_send_0(vfs_phone, VFS_IN_REGISTER, &answer);
     92        aid_t req = async_send_0(exch, VFS_IN_REGISTER, &answer);
    9093       
    9194        /*
    9295         * Send our VFS info structure to VFS.
    9396         */
    94         int rc = async_data_write_start(vfs_phone, info, sizeof(*info));
     97        int rc = async_data_write_start(exch, info, sizeof(*info));
     98       
    9599        if (rc != EOK) {
     100                async_exchange_end(exch);
    96101                async_wait_for(req, NULL);
    97102                return rc;
     
    101106         * Ask VFS for callback connection.
    102107         */
    103         async_connect_to_me(vfs_phone, 0, 0, 0, conn);
     108        async_connect_to_me(exch, 0, 0, 0, conn);
    104109       
    105110        /*
     
    108113        reg->plb_ro = as_get_mappable_page(PLB_SIZE);
    109114        if (!reg->plb_ro) {
     115                async_exchange_end(exch);
    110116                async_wait_for(req, NULL);
    111117                return ENOMEM;
     
    115121         * Request sharing the Path Lookup Buffer with VFS.
    116122         */
    117         rc = async_share_in_start_0_0(vfs_phone, reg->plb_ro, PLB_SIZE);
     123        rc = async_share_in_start_0_0(exch, reg->plb_ro, PLB_SIZE);
     124       
     125        async_exchange_end(exch);
     126       
    118127        if (rc) {
    119128                async_wait_for(req, NULL);
     
    148157        fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*request);
    149158        devmap_handle_t mr_devmap_handle = (devmap_handle_t) IPC_GET_ARG4(*request);
    150         int res;
    151         sysarg_t rc;
    152        
    153         ipc_call_t call;
    154         ipc_callid_t callid;
    155        
    156         /* Accept the phone */
    157         callid = async_get_call(&call);
    158         int mountee_phone = (int) IPC_GET_ARG1(call);
    159         if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECTION_CLONE) ||
    160             (mountee_phone < 0)) {
    161                 async_answer_0(callid, EINVAL);
     159       
     160        async_sess_t *mountee_sess = async_clone_receive(EXCHANGE_PARALLEL);
     161        if (mountee_sess == NULL) {
    162162                async_answer_0(rid, EINVAL);
    163163                return;
    164164        }
    165165       
    166         /* Acknowledge the mountee_phone */
    167         async_answer_0(callid, EOK);
    168        
    169166        fs_node_t *fn;
    170         res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index);
     167        int res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index);
    171168        if ((res != EOK) || (!fn)) {
    172                 async_hangup(mountee_phone);
     169                async_hangup(mountee_sess);
    173170                async_data_write_void(combine_rc(res, ENOENT));
    174171                async_answer_0(rid, combine_rc(res, ENOENT));
     
    177174       
    178175        if (fn->mp_data.mp_active) {
    179                 async_hangup(mountee_phone);
     176                async_hangup(mountee_sess);
    180177                (void) ops->node_put(fn);
    181178                async_data_write_void(EBUSY);
     
    184181        }
    185182       
    186         rc = async_req_0_0(mountee_phone, IPC_M_CONNECT_ME);
    187         if (rc != EOK) {
    188                 async_hangup(mountee_phone);
     183        async_exch_t *exch = async_exchange_begin(mountee_sess);
     184        async_sess_t *sess = async_connect_me(EXCHANGE_PARALLEL, exch);
     185       
     186        if (!sess) {
     187                async_exchange_end(exch);
     188                async_hangup(mountee_sess);
    189189                (void) ops->node_put(fn);
    190                 async_data_write_void(rc);
    191                 async_answer_0(rid, rc);
     190                async_data_write_void(errno);
     191                async_answer_0(rid, errno);
    192192                return;
    193193        }
    194194       
    195195        ipc_call_t answer;
    196         rc = async_data_write_forward_1_1(mountee_phone, VFS_OUT_MOUNTED,
     196        int rc = async_data_write_forward_1_1(exch, VFS_OUT_MOUNTED,
    197197            mr_devmap_handle, &answer);
     198        async_exchange_end(exch);
    198199       
    199200        if (rc == EOK) {
     
    201202                fn->mp_data.fs_handle = mr_fs_handle;
    202203                fn->mp_data.devmap_handle = mr_devmap_handle;
    203                 fn->mp_data.phone = mountee_phone;
     204                fn->mp_data.sess = mountee_sess;
    204205        }
    205206       
     
    236237         * Tell the mounted file system to unmount.
    237238         */
    238         res = async_req_1_0(fn->mp_data.phone, VFS_OUT_UNMOUNTED,
    239             fn->mp_data.devmap_handle);
     239        async_exch_t *exch = async_exchange_begin(fn->mp_data.sess);
     240        res = async_req_1_0(exch, VFS_OUT_UNMOUNTED, fn->mp_data.devmap_handle);
     241        async_exchange_end(exch);
    240242
    241243        /*
     
    243245         */
    244246        if (res == EOK) {
    245                 async_hangup(fn->mp_data.phone);
     247                async_hangup(fn->mp_data.sess);
    246248                fn->mp_data.mp_active = false;
    247249                fn->mp_data.fs_handle = 0;
    248250                fn->mp_data.devmap_handle = 0;
    249                 fn->mp_data.phone = 0;
     251                fn->mp_data.sess = NULL;
     252               
    250253                /* Drop the reference created in libfs_mount(). */
    251254                (void) ops->node_put(fn);
     
    293296       
    294297        if (cur->mp_data.mp_active) {
    295                 async_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP,
    296                     next, last, cur->mp_data.devmap_handle, lflag, index,
    297                     IPC_FF_ROUTE_FROM_ME);
     298                async_exch_t *exch = async_exchange_begin(cur->mp_data.sess);
     299                async_forward_slow(rid, exch, VFS_OUT_LOOKUP, next, last,
     300                    cur->mp_data.devmap_handle, lflag, index, IPC_FF_ROUTE_FROM_ME);
     301                async_exchange_end(exch);
     302               
    298303                (void) ops->node_put(cur);
    299304                return;
     
    351356                                next--;
    352357                       
    353                         async_forward_slow(rid, tmp->mp_data.phone,
    354                             VFS_OUT_LOOKUP, next, last, tmp->mp_data.devmap_handle,
    355                             lflag, index, IPC_FF_ROUTE_FROM_ME);
     358                        async_exch_t *exch = async_exchange_begin(tmp->mp_data.sess);
     359                        async_forward_slow(rid, exch, VFS_OUT_LOOKUP, next, last,
     360                            tmp->mp_data.devmap_handle, lflag, index,
     361                            IPC_FF_ROUTE_FROM_ME);
     362                        async_exchange_end(exch);
     363                       
    356364                        (void) ops->node_put(cur);
    357365                        (void) ops->node_put(tmp);
Note: See TracChangeset for help on using the changeset viewer.