Changeset 635 for trunk/kernel/fs/vfs.c


Ignore:
Timestamp:
Jun 26, 2019, 11:42:37 AM (15 months ago)
Author:
alain
Message:

This version is a major evolution: The physical memory allocators,
defined in the kmem.c, ppm.c, and kcm.c files have been modified
to support remote accesses. The RPCs that were previously user
to allocate physical memory in a remote cluster have been removed.
This has been done to cure a dead-lock in case of concurrent page-faults.

This version 2.2 has been tested on a (4 clusters / 2 cores per cluster)
TSAR architecture, for both the "sort" and the "fft" applications.

File:
1 edited

Legend:

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

    r634 r635  
    150150    mapper_t         * mapper;     // associated mapper( to be allocated)
    151151    vfs_inode_t      * inode;      // inode descriptor (to be allocated)
     152   
    152153    uint32_t           inum;       // inode identifier (to be allocated)
    153154    vfs_ctx_t        * ctx;        // file system context
     
    155156    error_t            error;
    156157
    157 #if DEBUG_VFS_INODE_CREATE
    158 char           name[CONFIG_VFS_MAX_NAME_LENGTH];
    159 uint32_t       cycle      = (uint32_t)hal_get_cycles();
    160 cxy_t          dentry_cxy = GET_CXY( dentry_xp );
    161 vfs_dentry_t * dentry_ptr = GET_PTR( dentry_xp );
    162 thread_t *     this       = CURRENT_THREAD;
    163 if( dentry_xp != XPTR_NULL ) hal_remote_strcpy( XPTR( local_cxy  , name ),
    164                                                 XPTR( dentry_cxy , dentry_ptr->name ) );
    165 else                         strcpy( name , "/" );
    166 if( DEBUG_VFS_INODE_CREATE < cycle )
    167 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n",
    168 __FUNCTION__, this->process->pid, this->trdid, name, cycle );
    169 #endif
    170  
    171158    // check fs type and get pointer on context
    172159    if     ( fs_type == FS_TYPE_FATFS ) ctx = &fs_context[FS_TYPE_FATFS];
     
    198185    }
    199186
    200     // allocate memory for VFS inode descriptor
    201         req.type  = KMEM_VFS_INODE;
    202         req.size  = sizeof(vfs_inode_t);
     187// check inode descriptor contained in one page
     188assert( (sizeof(vfs_inode_t) <= CONFIG_PPM_PAGE_SIZE),
     189"inode descriptor must fit in one page" );
     190
     191    // allocate one page for VFS inode descriptor
     192    // because the embedded "children xhtab footprint
     193        req.type  = KMEM_PPM;
     194        req.order = 0;
    203195    req.flags = AF_KERNEL | AF_ZERO;
    204         inode     = (vfs_inode_t *)kmem_alloc( &req );
     196        inode     = kmem_alloc( &req );
    205197
    206198    if( inode == NULL )
     
    243235
    244236#if DEBUG_VFS_INODE_CREATE
    245 cycle      = (uint32_t)hal_get_cycles();
     237char           name[CONFIG_VFS_MAX_NAME_LENGTH];
     238uint32_t       cycle      = (uint32_t)hal_get_cycles();
     239thread_t *     this       = CURRENT_THREAD;
     240vfs_inode_get_name( *inode_xp , name );
    246241if( DEBUG_VFS_INODE_CREATE < cycle )
    247 printk("\n[%s] thread[%x,%x] exit for <%s> / inode [%x,%x] / cycle %d\n",
     242printk("\n[%s] thread[%x,%x] created <%s> / inode [%x,%x] / cycle %d\n",
    248243__FUNCTION__, this->process->pid, this->trdid, name, local_cxy, inode, cycle );
    249244#endif
     
    261256    // release memory allocate for inode descriptor
    262257        kmem_req_t req;
     258        req.type  = KMEM_PPM;
    263259        req.ptr   = inode;
    264         req.type  = KMEM_VFS_INODE;
    265260        kmem_free( &req );
    266261
     
    477472        kmem_req_t       req;        // request to kernel memory allocator
    478473
    479 #if DEBUG_VFS_DENTRY_CREATE
    480 thread_t * this = CURRENT_THREAD;
    481 uint32_t cycle = (uint32_t)hal_get_cycles();
    482 if( DEBUG_VFS_DENTRY_CREATE < cycle )
    483 printk("\n[%s] thread[%x,%x] enter for <%s> / cycle %d\n",
    484 __FUNCTION__, this->process->pid, this->trdid, name, cycle );
    485 #endif
    486 
    487474    // get pointer on context
    488475    if     ( fs_type == FS_TYPE_FATFS ) ctx = &fs_context[FS_TYPE_FATFS];
     
    501488
    502489    // allocate memory for dentry descriptor
    503         req.type  = KMEM_VFS_DENTRY;
    504         req.size  = sizeof(vfs_dentry_t);
     490        req.type  = KMEM_KCM;
     491        req.order = bits_log2( sizeof(vfs_dentry_t) );
    505492    req.flags = AF_KERNEL | AF_ZERO;
    506         dentry     = (vfs_dentry_t *)kmem_alloc( &req );
     493        dentry    = kmem_alloc( &req );
    507494
    508495    if( dentry == NULL )
     
    523510
    524511#if DEBUG_VFS_DENTRY_CREATE
    525 cycle = (uint32_t)hal_get_cycles();
     512thread_t * this  = CURRENT_THREAD;
     513uint32_t   cycle = (uint32_t)hal_get_cycles();
    526514if( DEBUG_VFS_DENTRY_CREATE < cycle )
    527 printk("\n[%s] thread[%x,%x] exit for <%s> / dentry [%x,%x] / cycle %d\n",
     515printk("\n[%s] thread[%x,%x] created <%s> / dentry [%x,%x] / cycle %d\n",
    528516__FUNCTION__, this->process->pid, this->trdid, name, local_cxy, dentry, cycle );
    529517#endif
     
    538526    // release memory allocated to dentry
    539527        kmem_req_t req;
     528        req.type  = KMEM_KCM;
    540529        req.ptr   = dentry;
    541         req.type  = KMEM_VFS_DENTRY;
    542530        kmem_free( &req );
    543531
     
    566554
    567555    // allocate memory for new file descriptor
    568         req.type  = KMEM_VFS_FILE;
    569         req.size  = sizeof(vfs_file_t);
     556        req.type  = KMEM_KCM;
     557        req.order = bits_log2( sizeof(vfs_file_t) );
    570558    req.flags = AF_KERNEL | AF_ZERO;
    571         file      = (vfs_file_t *)kmem_alloc( &req );
     559        file      = kmem_alloc( &req );
    572560
    573561    if( file == NULL ) return ENOMEM;
     
    602590{
    603591        kmem_req_t req;
     592        req.type  = KMEM_KCM;
    604593        req.ptr   = file;
    605         req.type  = KMEM_VFS_FILE;
    606594        kmem_free( &req );
    607595
     
    33473335#endif
    33483336
     3337
    33493338    // 3. register new_dentry in new_inode xlist of parents
    33503339    parents_root_xp  = XPTR( child_cxy , &new_inode_ptr->parents );
Note: See TracChangeset for help on using the changeset viewer.