Changeset 568 for trunk/kernel/fs
- Timestamp:
- Oct 5, 2018, 12:02:49 AM (6 years ago)
- Location:
- trunk/kernel/fs
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/fs/devfs.c
r494 r568 52 52 #endif 53 53 54 /////////////////////////////// 54 ///////////////////////////////////// 55 55 devfs_ctx_t * devfs_ctx_alloc( void ) 56 56 { … … 91 91 { 92 92 error_t error; 93 94 #if DEBUG_DEVFS_INIT95 uint32_t cycle = (uint32_t)hal_get_cycles();96 if( DEBUG_DEVFS_INIT < cycle )97 printk("\n[DBG] %s : thread %x enter at cycle %d\n",98 __FUNCTION__ , CURRENT_THREAD , cycle );99 #endif100 93 101 94 // creates DEVFS "dev" inode in cluster 0 … … 110 103 assert( (error == 0) , "cannot create <dev>\n" ); 111 104 112 #if( DEBUG_DEVFS_INIT & 1 ) 113 if( DEBUG_DEVFS_INIT < cycle ) 114 printk("\n[DBG] %s : created <dev> inode at cycle %d\n", __FUNCTION__, cycle ); 105 #if DEBUG_DEVFS_INIT 106 uint32_t cycle = (uint32_t)hal_get_cycles(); 107 if( DEBUG_DEVFS_INIT < cycle ) 108 printk("\n[DBG] %s : thread %x in process %x created <dev> inode / cycle %d\n", 109 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid ,cycle ); 115 110 #endif 116 111 … … 129 124 cycle = (uint32_t)hal_get_cycles(); 130 125 if( DEBUG_DEVFS_INIT < cycle ) 131 printk("\n[DBG] %s : thread %x exit atcycle %d\n",132 __FUNCTION__ , CURRENT_THREAD, cycle );126 printk("\n[DBG] %s : thread %x in process %x created <external> inode / cycle %d\n", 127 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid , cycle ); 133 128 #endif 134 129 … … 147 142 uint32_t channel; 148 143 149 #if DEBUG_DEVFS_INIT 150 uint32_t cycle = (uint32_t)hal_get_cycles(); 151 if( DEBUG_DEVFS_INIT < cycle ) 152 printk("\n[DBG] %s : thread %x enter at cycle %d\n", 153 __FUNCTION__ , CURRENT_THREAD , cycle ); 154 #endif 155 156 // create "internal" directory linked to "dev" 144 // create "internal" directory 157 145 snprintf( node_name , 16 , "internal_%x" , local_cxy ); 158 146 vfs_add_child_in_parent( local_cxy, … … 163 151 NULL, 164 152 devfs_internal_inode_xp ); 153 #if DEBUG_DEVFS_INIT 154 uint32_t cycle = (uint32_t)hal_get_cycles(); 155 trdid_t trdid = CURRENT_THREAD->trdid; 156 pid_t pid = CURRENT_THREAD->process->pid; 157 if( DEBUG_DEVFS_INIT < cycle ) 158 printk("\n[DBG] %s : thread %x in process %x created <%s> in cluster %x / cycle %d\n", 159 __FUNCTION__, trdid, pid, node_name, local_cxy, cycle ); 160 #endif 165 161 166 162 // create MMC chdev inode … … 176 172 GET_PTR( chdev_xp ), 177 173 &inode_xp ); 174 #if DEBUG_DEVFS_INIT 175 cycle = (uint32_t)hal_get_cycles(); 176 if( DEBUG_DEVFS_INIT < cycle ) 177 printk("\n[DBG] %s : thread %x in process %x created <mmc> inode in cluster %x\n", 178 __FUNCTION__, trdid, pid, local_cxy, cycle ); 179 #endif 180 178 181 } 179 182 … … 192 195 GET_PTR( chdev_xp ), 193 196 &inode_xp ); 197 #if DEBUG_DEVFS_INIT 198 cycle = (uint32_t)hal_get_cycles(); 199 if( DEBUG_DEVFS_INIT < cycle ) 200 printk("\n[DBG] %s : thread %x in process %x created <dma[%d]> inode in cluster %x\n", 201 __FUNCTION__, trdid, pid, channel, local_cxy, cycle ); 202 #endif 194 203 } 195 204 } … … 210 219 GET_PTR( chdev_xp ), 211 220 &inode_xp ); 221 #if DEBUG_DEVFS_INIT 222 cycle = (uint32_t)hal_get_cycles(); 223 if( DEBUG_DEVFS_INIT < cycle ) 224 printk("\n[DBG] %s : thread %x in process %x created <iob> inode in cluster %x\n", 225 __FUNCTION__, trdid, pid, local_cxy, cycle ); 226 #endif 212 227 } 213 228 } … … 228 243 GET_PTR( chdev_xp ), 229 244 &inode_xp ); 245 #if DEBUG_DEVFS_INIT 246 cycle = (uint32_t)hal_get_cycles(); 247 if( DEBUG_DEVFS_INIT < cycle ) 248 printk("\n[DBG] %s : thread %x in process %x created <pic> inode in cluster %x\n", 249 __FUNCTION__, trdid, pid, local_cxy, cycle ); 250 #endif 230 251 } 231 252 } … … 248 269 GET_PTR( chdev_xp ), 249 270 &inode_xp ); 271 #if DEBUG_DEVFS_INIT 272 cycle = (uint32_t)hal_get_cycles(); 273 if( DEBUG_DEVFS_INIT < cycle ) 274 printk("\n[DBG] %s : thread %x in process %x created <txt_rx[%d]> inode in cluster %x\n", 275 __FUNCTION__, trdid, pid, channel, local_cxy, cycle ); 276 #endif 250 277 } 251 278 } … … 269 296 GET_PTR( chdev_xp ), 270 297 &inode_xp ); 298 #if DEBUG_DEVFS_INIT 299 cycle = (uint32_t)hal_get_cycles(); 300 if( DEBUG_DEVFS_INIT < cycle ) 301 printk("\n[DBG] %s : thread %x in process %x created <txt_tx[%d]> inode in cluster %x\n", 302 __FUNCTION__, trdid, pid, channel, local_cxy, cycle ); 303 #endif 271 304 } 272 305 } … … 290 323 GET_PTR( chdev_xp ), 291 324 &inode_xp ); 325 #if DEBUG_DEVFS_INIT 326 cycle = (uint32_t)hal_get_cycles(); 327 if( DEBUG_DEVFS_INIT < cycle ) 328 printk("\n[DBG] %s : thread %x in process %x created <ioc[%d]> inode in cluster %x\n", 329 __FUNCTION__, trdid, pid, channel, local_cxy, cycle ); 330 #endif 292 331 } 293 332 } … … 295 334 296 335 // create a FBF inode in each cluster containing a FBF chdev 297 for( channel = 0 ; channel < CONFIG_MAX_ IOC_CHANNELS ; channel++ )336 for( channel = 0 ; channel < CONFIG_MAX_FBF_CHANNELS ; channel++ ) 298 337 { 299 338 chdev_xp = chdev_dir.fbf[channel]; … … 311 350 GET_PTR( chdev_xp ), 312 351 &inode_xp ); 352 #if DEBUG_DEVFS_INIT 353 cycle = (uint32_t)hal_get_cycles(); 354 if( DEBUG_DEVFS_INIT < cycle ) 355 printk("\n[DBG] %s : thread %x in process %x created <fbf[%d]> inode in cluster %x\n", 356 __FUNCTION__, trdid, pid, channel, local_cxy, cycle ); 357 #endif 313 358 } 314 359 } … … 332 377 GET_PTR( chdev_xp ), 333 378 &inode_xp ); 379 #if DEBUG_DEVFS_INIT 380 cycle = (uint32_t)hal_get_cycles(); 381 if( DEBUG_DEVFS_INIT < cycle ) 382 printk("\n[DBG] %s : thread %x in process %x created <nic_rx[%d]> inode in cluster %x\n", 383 __FUNCTION__, trdid, pid, channel, local_cxy, cycle ); 384 #endif 334 385 } 335 386 } … … 353 404 GET_PTR( chdev_xp ), 354 405 &inode_xp ); 355 } 356 } 357 } 358 359 #if DEBUG_DEVFS_INIT 360 cycle = (uint32_t)hal_get_cycles(); 361 if( DEBUG_DEVFS_INIT < cycle ) 362 printk("\n[DBG] %s : thread %x exit at cycle %d\n", 363 __FUNCTION__ , CURRENT_THREAD , cycle ); 364 #endif 365 406 #if DEBUG_DEVFS_INIT 407 cycle = (uint32_t)hal_get_cycles(); 408 if( DEBUG_DEVFS_INIT < cycle ) 409 printk("\n[DBG] %s : thread %x in process %x created <nic_tx[%d]> inode in cluster %x\n", 410 __FUNCTION__, trdid, pid, channel, local_cxy, cycle ); 411 #endif 412 } 413 } 414 } 366 415 } // end devfs_local_init() 367 416 … … 408 457 409 458 // get chdev functionnal type and channel 410 func = hal_remote_l w( XPTR( chdev_cxy , &chdev_ptr->func ) );411 channel = hal_remote_l w( XPTR( chdev_cxy , &chdev_ptr->channel ) );459 func = hal_remote_l32( XPTR( chdev_cxy , &chdev_ptr->func ) ); 460 channel = hal_remote_l32( XPTR( chdev_cxy , &chdev_ptr->channel ) ); 412 461 413 462 // action depends on "func" and "to_buffer" -
trunk/kernel/fs/devfs.h
r484 r568 88 88 * This function start to create the DEVFS subtree. 89 89 * This function should be called once in the cluster containing the VFS parent inode. 90 * More precisely, it creates in cluster IOthe "dev" and "external" DEVFS directories.90 * More precisely, it creates in cluster 0 the "dev" and "external" DEVFS directories. 91 91 * For each one, it creates the inode and link the associated dentry to parent inode. 92 92 * The DEVFS root inode is linked to the VFS parent inode identified by <parent_inode_xp>. -
trunk/kernel/fs/fatfs.c
r519 r568 44 44 extern vfs_ctx_t fs_context[FS_TYPES_NR]; // allocated in vfs.c file 45 45 46 extern remote_barrier_t global_barrier; // allocated in kernel_init.c47 48 46 ////////////////////////////////////////////////////////////////////////////////////////// 49 47 // FATFS specific and static functions … … 55 53 ////////////////////////////////////////////////////////////////////////////////////////// 56 54 57 static inline 58 int get_length( 59 int offset __attribute__((unused) ), 60 int length) 61 { 62 return length; 63 } 64 65 static inline 66 int get_offset( 67 int offset, 68 int length __attribute__((unused)) ) 69 { 70 return offset; 71 } 55 static inline int get_length( int offset __attribute__((unused)), int length ) { return length; } 56 57 static inline int get_offset( int offset, int length __attribute__((unused)) ) { return offset; } 72 58 73 59 ////////////////////////////////////////////////////////////////////////////////////////// … … 231 217 232 218 ////////////////////////////////////////////////////////////////////////////////////////// 233 // FATFS specific butextern functions219 // FATFS specific extern functions 234 220 ////////////////////////////////////////////////////////////////////////////////////////// 235 221 … … 338 324 /////////////////////////////////////////////////////////////////////////////////////// 339 325 340 /////////////////////////////// 326 ///////////////////////////////////// 341 327 fatfs_ctx_t * fatfs_ctx_alloc( void ) 342 328 { … … 778 764 vfs_inode_type_t type = (is_dir) ? INODE_TYPE_DIR : INODE_TYPE_FILE; 779 765 780 hal_remote_s w( XPTR( child_cxy , &child_ptr->type ) , type );781 hal_remote_s w( XPTR( child_cxy , &child_ptr->size ) , size );782 hal_remote_s w( XPTR( child_cxy , &child_ptr->extend ) , cluster );766 hal_remote_s32( XPTR( child_cxy , &child_ptr->type ) , type ); 767 hal_remote_s32( XPTR( child_cxy , &child_ptr->size ) , size ); 768 hal_remote_s32( XPTR( child_cxy , &child_ptr->extend ) , cluster ); 783 769 784 770 #if DEBUG_FATFS_LOAD -
trunk/kernel/fs/ramfs.c
r561 r568 26 26 #include <hal_kernel_types.h> 27 27 #include <hal_special.h> 28 #include <printk.h>29 #include <kmem.h>30 28 #include <vfs.h> 29 #include <cluster.h> 31 30 #include <ramfs.h> 32 31 -
trunk/kernel/fs/vfs.c
r561 r568 28 28 #include <hal_atomic.h> 29 29 #include <hal_special.h> 30 #include <readlock.h>31 #include <spinlock.h>32 30 #include <printk.h> 33 31 #include <list.h> … … 43 41 #include <chdev.h> 44 42 #include <process.h> 43 #include <cluster.h> 45 44 #include <vfs.h> 46 45 #include <fatfs.h> … … 55 54 56 55 extern vfs_ctx_t fs_context[FS_TYPES_NR]; // allocated in kernel_init.c 57 58 56 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 57 extern char * lock_type_str[]; // allocated in kernel_init.c 59 58 60 59 ////////////////////////////////////////////////////////////////////////////////////////// … … 79 78 vfs_ctx->extend = extend; 80 79 81 spinlock_init( &vfs_ctx->lock);80 busylock_init( &vfs_ctx->lock , LOCK_VFS_CTX ); 82 81 83 82 bitmap_init( vfs_ctx->bitmap , BITMAP_SIZE(CONFIG_VFS_MAX_INODES) ); … … 89 88 { 90 89 // get lock on inum allocator 91 spinlock_lock( &ctx->lock );90 busylock_acquire( &ctx->lock ); 92 91 93 92 // get lid from local inum allocator … … 97 96 { 98 97 // release lock 99 spinlock_unlock( &ctx->lock );98 busylock_release( &ctx->lock ); 100 99 101 100 // return error … … 108 107 109 108 // release lock 110 spinlock_unlock( &ctx->lock );109 busylock_release( &ctx->lock ); 111 110 112 111 // return inum … … 160 159 161 160 #if DEBUG_VFS_INODE_CREATE 162 uint32_t cycle = (uint32_t)hal_get_cycles(); 161 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 162 uint32_t cycle = (uint32_t)hal_get_cycles(); 163 cxy_t dentry_cxy = GET_CXY( dentry_xp ); 164 vfs_dentry_t * dentry_ptr = GET_PTR( dentry_xp ); 165 thread_t * this = CURRENT_THREAD; 166 if( dentry_xp != XPTR_NULL ) hal_remote_strcpy( XPTR( local_cxy , name ), 167 XPTR( dentry_cxy , dentry_ptr->name ) ); 168 else strcpy( name , "/" ); 163 169 if( DEBUG_VFS_INODE_CREATE < cycle ) 164 printk("\n[DBG] %s : thread %x enter / dentry = %x in cluster %x/ cycle %d\n",165 __FUNCTION__, CURRENT_THREAD, GET_PTR(dentry_xp), GET_CXY(dentry_xp), cycle );170 printk("\n[DBG] %s : thread %x in process %x enter for <%s> / cycle %d\n", 171 __FUNCTION__, this->trdid, this->process->pid, name, cycle ); 166 172 #endif 167 173 … … 232 238 xhtab_init( &inode->children , XHTAB_DENTRY_TYPE ); 233 239 234 // initialize inode locks 235 remote_rwlock_init( XPTR( local_cxy , &inode->data_lock ) ); 236 remote_spinlock_init( XPTR( local_cxy , &inode->main_lock ) ); 240 // initialize inode lock 241 remote_rwlock_init( XPTR( local_cxy , &inode->data_lock ), LOCK_VFS_INODE ); 242 243 // initialise lock protecting inode three traversal 244 remote_busylock_init( XPTR( local_cxy , &inode->main_lock ), LOCK_VFS_MAIN ); 237 245 238 246 #if DEBUG_VFS_INODE_CREATE 239 cycle = (uint32_t)hal_get_cycles();247 cycle = (uint32_t)hal_get_cycles(); 240 248 if( DEBUG_VFS_INODE_CREATE < cycle ) 241 printk("\n[DBG] %s : thread %x exit / inode = %x in cluster %x/ cycle %d\n",242 __FUNCTION__, CURRENT_THREAD, inode, local_cxy, cycle );249 printk("\n[DBG] %s : thread %x in process %x exit for <%s> / inode [%x,%x] / cycle %d\n", 250 __FUNCTION__, this->trdid, this->process->pid, name, local_cxy, inode, cycle ); 243 251 #endif 244 252 … … 346 354 347 355 // get size 348 remote_rwlock_rd_ lock( XPTR( cxy , &ptr->data_lock ) );349 uint32_t size = hal_remote_l w( XPTR( cxy , &ptr->size ) );350 remote_rwlock_rd_ unlock( XPTR( cxy , &ptr->data_lock ) );356 remote_rwlock_rd_acquire( XPTR( cxy , &ptr->data_lock ) ); 357 uint32_t size = hal_remote_l32( XPTR( cxy , &ptr->size ) ); 358 remote_rwlock_rd_release( XPTR( cxy , &ptr->data_lock ) ); 351 359 return size; 352 360 } … … 361 369 362 370 // set size 363 remote_rwlock_wr_ unlock( XPTR( cxy , &ptr->data_lock ) );364 hal_remote_s w( XPTR( cxy , &ptr->size ) , size );365 remote_rwlock_wr_ unlock( XPTR( cxy , &ptr->data_lock ) );371 remote_rwlock_wr_release( XPTR( cxy , &ptr->data_lock ) ); 372 hal_remote_s32( XPTR( cxy , &ptr->size ) , size ); 373 remote_rwlock_wr_release( XPTR( cxy , &ptr->data_lock ) ); 366 374 } 367 375 … … 374 382 375 383 // release the main lock 376 remote_ spinlock_unlock( XPTR( cxy , &ptr->main_lock ) );384 remote_busylock_release( XPTR( cxy , &ptr->main_lock ) ); 377 385 } 378 386 … … 385 393 386 394 // get the main lock 387 remote_ spinlock_lock( XPTR( cxy , &ptr->main_lock ) );395 remote_busylock_acquire( XPTR( cxy , &ptr->main_lock ) ); 388 396 } 389 397 … … 403 411 404 412 // get parent dentry 405 dentry_xp = hal_remote_l wd( XPTR( inode_cxy , &inode_ptr->parent_xp ) );413 dentry_xp = hal_remote_l64( XPTR( inode_cxy , &inode_ptr->parent_xp ) ); 406 414 407 415 // get local copy of name … … 475 483 cycle = (uint32_t)hal_get_cycles(); 476 484 if( DEBUG_VFS_DENTRY_CREATE < cycle ) 477 printk("\n[DBG] %s : dentry initialised\n", __FUNCTION__ ); 485 printk("\n[DBG] %s : thread %x in process %x / dentry <%s> initialised / cycle %d\n", 486 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, dentry->name, cycle ); 478 487 #endif 479 488 … … 488 497 cycle = (uint32_t)hal_get_cycles(); 489 498 if( DEBUG_VFS_DENTRY_CREATE < cycle ) 490 printk("\n[DBG] %s : dentry registerd in htab\n", __FUNCTION__ ); 499 printk("\n[DBG] %s : thread %x in process %x / dentry <%s> registered / cycle %d\n", 500 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, dentry->name, cycle ); 491 501 #endif 492 502 … … 544 554 vfs_file_t * file; 545 555 kmem_req_t req; 556 557 #if DEBUG_VFS_FILE_CREATE 558 uint32_t cycle = (uint32_t)hal_get_cycles(); 559 if( DEBUG_VFS_OPEN < cycle ) 560 printk("\n[DBG] %s : thread %x in process %x enter for inode %x in cluster %x / cycle %d\n", 561 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, inode, local_cxy, cycle ); 562 #endif 546 563 547 564 // allocate memory for new file descriptor … … 563 580 file->mapper = inode->mapper; 564 581 565 remote_rwlock_init( XPTR( local_cxy , &file->lock ) );582 remote_rwlock_init( XPTR( local_cxy , &file->lock ), LOCK_VFS_FILE ); 566 583 567 584 *file_xp = XPTR( local_cxy , file ); 568 585 569 #if DEBUG_VFS_ OPEN570 uint32_tcycle = (uint32_t)hal_get_cycles();586 #if DEBUG_VFS_FILE_CREATE 587 cycle = (uint32_t)hal_get_cycles(); 571 588 if( DEBUG_VFS_OPEN < cycle ) 572 589 printk("\n[DBG] %s : thread %x in process %x created file %x in cluster %x / cycle %d\n", … … 729 746 730 747 // get inode type from remote file descriptor 731 inode_type = hal_remote_l w( XPTR( file_cxy , &file_ptr->type ) );748 inode_type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) ); 732 749 733 750 assert( (inode_type == INODE_TYPE_FILE) , … … 735 752 736 753 // get mapper pointer and file offset from file descriptor 737 file_offset = hal_remote_l w( XPTR( file_cxy , &file_ptr->offset ) );754 file_offset = hal_remote_l32( XPTR( file_cxy , &file_ptr->offset ) ); 738 755 mapper = (mapper_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->mapper ) ); 739 756 … … 784 801 785 802 // get inode type from remote file descriptor 786 inode_type = hal_remote_l w( XPTR( file_cxy , &file_ptr->type ) );803 inode_type = hal_remote_l32( XPTR( file_cxy , &file_ptr->type ) ); 787 804 788 805 // action depends on inode type … … 790 807 { 791 808 // get mapper pointer and file offset from file descriptor 792 file_offset = hal_remote_l w( XPTR( file_cxy , &file_ptr->offset ) );809 file_offset = hal_remote_l32( XPTR( file_cxy , &file_ptr->offset ) ); 793 810 mapper = (mapper_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->mapper ) ); 794 811 … … 848 865 849 866 // take file descriptor lock 850 remote_rwlock_wr_ lock( lock_xp );867 remote_rwlock_wr_acquire( lock_xp ); 851 868 852 869 if ( whence == SEEK_CUR ) // new = current + offset 853 870 { 854 new = hal_remote_l w( offset_xp ) + offset;871 new = hal_remote_l32( offset_xp ) + offset; 855 872 } 856 873 else if ( whence == SEEK_SET ) // new = offset … … 863 880 inode_ptr = (vfs_inode_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) ); 864 881 865 new = hal_remote_l w( XPTR( file_cxy , &inode_ptr->size ) ) + offset;882 new = hal_remote_l32( XPTR( file_cxy , &inode_ptr->size ) ) + offset; 866 883 } 867 884 else 868 885 { 869 886 printk("\n[ERROR] in %s : illegal whence value\n", __FUNCTION__ ); 870 remote_rwlock_wr_ unlock( lock_xp );887 remote_rwlock_wr_release( lock_xp ); 871 888 return -1; 872 889 } 873 890 874 891 // set new offset 875 hal_remote_s w( offset_xp , new );892 hal_remote_s32( offset_xp , new ); 876 893 877 894 // release file descriptor lock 878 remote_rwlock_wr_ unlock( lock_xp );895 remote_rwlock_wr_release( lock_xp ); 879 896 880 897 // success … … 929 946 930 947 // take the lock protecting the list of copies 931 remote_ spinlock_lock( lock_xp );948 remote_queuelock_acquire( lock_xp ); 932 949 933 950 XLIST_FOREACH( root_xp , iter_xp ) … … 948 965 xptr_t entry_xp = XPTR( process_cxy , &process_ptr->fd_array.array[file_id] ); 949 966 950 // remote_rwlock_wr_ lock( fd_array_lock_xp );951 952 hal_remote_s wd( entry_xp , XPTR_NULL );967 // remote_rwlock_wr_acquire( fd_array_lock_xp ); 968 969 hal_remote_s64( entry_xp , XPTR_NULL ); 953 970 954 // remote_rwlock_wr_ unlock( fd_array_lock_xp );971 // remote_rwlock_wr_release( fd_array_lock_xp ); 955 972 956 973 vfs_file_count_down( file_xp ); … … 960 977 961 978 // release the lock protecting the list of copies 962 remote_ spinlock_unlock( lock_xp );979 remote_queuelock_release( lock_xp ); 963 980 964 981 #if (DEBUG_VFS_CLOSE & 1) … … 1064 1081 1065 1082 // get inode type from remote file 1066 inode_type = hal_remote_l w( XPTR( inode_cxy , &inode_ptr->type ) );1083 inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 1067 1084 1068 1085 if( inode_type != INODE_TYPE_DIR ) … … 1072 1089 } 1073 1090 1074 assert( false , "not implemented\n" ); 1091 // TODO implement this function using process CWD lock 1092 1093 assert( false , "not implemented\n" ); 1094 1075 1095 return 0; 1076 1096 } … … 1101 1121 1102 1122 // get inode type from remote inode 1103 inode_type = hal_remote_l w( XPTR( inode_cxy , &inode_ptr->type ) );1123 inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 1104 1124 1105 1125 … … 1123 1143 // Inode Tree functions 1124 1144 ////////////////////////////////////////////////////////////////////////////////////////// 1125 1126 1145 1127 1146 ////////////////////////////////////////////////////////////////////////// … … 1172 1191 1173 1192 // get inode type 1174 inode_type = hal_remote_l w( XPTR( inode_cxy , &inode_ptr->type ) );1193 inode_type = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->type ) ); 1175 1194 1176 1195 // get local pointer on associated mapper … … 1192 1211 1193 1212 // get xhtab lock 1194 xhtab_ read_lock( children_xp );1213 xhtab_lock( children_xp ); 1195 1214 1196 1215 // get first dentry from xhtab … … 1204 1223 1205 1224 // get extended pointer on child inode 1206 child_inode_xp = hal_remote_l wd( XPTR( child_dentry_cxy,1225 child_inode_xp = hal_remote_l64( XPTR( child_dentry_cxy, 1207 1226 &child_dentry_ptr->child_xp ) ); 1208 1227 … … 1210 1229 child_dentry_name_xp = XPTR( child_dentry_cxy , &child_dentry_ptr->name ); 1211 1230 1212 // recursive call on child inode1231 // recursive call on inode display 1213 1232 vfs_recursive_display( child_inode_xp, 1214 1233 child_dentry_name_xp, … … 1220 1239 1221 1240 // release xhtab lock 1222 xhtab_ read_unlock( children_xp );1241 xhtab_unlock( children_xp ); 1223 1242 } 1224 1243 } // end vfs_recursive_display() … … 1231 1250 cxy_t dentry_cxy; 1232 1251 vfs_dentry_t * dentry_ptr; 1233 uint32_t save_sr;1234 1252 1235 1253 // get target inode cluster and local pointer … … 1238 1256 1239 1257 // get extended pointer on associated dentry 1240 dentry_xp = hal_remote_l wd( XPTR( inode_cxy , &inode_ptr->parent_xp ) );1258 dentry_xp = hal_remote_l64( XPTR( inode_cxy , &inode_ptr->parent_xp ) ); 1241 1259 1242 1260 // check if target inode is the File System root … … 1265 1283 1266 1284 // get TXT0 lock in busy waiting mode 1267 remote_ spinlock_lock_busy( lock_xp , &save_sr);1285 remote_busylock_acquire( lock_xp ); 1268 1286 1269 1287 // print header … … 1274 1292 1275 1293 // release lock 1276 remote_ spinlock_unlock_busy( lock_xp , save_sr);1294 remote_busylock_release( lock_xp ); 1277 1295 1278 1296 } // end vfs_display() … … 1298 1316 1299 1317 // get inode access mode, UID, and GID 1300 // TODO uint32_t mode = hal_remote_l w( XPTR( inode_cxy , &inode_ptr->mode ) );1301 uid_t uid = hal_remote_l w( XPTR( inode_cxy , &inode_ptr->uid ) );1302 gid_t gid = hal_remote_l w( XPTR( inode_cxy , &inode_ptr->gid ) );1318 // TODO uint32_t mode = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->mode ) ); 1319 uid_t uid = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->uid ) ); 1320 gid_t gid = hal_remote_l32( XPTR( inode_cxy , &inode_ptr->gid ) ); 1303 1321 1304 1322 // FIXME : me must use mode … … 1342 1360 1343 1361 // return child inode 1344 *child_xp = (xptr_t)hal_remote_l wd( XPTR( dentry_cxy , &dentry_ptr->child_xp ) );1362 *child_xp = (xptr_t)hal_remote_l64( XPTR( dentry_cxy , &dentry_ptr->child_xp ) ); 1345 1363 return true; 1346 1364 … … 1496 1514 parent_ptr = GET_PTR( parent_xp ); 1497 1515 ctx_ptr = (vfs_ctx_t *)hal_remote_lpt( XPTR( parent_cxy,&parent_ptr->ctx ) ); 1498 fs_type = hal_remote_l w( XPTR( parent_cxy , &ctx_ptr->type ) );1516 fs_type = hal_remote_l32( XPTR( parent_cxy , &ctx_ptr->type ) ); 1499 1517 1500 1518 // select a cluster for missing inode … … 1545 1563 if( last && create && dir ) // new directory => update inode type 1546 1564 { 1547 hal_remote_s w( XPTR( child_cxy, &child_ptr->type ), INODE_TYPE_DIR );1565 hal_remote_s32( XPTR( child_cxy, &child_ptr->type ), INODE_TYPE_DIR ); 1548 1566 1549 1567 #if (DEBUG_VFS_LOOKUP & 1) … … 1555 1573 else if ( last && create ) // new file => update inode type 1556 1574 { 1557 hal_remote_s w( XPTR( child_cxy, &child_ptr->type ), INODE_TYPE_FILE );1575 hal_remote_s32( XPTR( child_cxy, &child_ptr->type ), INODE_TYPE_FILE ); 1558 1576 1559 1577 #if (DEBUG_VFS_LOOKUP & 1) … … 1574 1592 { 1575 1593 // load child mapper from device if child is a directory (prefetch) 1576 if( hal_remote_l w( XPTR( child_cxy , &child_ptr->type ) ) == INODE_TYPE_DIR )1594 if( hal_remote_l32( XPTR( child_cxy , &child_ptr->type ) ) == INODE_TYPE_DIR ) 1577 1595 { 1578 1596 if( child_cxy == local_cxy ) … … 1700 1718 1701 1719 // get extended pointer on parent dentry 1702 dentry_xp = (xptr_t)hal_remote_l wd( XPTR( inode_cxy , inode_ptr->parent_xp ) );1720 dentry_xp = (xptr_t)hal_remote_l64( XPTR( inode_cxy , inode_ptr->parent_xp ) ); 1703 1721 1704 1722 // get dentry cluster and local pointer … … 1707 1725 1708 1726 // get dentry name length and pointer 1709 length = hal_remote_l w( XPTR( dentry_cxy , &dentry_ptr->length ) );1727 length = hal_remote_l32( XPTR( dentry_cxy , &dentry_ptr->length ) ); 1710 1728 name = (char *)hal_remote_lpt( XPTR( dentry_cxy , &dentry_ptr->name ) ); 1711 1729 … … 1727 1745 1728 1746 // get extended pointer on next inode 1729 inode_xp = (xptr_t)hal_remote_l wd( XPTR( dentry_cxy , dentry_ptr->parent ) );1747 inode_xp = (xptr_t)hal_remote_l64( XPTR( dentry_cxy , dentry_ptr->parent ) ); 1730 1748 } 1731 1749 while( (dentry_xp != XPTR_NULL) ); … … 1757 1775 #if DEBUG_VFS_ADD_CHILD 1758 1776 uint32_t cycle = (uint32_t)hal_get_cycles(); 1777 thread_t * this = CURRENT_THREAD; 1759 1778 if( DEBUG_VFS_ADD_CHILD < cycle ) 1760 printk("\n[DBG] %s : thread %x enter for <%s> / child_cxy = %x / parent_cxy = %x / cycle %d\n", 1761 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, name, 1779 printk("\n[DBG] %s : thread %x in process %x enter for <%s>\n" 1780 " child_cxy = %x / parent_cxy = %x / cycle %d\n", 1781 __FUNCTION__, this->trdid, this->process->pid, name, 1762 1782 child_cxy, parent_cxy, (uint32_t)hal_get_cycles() ); 1763 1783 #endif … … 1770 1790 parent_ptr, 1771 1791 &dentry_xp ); 1772 1773 #if (DEBUG_VFS_ADD_CHILD & 1)1774 if( (DEBUG_VFS_ADD_CHILD < cycle) && (error == 0) )1775 printk("\n[DBG] %s : dentry <%s> created in cluster %x\n", __FUNCTION__, name, local_cxy );1776 #endif1777 1778 1792 } 1779 1793 else // parent cluster is remote … … 1785 1799 &dentry_xp, 1786 1800 &error ); 1787 1788 #if (DEBUG_VFS_ADD_CHILD & 1)1789 if( (DEBUG_VFS_ADD_CHILD < cycle) && (error == 0) )1790 printk("\n[DBG] %s : dentry <%s> created in cluster %x\n", __FUNCTION__, name, parent_cxy );1791 #endif1792 1793 1801 } 1794 1802 … … 1799 1807 return ENOMEM; 1800 1808 } 1809 1810 #if(DEBUG_VFS_ADD_CHILD & 1) 1811 if( DEBUG_VFS_ADD_CHILD < cycle ) 1812 printk("\n[DBG] %s : thread %x in process %x / dentry <%s> created in cluster %x\n", 1813 __FUNCTION__, this->trdid, this->process->pid, name, parent_cxy ); 1814 #endif 1801 1815 1802 1816 // 2. create child inode TODO : define attr / mode / uid / gid … … 1817 1831 gid, 1818 1832 &inode_xp ); 1819 1820 #if (DEBUG_VFS_ADD_CHILD & 1)1821 if( DEBUG_VFS_ADD_CHILD < cycle )1822 printk("\n[DBG] %s : inode <%x> created in cluster %x\n",1823 __FUNCTION__ , GET_PTR(inode_xp) , local_cxy );1824 #endif1825 1826 1833 } 1827 1834 else // child cluster is remote … … 1838 1845 &inode_xp, 1839 1846 &error ); 1840 1841 #if (DEBUG_VFS_ADD_CHILD & 1)1842 if( DEBUG_VFS_ADD_CHILD < cycle )1843 printk("\n[DBG] %s : inode <%s> created in cluster %x\n",1844 __FUNCTION__ , GET_PTR(inode_xp) , child_cxy );1845 #endif1846 1847 1847 } 1848 1848 … … 1858 1858 } 1859 1859 1860 #if(DEBUG_VFS_ADD_CHILD & 1) 1861 if( DEBUG_VFS_ADD_CHILD < cycle ) 1862 printk("\n[DBG] %s : thread %x in process %x / inode <%s> created in cluster %x\n", 1863 __FUNCTION__ , this->trdid, this->process->pid, name , child_cxy ); 1864 #endif 1865 1860 1866 // 3. update extended pointer on inode in dentry 1861 1867 cxy_t dentry_cxy = GET_CXY( dentry_xp ); 1862 1868 vfs_dentry_t * dentry_ptr = GET_PTR( dentry_xp ); 1863 hal_remote_s wd( XPTR( dentry_cxy , &dentry_ptr->child_xp ) , inode_xp );1869 hal_remote_s64( XPTR( dentry_cxy , &dentry_ptr->child_xp ) , inode_xp ); 1864 1870 1865 1871 #if DEBUG_VFS_ADD_CHILD 1866 1872 cycle = (uint32_t)hal_get_cycles(); 1867 1873 if( DEBUG_VFS_ADD_CHILD < cycle ) 1868 printk("\n[DBG] %s : thread %x in process %x exit for <%s> \n",1869 __FUNCTION__, CURRENT_THREAD, CURRENT_THREAD->process->pid, name);1874 printk("\n[DBG] %s : thread %x in process %x exit for <%s> / cycle %d\n", 1875 __FUNCTION__, this->trdid, this->process->pid, name, (uint32_t)hal_get_cycles() ); 1870 1876 #endif 1871 1877 … … 1893 1899 1894 1900 // get cluster and pointers of associated dentry 1895 dentry_xp = hal_remote_l wd( XPTR( inode_cxy , &inode_ptr->parent_xp ) );1901 dentry_xp = hal_remote_l64( XPTR( inode_cxy , &inode_ptr->parent_xp ) ); 1896 1902 dentry_cxy = GET_CXY( dentry_xp ); 1897 1903 dentry_ptr = GET_PTR( dentry_xp ); … … 1958 1964 if( fs_type == FS_TYPE_FATFS ) 1959 1965 { 1960 rwlock_wr_lock( &mapper->lock ); 1966 // enter mapper in write mode 1967 rwlock_wr_acquire( &mapper->lock ); 1968 1969 // move page to mapper 1961 1970 error = fatfs_mapper_move_page( page , to_mapper ); 1962 rwlock_wr_unlock( &mapper->lock ); 1971 1972 // exit mapper in write mode 1973 rwlock_wr_release( &mapper->lock ); 1963 1974 } 1964 1975 else if( fs_type == FS_TYPE_RAMFS ) -
trunk/kernel/fs/vfs.h
r561 r568 30 30 #include <hal_atomic.h> 31 31 #include <remote_rwlock.h> 32 #include <remote_ spinlock.h>33 #include < spinlock.h>32 #include <remote_busylock.h> 33 #include <busylock.h> 34 34 #include <list.h> 35 35 #include <xlist.h> 36 #include <slist.h>37 36 #include <bits.h> 38 37 #include <xhtab.h> … … 105 104 106 105 /****************************************************************************************** 107 * This structure defines informations common to all inodes and dentries108 * of a given file system. As it is declared a global variable in the kdata segment,109 * it is replicated in all clusters and handled as private by each OS intance.106 * This structure defines a VFS context, that contains informations common to all inodes 107 * and dentries for a given file system. As it is declared as a global variable in the 108 * kdata segment, it is handled as private by each OS intance in a given cluster. 110 109 *****************************************************************************************/ 111 110 … … 134 133 uint32_t cluster_size; /*! cluster size on device (bytes) */ 135 134 xptr_t vfs_root_xp; /*! extended pointer on VFS root inode */ 136 spinlock_t lock; /*! lock protecting inum allocator */135 busylock_t lock; /*! lock protecting inum allocator */ 137 136 uint32_t bitmap[BITMAP_SIZE(CONFIG_VFS_MAX_INODES)]; /* inum allocator */ 138 137 void * extend; /*! FS specific context extension */ … … 143 142 * This structure define a VFS inode. 144 143 * It contains an extended pointer on the parent dentry, and (for directory only) 145 * an hash table xhtab refering all children dentries.146 * The <parent> inode is unique for a directory (no thard links for directories).144 * an hash table (xhtab) registering all children dentries. 145 * The <parent> inode is unique for a directory (no hard links for directories). 147 146 * For a file, the parent field points to the first dentry who created this inode. 148 * Sync rhonisation:149 * - the main_lock ( spinlock) is used during the inode tree traversal or for inode150 * modification (add/remove children).151 * - the data_lock (r wlock) is used during read/write accesses to the data stored152 * in the mapper.153 * - the mapper lock (r wlock) is only used during the radix tree traversal to return154 * t he relevant page for read/write.147 * Synchronisation: 148 * - the main_lock (remote_busylock) is used during the inode tree traversal, 149 * or for inode modification (add/remove children). 150 * - the data_lock (remote_rwlock) is used during read/write accesses to the data 151 * stored in the mapper. 152 * - the mapper lock (remote rwlock) is only used during the radix tree traversal 153 * to return the relevant page for read/write. 155 154 *****************************************************************************************/ 156 155 … … 195 194 xhtab_t children; /*! embedded xhtab of children dentries */ 196 195 remote_rwlock_t data_lock; /*! protect read/write to data and to size */ 197 remote_ spinlock_t main_lock; /*! protect inode tree traversal and modifs */196 remote_busylock_t main_lock; /*! protect inode tree traversal and modifs */ 198 197 list_entry_t list; /*! member of set of inodes in same cluster */ 199 198 xlist_entry_t wait_root; /*! root of threads waiting on this inode */
Note: See TracChangeset
for help on using the changeset viewer.