Ignore:
Timestamp:
Dec 27, 2018, 7:38:58 PM (3 years ago)
Author:
alain
Message:

Fix several bugs in VFS to support the following
ksh commandis : cp, mv, rm, mkdir, cd, pwd

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/rpc.c

    r601 r610  
    7575    &rpc_kcm_alloc_server,                 // 22
    7676    &rpc_kcm_free_server,                  // 23
    77     &rpc_mapper_move_user_server,          // 24
     77    &rpc_undefined,                        // 24   unused slot
    7878    &rpc_mapper_handle_miss_server,        // 25
    7979    &rpc_undefined,                        // 26   unused slot
     
    111111    "KCM_ALLOC",                 // 22
    112112    "KCM_FREE",                  // 23
    113     "MAPPER_MOVE_USER",          // 24
     113    "undefined",                 // 24
    114114    "MAPPER_HANDLE_MISS",        // 25
    115115    "undefined",                 // 26
     
    302302uint32_t cycle = (uint32_t)hal_get_cycles();
    303303if( DEBUG_RPC_SERVER_GENERIC < cycle )
    304 printk("\n[DBG] %s : RPC thread %x on core[%d] takes RPC_FIFO ownership / cycle %d\n",
     304printk("\n[%s] RPC thread %x on core[%d] takes RPC_FIFO ownership / cycle %d\n",
    305305__FUNCTION__, server_ptr->trdid, server_core_lid, cycle );
    306306#endif
     
    318318                desc_ptr = GET_PTR( desc_xp );
    319319
    320                     index    = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->index ) );
    321                 blocking = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->blocking ) );
     320                    index      = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->index ) );
     321                blocking   = hal_remote_l32( XPTR( desc_cxy , &desc_ptr->blocking ) );
     322                client_ptr = hal_remote_lpt( XPTR( desc_cxy , &desc_ptr->thread ) );
    322323
    323324#if DEBUG_RPC_SERVER_GENERIC
     
    325326uint32_t items = remote_fifo_items( XPTR( local_cxy , rpc_fifo ) );
    326327if( DEBUG_RPC_SERVER_GENERIC < cycle )
    327 printk("\n[DBG] %s : RPC thread %x got rpc %s / client_cxy %x / items %d / cycle %d\n",
     328printk("\n[%s] RPC thread %x got rpc %s / client_cxy %x / items %d / cycle %d\n",
    328329__FUNCTION__, server_ptr->trdid, rpc_str[index], desc_cxy, items, cycle );
    329330#endif
     331                // register client thread in RPC thread descriptor
     332                server_ptr->rpc_client_xp = XPTR( desc_cxy , client_ptr );
     333 
    330334                // call the relevant server function
    331335                rpc_server[index]( desc_xp );
     
    334338cycle = (uint32_t)hal_get_cycles();
    335339if( DEBUG_RPC_SERVER_GENERIC < cycle )
    336 printk("\n[DBG] %s : RPC thread %x completes rpc %s / client_cxy %x / cycle %d\n",
     340printk("\n[%s] RPC thread %x completes rpc %s / client_cxy %x / cycle %d\n",
    337341__FUNCTION__, server_ptr->trdid, rpc_str[index], desc_cxy, cycle );
    338342#endif
     
    355359cycle = (uint32_t)hal_get_cycles();
    356360if( DEBUG_RPC_SERVER_GENERIC < cycle )
    357 printk("\n[DBG] %s : RPC thread %x unblocked client thread %x / cycle %d\n",
     361printk("\n[%s] RPC thread %x unblocked client thread %x / cycle %d\n",
    358362__FUNCTION__, server_ptr->trdid, client_ptr->trdid, cycle );
    359363#endif
     
    372376uint32_t cycle = (uint32_t)hal_get_cycles();
    373377if( DEBUG_RPC_SERVER_GENERIC < cycle )
    374 printk("\n[DBG] %s : RPC thread %x suicides / cycle %d\n",
     378printk("\n[%s] RPC thread %x suicides / cycle %d\n",
    375379__FUNCTION__, server_ptr->trdid, cycle );
    376380#endif
     
    391395uint32_t cycle = (uint32_t)hal_get_cycles();
    392396if( DEBUG_RPC_SERVER_GENERIC < cycle )
    393 printk("\n[DBG] %s : RPC thread %x block IDLE & deschedules / cycle %d\n",
     397printk("\n[%s] RPC thread %x block IDLE & deschedules / cycle %d\n",
    394398__FUNCTION__, server_ptr->trdid, cycle );
    395399#endif
     
    870874uint32_t  action = rpc->args[0];
    871875pid_t     pid    = rpc->args[1];
     876thread_t * this = CURRENT_THREAD;
    872877if( DEBUG_RPC_PROCESS_SIGACTION < cycle )
    873 printk("\n[DBG] %s : enter to request %s of process %x in cluster %x / cycle %d\n",
    874 __FUNCTION__ , process_action_str( action ) , pid , cxy , cycle );
     878printk("\n[%s] thread[%x,%x] enter to request %s of process %x in cluster %x / cycle %d\n",
     879__FUNCTION__, this->process->pid, this->trdid, process_action_str(action), pid, cxy, cycle );
    875880#endif
    876881
     
    885890cycle = (uint32_t)hal_get_cycles();
    886891if( DEBUG_RPC_PROCESS_SIGACTION < cycle )
    887 printk("\n[DBG] %s : exit after requesting to %s process %x in cluster %x / cycle %d\n",
    888 __FUNCTION__ , process_action_str( action ) , pid , cxy , cycle );
     892printk("\n[%s] thread[%x,%x] requested %s of process %x in cluster %x / cycle %d\n",
     893__FUNCTION__, this->process->pid, this->trdid, process_action_str(action), pid, cxy, cycle );
    889894#endif
    890895
     
    915920#if DEBUG_RPC_PROCESS_SIGACTION
    916921uint32_t cycle = (uint32_t)hal_get_cycles();
     922thread_t * this = CURRENT_THREAD;
    917923if( DEBUG_RPC_PROCESS_SIGACTION < cycle )
    918 printk("\n[DBG] %s : enter to %s process %x in cluster %x / cycle %d\n",
    919 __FUNCTION__ , process_action_str( action ) , pid , local_cxy , cycle );
     924printk("\n[%s] thread[%x,%x] enter to %s process %x in cluster %x / cycle %d\n",
     925__FUNCTION__, this->process->pid, this->trdid,
     926process_action_str( action ), pid, local_cxy, cycle );
    920927#endif
    921928
     
    954961cycle = (uint32_t)hal_get_cycles();
    955962if( DEBUG_RPC_PROCESS_SIGACTION < cycle )
    956 printk("\n[DBG] %s : exit after %s process %x in cluster %x / cycle %d\n",
    957 __FUNCTION__ , process_action_str( action ) , pid , local_cxy , cycle );
     963printk("\n[%s] thread[%x,%x] exit after %s process %x in cluster %x / cycle %d\n",
     964__FUNCTION__, this->process->pid, this->trdid,
     965process_action_str( action ), pid, local_cxy, cycle );
    958966#endif
    959967
     
    966974/////////////////////////////////////////////////////
    967975void rpc_vfs_inode_create_client( cxy_t          cxy,     
    968                                   xptr_t         dentry_xp,  // in
    969976                                  uint32_t       fs_type,    // in
    970977                                  uint32_t       inode_type, // in
     
    9931000
    9941001    // set input arguments in RPC descriptor
    995     rpc.args[0] = (uint64_t)dentry_xp;
    996     rpc.args[1] = (uint64_t)fs_type;
    997     rpc.args[2] = (uint64_t)inode_type;
    998     rpc.args[3] = (uint64_t)attr;
    999     rpc.args[4] = (uint64_t)rights;
    1000     rpc.args[5] = (uint64_t)uid;
    1001     rpc.args[6] = (uint64_t)gid;
     1002    rpc.args[0] = (uint64_t)fs_type;
     1003    rpc.args[1] = (uint64_t)inode_type;
     1004    rpc.args[2] = (uint64_t)attr;
     1005    rpc.args[3] = (uint64_t)rights;
     1006    rpc.args[4] = (uint64_t)uid;
     1007    rpc.args[5] = (uint64_t)gid;
    10021008
    10031009    // register RPC request in remote RPC fifo
     
    10051011
    10061012    // get output values from RPC descriptor
    1007     *inode_xp = (xptr_t)rpc.args[7];
    1008     *error    = (error_t)rpc.args[8];
     1013    *inode_xp = (xptr_t)rpc.args[6];
     1014    *error    = (error_t)rpc.args[7];
    10091015
    10101016#if DEBUG_RPC_VFS_INODE_CREATE
     
    10271033#endif
    10281034
    1029     xptr_t           dentry_xp;
    10301035    uint32_t         fs_type;
    10311036    uint32_t         inode_type;
     
    10421047
    10431048    // get input arguments from client rpc descriptor
    1044     dentry_xp  = (xptr_t)    hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
    1045     fs_type    = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
    1046     inode_type = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
    1047     attr       = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
    1048     rights     = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) );
    1049     uid        = (uid_t)     hal_remote_l64( XPTR( client_cxy , &desc->args[5] ) );
    1050     gid        = (gid_t)     hal_remote_l64( XPTR( client_cxy , &desc->args[6] ) );
     1049    fs_type    = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
     1050    inode_type = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
     1051    attr       = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
     1052    rights     = (uint32_t)  hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
     1053    uid        = (uid_t)     hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) );
     1054    gid        = (gid_t)     hal_remote_l64( XPTR( client_cxy , &desc->args[5] ) );
    10511055
    10521056    // call local kernel function
    1053     error = vfs_inode_create( dentry_xp,
    1054                               fs_type,
     1057    error = vfs_inode_create( fs_type,
    10551058                              inode_type,
    10561059                              attr,
     
    10611064
    10621065    // set output arguments
    1063     hal_remote_s64( XPTR( client_cxy , &desc->args[7] ) , (uint64_t)inode_xp );
    1064     hal_remote_s64( XPTR( client_cxy , &desc->args[8] ) , (uint64_t)error );
     1066    hal_remote_s64( XPTR( client_cxy , &desc->args[6] ) , (uint64_t)inode_xp );
     1067    hal_remote_s64( XPTR( client_cxy , &desc->args[7] ) , (uint64_t)error );
    10651068
    10661069#if DEBUG_RPC_VFS_INODE_CREATE
     
    11491152                                   uint32_t               type,         // in
    11501153                                   char                 * name,         // in
    1151                                    struct vfs_inode_s   * parent,       // in
    11521154                                   xptr_t               * dentry_xp,    // out
    11531155                                   error_t              * error )       // out
     
    11721174    rpc.args[0] = (uint64_t)type;
    11731175    rpc.args[1] = (uint64_t)(intptr_t)name;
    1174     rpc.args[2] = (uint64_t)(intptr_t)parent;
    11751176
    11761177    // register RPC request in remote RPC fifo
     
    11781179
    11791180    // get output values from RPC descriptor
    1180     *dentry_xp = (xptr_t)rpc.args[3];
    1181     *error     = (error_t)rpc.args[4];
     1181    *dentry_xp = (xptr_t)rpc.args[2];
     1182    *error     = (error_t)rpc.args[3];
    11821183
    11831184#if DEBUG_RPC_VFS_DENTRY_CREATE
     
    12021203    uint32_t      type;
    12031204    char        * name;
    1204     vfs_inode_t * parent;
    12051205    xptr_t        dentry_xp;
    12061206    error_t       error;
     
    12121212
    12131213    // get arguments "name", "type", and "parent" from client RPC descriptor
    1214     type   = (uint32_t)               hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
    1215     name   = (char *)(intptr_t)       hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
    1216     parent = (vfs_inode_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
     1214    type   = (uint32_t)         hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
     1215    name   = (char *)(intptr_t) hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
    12171216
    12181217    // makes a local copy of  name
     
    12231222    error = vfs_dentry_create( type,
    12241223                               name_copy,
    1225                                parent,
    12261224                               &dentry_xp );
    12271225    // set output arguments
    1228     hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)dentry_xp );
    1229     hal_remote_s64( XPTR( client_cxy , &desc->args[4] ) , (uint64_t)error );
     1226    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)dentry_xp );
     1227    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
    12301228
    12311229#if DEBUG_RPC_VFS_DENTRY_CREATE
     
    21122110
    21132111/////////////////////////////////////////////////////////////////////////////////////////
    2114 // [24]          Marshaling functions attached to RPC_MAPPER_MOVE_USER 
    2115 /////////////////////////////////////////////////////////////////////////////////////////
    2116 
    2117 /////////////////////////////////////////////////
    2118 void rpc_mapper_move_user_client( cxy_t      cxy,
    2119                                   mapper_t * mapper,        // in
    2120                                   bool_t     to_buffer,     // in
    2121                                   uint32_t   file_offset,   // in
    2122                                   void     * buffer,        // in
    2123                                   uint32_t   size,          // in
    2124                                   error_t  * error )        // out
    2125 {
    2126 #if DEBUG_RPC_MAPPER_MOVE_USER
    2127 uint32_t cycle = (uint32_t)hal_get_cycles();
    2128 if( cycle > DEBUG_RPC_MAPPER_MOVE_USER )
    2129 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
    2130 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
    2131 #endif
    2132 
    2133     assert( (cxy != local_cxy) , "target cluster is not remote\n");
    2134 
    2135     // initialise RPC descriptor header
    2136     rpc_desc_t  rpc;
    2137     rpc.index    = RPC_MAPPER_MOVE_USER;
    2138     rpc.blocking = true;
    2139     rpc.responses = 1;
    2140 
    2141     // set input arguments in RPC descriptor
    2142     rpc.args[0] = (uint64_t)(intptr_t)mapper;
    2143     rpc.args[1] = (uint64_t)to_buffer;
    2144     rpc.args[2] = (uint64_t)file_offset;
    2145     rpc.args[3] = (uint64_t)(intptr_t)buffer;
    2146     rpc.args[4] = (uint64_t)size;
    2147 
    2148     // register RPC request in remote RPC fifo
    2149     rpc_send( cxy , &rpc );
    2150 
    2151     // get output values from RPC descriptor
    2152     *error     = (error_t)rpc.args[5];
    2153 
    2154 #if DEBUG_RPC_MAPPER_MOVE_USER
    2155 cycle = (uint32_t)hal_get_cycles();
    2156 if( cycle > DEBUG_RPC_MAPPER_MOVE_USER )
    2157 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
    2158 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
    2159 #endif
    2160 }
    2161 
    2162 /////////////////////////////////////////////
    2163 void rpc_mapper_move_user_server( xptr_t xp )
    2164 {
    2165 #if DEBUG_RPC_MAPPER_MOVE_USER
    2166 uint32_t cycle = (uint32_t)hal_get_cycles();
    2167 if( cycle > DEBUG_RPC_MAPPER_MOVE_USER )
    2168 printk("\n[%s] thread[%x,%x] on core %d enter / cycle %d\n",
    2169 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
    2170 #endif
    2171 
    2172     mapper_t * mapper;
    2173     bool_t     to_buffer;
    2174     uint32_t   file_offset;
    2175     void     * buffer;
    2176     uint32_t   size;
    2177     error_t    error;
    2178 
    2179     // get client cluster identifier and pointer on RPC descriptor
    2180     cxy_t        client_cxy  = GET_CXY( xp );
    2181     rpc_desc_t * desc        = GET_PTR( xp );
    2182 
    2183     // get arguments from client RPC descriptor
    2184     mapper      = (mapper_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) );
    2185     to_buffer   =                       hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) );
    2186     file_offset =                       hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) );
    2187     buffer      = (void *)(intptr_t)    hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) );
    2188     size        =                       hal_remote_l64( XPTR( client_cxy , &desc->args[4] ) );
    2189 
    2190     // call local kernel function
    2191     error = mapper_move_user( mapper,
    2192                               to_buffer,
    2193                               file_offset,
    2194                               buffer,
    2195                               size );
    2196 
    2197     // set output argument to client RPC descriptor
    2198     hal_remote_s64( XPTR( client_cxy , &desc->args[6] ) , (uint64_t)error );
    2199 
    2200 #if DEBUG_RPC_MAPPER_MOVE_USER
    2201 cycle = (uint32_t)hal_get_cycles();
    2202 if( cycle > DEBUG_RPC_MAPPER_MOVE_USER )
    2203 printk("\n[%s] thread[%x,%x] on core %d exit / cycle %d\n",
    2204 __FUNCTION__, this->process->pid, this->trdid, this->core->lid , cycle );
    2205 #endif
    2206 }
     2112// [24]          undefined slot
     2113/////////////////////////////////////////////////////////////////////////////////////////
    22072114
    22082115/////////////////////////////////////////////////////////////////////////////////////////
     
    22802187
    22812188    // set output argument to client RPC descriptor
    2282     hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)error );
    2283     hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)page_xp );
     2189    hal_remote_s64( XPTR( client_cxy , &desc->args[2] ) , (uint64_t)page_xp );
     2190    hal_remote_s64( XPTR( client_cxy , &desc->args[3] ) , (uint64_t)error );
    22842191
    22852192#if DEBUG_RPC_MAPPER_HANDLE_MISS
Note: See TracChangeset for help on using the changeset viewer.