Changeset 401 for trunk/kernel/vfs


Ignore:
Timestamp:
Aug 17, 2017, 3:02:18 PM (7 years ago)
Author:
alain
Message:

Few bugs in VMM

Location:
trunk/kernel/vfs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/vfs/fatfs.c

    r367 r401  
    2626#include <hal_special.h>
    2727#include <printk.h>
     28#include <thread.h>
    2829#include <kmem.h>
    2930#include <ppm.h>
     
    462463                                bool_t   to_mapper )
    463464{
    464     error_t error;
     465    error_t       error;
     466    vfs_inode_t * inode;
     467    mapper_t    * mapper;
     468    uint32_t      index;       // page index in mapper
     469    uint8_t     * buffer;      // page base address in mapper
     470    uint32_t      count;       // number of sectors in a page
     471    uint32_t      lba;         // block address on device
     472    fatfs_ctx_t * fatfs_ctx;   // pointer on local FATFS context
    465473
    466474    // get pointer on source mapper and page index from page descriptor
    467     mapper_t * mapper = page->mapper;
    468     uint32_t   index  = page->index;
     475    mapper = page->mapper;
     476    index  = page->index;
    469477
    470478    // get VFS inode pointer from mapper
    471     vfs_inode_t * inode = mapper->inode;
    472 
    473     fatfs_dmsg("\n[INFO] %s : enter for inode %x / page_index = %d / mapper = %x\n",
    474                __FUNCTION__ , inode , index , mapper );
    475 
    476     // get memory buffer base address
     479    inode = mapper->inode;
     480
     481    fatfs_dmsg("\n[INFO] %s : core[%x,%d] enter for inode %x / page_id = %d / mapper = %x\n",
     482    __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , index , mapper );
     483
     484    // get page to move base address
    477485    xptr_t base_xp = ppm_page2base( XPTR( local_cxy , page ) );
    478     uint8_t * buffer = (uint8_t *)GET_PTR( base_xp );
     486    buffer = (uint8_t *)GET_PTR( base_xp );
    479487 
    480     // get number of sectors from FATFS context
    481     fatfs_ctx_t * fatfs_ctx = (fatfs_ctx_t *)fs_context[FS_TYPE_FATFS].extend;
    482     uint32_t count = fatfs_ctx->sectors_per_cluster;
    483 
    484     // analyse the mapper type : FAT or normal inode
    485     if( inode == NULL )  // it is the FAT mapper
     488    // get number of sectors for one page (from FATFS context)
     489    fatfs_ctx = (fatfs_ctx_t *)fs_context[FS_TYPE_FATFS].extend;
     490    count = fatfs_ctx->sectors_per_cluster;
     491
     492    // test FAT/normal inode
     493    if( inode == NULL )      // it is the FAT mapper
    486494    {
    487495        // get lba from page index
    488         uint32_t lba = fatfs_ctx->fat_begin_lba + (count * index);
     496        lba = fatfs_ctx->fat_begin_lba + (count * index);
    489497 
    490         fatfs_dmsg("\n[INFO] %s : for FAT / lba = %d\n",
    491                    __FUNCTION__ , lba );
     498        fatfs_dmsg("\n[INFO] %s : core[%x,%d] access FAT on device / lba = %d\n",
     499        __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , lba );
    492500
    493501        // access device
     
    496504
    497505        if( error ) return EIO;
    498 
    499         fatfs_dmsg("\n[INFO] %s : exit for FAT / page_index = %d / mapper = %x\n",
    500                    __FUNCTION__ , index , mapper );
    501     }
    502     else                 // it is a normal inode mapper
     506    }
     507    else                     // it is a normal inode mapper
    503508    {
    504509        uint32_t  searched_cluster_id;
     
    506511        // get first_cluster_id from inode extension
    507512        uint32_t  first_cluster_id = (uint32_t)(intptr_t)inode->extend;
    508 
    509         fatfs_dmsg("\n[INFO] %s : for inode %x / first_cluster_id = %d\n",
    510                    __FUNCTION__ , inode , first_cluster_id );
    511513
    512514        // compute cluster_id
     
    544546
    545547        // get lba from cluster_id
    546         uint32_t lba = fatfs_lba_from_cluster( fatfs_ctx , searched_cluster_id );
    547 
    548         fatfs_dmsg("\n[INFO] %s : for inode %x / page = %d / cluster_id = %d / lba = %x\n",
    549                    __FUNCTION__ , inode , index , searched_cluster_id , lba );
     548        lba = fatfs_lba_from_cluster( fatfs_ctx , searched_cluster_id );
     549
     550        fatfs_dmsg("\n[INFO] %s : core[%x,%d] access device for inode %x / cluster_id = %d\n",
     551        __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , first_cluster_id );
    550552
    551553        // access device
     
    554556
    555557        if( error ) return EIO;
    556 
    557         fatfs_dmsg("\n[INFO] %s : exit for inode %x / page_index = %d / mapper = %x\n",
    558                    __FUNCTION__ , inode , index , mapper );
    559     }
     558    }
     559
     560    fatfs_dmsg("\n[INFO] %s : core[%x,%d] exit for inode %x / page_id = %d / mapper = %x\n",
     561    __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , inode , index , mapper );
    560562
    561563    return 0;
  • trunk/kernel/vfs/fatfs.h

    r367 r401  
    249249 * It must be called by a thread running in cluster containing the mapper.
    250250 * The pointer on the mapper and the page index in file are found in the page descriptor.
    251  * WARNING : The inode field in the mapper must be NULL for the FAT mapper.
    252  * This is used to implement a specific behaviour to access the FAT zone on device.
     251 * WARNING : The inode field in the mapper MUST be NULL for the FAT mapper, as this
     252 * is used to implement a specific behaviour to access the FAT zone on device.
    253253 *****************************************************************************************
    254254 * @ page      : local pointer on page descriptor.
  • trunk/kernel/vfs/vfs.c

    r395 r401  
    156156    error_t            error;
    157157
    158     vfs_dmsg("\n[INFO] %s : enter / local_cxy = %x / parent_xp = %l\n",
    159     __FUNCTION__ , local_cxy , dentry_xp );
     158    vfs_dmsg("\n[INFO] %s : core[%x,%d] enter / dentry_xp = %l\n",
     159    __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , dentry_xp );
    160160 
    161161    // check fs type and get pointer on context
     
    229229    remote_spinlock_init( XPTR( local_cxy , &inode->main_lock ) );
    230230
    231     vfs_dmsg("\n[INFO] %s : exit / child_xp = %l / parent_xp = %l\n",
    232     __FUNCTION__ , XPTR( local_cxy , inode ) , dentry_xp );
    233 
     231    vfs_dmsg("\n[INFO] %s : core[%x,%d] exit / inode_xp = %l / dentry_xp = %l\n",
     232    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, XPTR(local_cxy,inode), dentry_xp );
     233 
    234234    // return extended pointer on inode
    235235    *inode_xp = XPTR( local_cxy , inode );
     
    262262                        xptr_t        child_xp )
    263263{
    264     vfs_dmsg("\n[INFO] %s : enter for child <%s>\n",
    265              __FUNCTION__ , name );
     264    vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n",
     265    __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() );
    266266
    267267    error_t error = 0;
     
    292292    }
    293293
    294     vfs_dmsg("\n[INFO] %s : exit for child <%s>\n",
    295              __FUNCTION__ , name );
     294    vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for <%s> / cycle %d\n",
     295    __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , name , hal_time_stamp() );
    296296
    297297    return error;
     
    435435        kmem_req_t       req;        // request to kernel memory allocator
    436436
    437     vfs_dmsg("\n[INFO] %s : enter for %s / parent inode = %x / cycle = %d\n",
    438     __FUNCTION__ , name , parent , hal_time_stamp() );
     437    vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / parent inode = %x / cycle %d\n",
     438    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, parent, hal_time_stamp() );
    439439
    440440    // get pointer on context
     
    484484    *dentry_xp = XPTR( local_cxy , dentry );
    485485
    486     vfs_dmsg("\n[INFO] %s : exit for %s / cycle = %d\n",
    487     __FUNCTION__ , name , hal_time_stamp() );
     486    vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for <%s> / dentry = %l / cycle %d\n",
     487    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, name, *dentry_xp, hal_time_stamp() );
    488488
    489489    return 0;
     
    603603    uint32_t      file_id;      // created file descriptor index in reference fd_array
    604604
    605     vfs_dmsg("\n[INFO] %s : enters for <%s> at cycle %d\n",
    606              __FUNCTION__ , path , (uint32_t)hal_time_stamp() );
     605    vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n",
     606    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, (uint32_t)hal_time_stamp() );
    607607
    608608    // compute lookup working mode
     
    623623    error = vfs_lookup( cwd_xp , path , lookup_mode , &inode_xp );
    624624
    625     vfs_dmsg("\n[INFO] %s : get inode_xp = %l for <%s> at cycle %d\n",
    626              __FUNCTION__ , inode_xp , path , hal_get_cycles() );
    627 
    628625    if( error ) return error;
    629626
     
    649646    if( error ) return error;
    650647
    651     vfs_dmsg("\n[INFO] %s : exit for <%s> / file_id = %d / file_xp = %l / at cycle %d\n",
    652              __FUNCTION__ , path , file_id , file_xp , hal_get_cycles() );
     648    vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for <%s> / file_xp = %l / cycle %d\n",
     649    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, path, file_xp, hal_time_stamp() );
    653650
    654651    // success
     
    11851182
    11861183    // print header
    1187     nolock_printk("\n***** file system state\n");
     1184    nolock_printk("\n***** file system state\n\n");
    11881185
    11891186    // call recursive function
     
    13411338    process = this->process;
    13421339
    1343     vfs_dmsg("\n[INFO] %s : enter for <%s> / core[%x,%d] / cycle %d\n",
    1344     __FUNCTION__ , pathname , local_cxy , this->core->lid , hal_time_stamp() );
     1340    vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for <%s> / cycle %d\n",
     1341    __FUNCTION__ , local_cxy , this->core->lid , pathname , hal_time_stamp() );
    13451342
    13461343    // get extended pointer on first inode to search
     
    13571354    vfs_inode_lock( parent_xp );
    13581355
    1359     // load from device if one intermediate node not found
    1360     // exit while loop when last name found (i.e. last == true)
     1356    // sequencially loop on nodes in pathname
     1357    // load from device if one node not found in inode tree
     1358    // exit loop when last name found (i.e. last == true)
    13611359    do
    13621360    {
    1363         // get one name from path, and the "last" flag
     1361        // get one name from path, and "last" flag
    13641362        vfs_get_name_from_path( current , name , &next , &last );
    13651363
    1366         vfs_dmsg("\n[INFO] %s : looking for <%s> / core[%x,%d] / last = %d\n",
    1367         __FUNCTION__ , name , local_cxy , this->core->lid , last );
     1364        vfs_dmsg("\n[INFO] %s : core[%x,%d] look for <%s> / last = %d\n",
     1365        __FUNCTION__ , local_cxy , this->core->lid , name , last );
    13681366
    13691367        // search a child dentry matching name in parent inode
     
    13821380        if (found == false ) // child node not found in inode tree
    13831381        {
    1384             vfs_dmsg("\n[INFO] %s : <%s> not found => load it / core[%x,%d]\n",
    1385             __FUNCTION__ , local_cxy , this->core->lid );
     1382            vfs_dmsg("\n[INFO] %s : core[%x,%d] miss <%s> => load it\n",
     1383            __FUNCTION__ , local_cxy , this->core->lid , name );
    13861384
    13871385            // release lock on parent inode
     
    13911389            parent_cxy = GET_CXY( parent_xp );
    13921390            parent_ptr = (vfs_inode_t *)GET_PTR( parent_xp );
    1393 
    1394             ctx_ptr    = (vfs_ctx_t *)hal_remote_lpt( XPTR( parent_cxy ,
    1395                                                             &parent_ptr->ctx ) );
     1391            ctx_ptr    = (vfs_ctx_t *)hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->ctx ) );
    13961392            fs_type    = hal_remote_lw( XPTR( parent_cxy , &ctx_ptr->type ) );
    13971393
    13981394            // select a cluster for missing inode
    13991395            child_cxy = vfs_cluster_random_select();
    1400                     
     1396 
    14011397            // insert a new child dentry/inode in parent inode
    14021398            error = vfs_add_child_in_parent( child_cxy,
     
    14671463            // take lock on parent inode
    14681464            vfs_inode_lock( parent_xp );
     1465
     1466            vfs_dmsg("\n[INFO] %s : core[%x,%d] created node <%s>\n",
     1467            __FUNCTION__ , local_cxy , this->core->lid , name );
    14691468        }
    14701469
    1471         vfs_dmsg("\n[INFO] %s : found <%s> / core[%x,%d] / parent = %l / child = %l\n",
    1472         __FUNCTION__ , name , local_cxy , this->core->lid , parent_xp , child_xp );
     1470        vfs_dmsg("\n[INFO] %s : core[%x,%d] found <%s> / parent = %l / child = %l\n",
     1471        __FUNCTION__ , local_cxy , this->core->lid , name , parent_xp , child_xp );
    14731472
    14741473        // TODO check access rights here [AG]
     
    15191518    // implementation note:
    15201519    // we use two variables "index" and "count" because the buffer
    1521     // is actually written in decreasing index order (from leaf to root)
    1522     // TODO : handle conflict with a concurrent rename
    1523     // FIXME : handle synchro in the loop ... [AG]
     1520    // is written in decreasing index order (from leaf to root)
     1521    // TODO : handle conflict with a concurrent rename [AG]
     1522    // TODO : handle synchro in the loop [AG]
    15241523
    15251524        // set the NUL character in buffer / initialise buffer index and count
     
    16061605
    16071606        vfs_dmsg("\n[INFO] %s : dentry <%s> created in local cluster %x\n",
    1608                  __FUNCTION__ , name , local_cxy );
     1607        __FUNCTION__ , name , local_cxy );
    16091608    }
    16101609    else                               // parent cluster is remote
     
    16181617
    16191618        vfs_dmsg("\n[INFO] %s : dentry <%s> created in remote cluster %x\n",
    1620                  __FUNCTION__ , name , parent_cxy );
     1619        __FUNCTION__ , name , parent_cxy );
    16211620    }
    16221621                                     
     
    17081707    assert( (mapper != NULL) , __FUNCTION__ , "no mapper for page\n" );
    17091708
    1710     vfs_dmsg("\n[INFO] %s : enters for page %d in mapper / inode %l\n",
     1709    vfs_dmsg("\n[INFO] %s : enters for page %d in mapper / inode_xp %l\n",
    17111710    __FUNCTION__ , page->index , XPTR( local_cxy , &mapper->inode ) );
    17121711
     
    17541753    assert( (mapper != NULL) , __FUNCTION__ , "mapper pointer is NULL\n" );
    17551754
     1755    vfs_dmsg("\n[INFO] %s : core[%x,%d] enter for inode %l / cycle %d\n",
     1756    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, XPTR(local_cxy , inode) );
     1757
     1758    // compute number of pages
    17561759    uint32_t npages = size >> CONFIG_PPM_PAGE_SHIFT;
    17571760    if( (size & CONFIG_PPM_PAGE_MASK) || (size == 0) ) npages++;
     
    17671770    }
    17681771
     1772    vfs_dmsg("\n[INFO] %s : core[%x,%d] exit for inode %l / cycle %d\n",
     1773    __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, XPTR(local_cxy , inode) );
     1774
    17691775    return 0;
    17701776
Note: See TracChangeset for help on using the changeset viewer.