Changeset 279 for trunk/kernel/vfs
- Timestamp:
- Jul 27, 2017, 12:23:29 AM (7 years ago)
- Location:
- trunk/kernel/vfs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/vfs/devfs.c
r204 r279 79 79 error_t error; 80 80 81 devfs_dmsg("\n[INFO] %s : enter in cluster %x\n", 82 __FUNCTION__ , local_cxy ); 83 81 84 // creates DEVFS "dev" inode in cluster IO 82 85 error = vfs_add_child_in_parent( LOCAL_CLUSTER->io_cxy, … … 88 91 devfs_dev_inode_xp ); 89 92 90 nolock_assert( (error == 0) , __FUNCTION__ , "cannot create <dev>\n" ); 93 assert( (error == 0) , __FUNCTION__ , "cannot create <dev>\n" ); 94 95 devfs_dmsg("\n[INFO] %s : <dev> created in cluster %x\n", 96 __FUNCTION__ , local_cxy ); 91 97 92 98 // create DEVFS "external" inode in cluster IO … … 99 105 devfs_external_inode_xp ); 100 106 101 nolock_assert( (error == 0) , __FUNCTION__ , "cannot create <external>\n" ); 107 assert( (error == 0) , __FUNCTION__ , "cannot create <external>\n" ); 108 109 devfs_dmsg("\n[INFO] %s : <external> created in cluster %x\n", 110 __FUNCTION__ , local_cxy ); 102 111 } 103 112 -
trunk/kernel/vfs/fatfs.c
r265 r279 217 217 } // end get_name_from_long() 218 218 219 //////////////////////////////////////////////////////////////////////////////////////////220 // This function returns the FATFS cluster index of a page identified by its page221 // index in the file, using the FAT mapper. It scans the FAT mapper, starting from the222 // FATFS cluster index allocated to the first page of the file, until it reaches the223 // searched page. The FAT mapper is automatically updated in case of miss.224 // This function can be called by any thread running in any cluster, as it uses the225 // RPC_FATFS_GET_CLUSTER to access the remote FAT mapper if required.226 // We use a RPC to scan the FAT because the RPC_FIFO will avoid contention227 // in the cluster containing the FAT mapper, and the RPC latency is not critical228 // compared to the device access latency.229 //////////////////////////////////////////////////////////////////////////////////////////230 // @ ctx : pointer on local FATFS context.231 // @ first_cluster : first cluster allocated to a file in FATFS.232 // @ page_index : index of searched page in file (one page occupies one cluster).233 // @ cluster_index : [out] pointer on buffer for FATFS cluster index.234 // @ return 0 if success / return EIO if a FAT cluster miss cannot be solved.235 //////////////////////////////////////////////////////////////////////////////////////////236 static error_t fatfs_cluster_from_index( fatfs_ctx_t * ctx,237 uint32_t first_cluster,238 uint32_t page_index,239 uint32_t * cluster_index )240 {241 uint32_t searched_cluster; // searched FATFS cluster index242 error_t error;243 244 // get extended pointer on FAT mapper245 xptr_t fat_mapper_xp = ctx->fat_mapper_xp;246 247 // get cluster cxy and local pointer on FAT mapper248 cxy_t fat_mapper_cxy = GET_CXY( fat_mapper_xp );249 mapper_t * fat_mapper_ptr = (mapper_t *)GET_PTR( fat_mapper_xp );250 251 if( fat_mapper_cxy == local_cxy ) // FAT mapper is local252 {253 error = fatfs_get_cluster( fat_mapper_ptr,254 first_cluster,255 page_index,256 &searched_cluster );257 }258 else // FAT mapper is remote259 {260 rpc_fatfs_get_cluster_client( fat_mapper_cxy,261 fat_mapper_ptr,262 first_cluster,263 page_index,264 &searched_cluster,265 &error );266 }267 268 if( error )269 {270 printk("\n[ERROR] in %s : cannot access FAT\n", __FUNCTION__ );271 return error;272 }273 274 // return success275 *cluster_index = searched_cluster;276 return 0;277 278 } // end fatfs_cluster_from_index()279 219 280 220 ////////////////////////////////////////////////////////////////////////////////////////// … … 400 340 uint8_t * buffer; 401 341 402 fatfs_dmsg("\n[INFO] %s : enter sfor fatfs_ctx = %x\n",342 fatfs_dmsg("\n[INFO] %s : enter for fatfs_ctx = %x\n", 403 343 __FUNCTION__ , fatfs_ctx ); 404 344 … … 414 354 "cannot allocate memory for 512 bytes buffer\n" ); 415 355 356 fatfs_dmsg("\n[INFO] %s : allocated 512 bytes buffer\n", __FUNCTION__ ); 357 416 358 // load the boot record from device 417 359 // using a synchronous access to IOC device 418 360 error = dev_ioc_sync_read( buffer , 0 , 1 ); 361 362 fatfs_dmsg("\n[INFO] %s : buffer loaded\n", __FUNCTION__ ); 419 363 420 364 assert( (error == 0) , __FUNCTION__ , … … 441 385 uint32_t sector_size = fatfs_get_record( BPB_BYTSPERSEC , buffer , 1 ); 442 386 443 nolock_assert( (sector_size == 512) , __FUNCTION__ ,444 387 assert( (sector_size == 512) , __FUNCTION__ , 388 "sector size must be 512 bytes\n" ); 445 389 446 390 // check cluster size from boot record 447 391 uint32_t nb_sectors = fatfs_get_record( BPB_SECPERCLUS , buffer , 1 ); 448 392 449 nolock_assert( (nb_sectors == 8) , __FUNCTION__ ,450 393 assert( (nb_sectors == 8) , __FUNCTION__ , 394 "cluster size must be 8 sectors\n" ); 451 395 452 396 // check number of FAT copies from boot record 453 397 uint32_t nb_fats = fatfs_get_record( BPB_NUMFATS , buffer , 1 ); 454 398 455 nolock_assert( (nb_fats == 1) , __FUNCTION__ ,456 399 assert( (nb_fats == 1) , __FUNCTION__ , 400 "number of FAT copies must be 1\n" ); 457 401 458 402 // get & check number of sectors in FAT from boot record 459 403 uint32_t fat_sectors = fatfs_get_record( BPB_FAT32_FATSZ32 , buffer , 1 ); 460 404 461 nolock_assert( ((fat_sectors & 0xF) == 0) , __FUNCTION__ ,462 405 assert( ((fat_sectors & 0xF) == 0) , __FUNCTION__ , 406 "FAT not multiple of 16 sectors\n"); 463 407 464 408 // get and check root cluster from boot record 465 409 uint32_t root_cluster = fatfs_get_record( BPB_FAT32_ROOTCLUS , buffer , 1 ); 466 410 467 nolock_assert( (root_cluster == 2) , __FUNCTION__ ,468 411 assert( (root_cluster == 2) , __FUNCTION__ , 412 "root cluster index must be 2\n"); 469 413 470 414 // get FAT lba from boot record … … 475 419 req.ptr = buffer; 476 420 kmem_free( &req ); 421 422 fatfs_dmsg("\n[INFO] %s : boot record read & released\n", 423 __FUNCTION__ ); 477 424 478 425 // allocate a mapper for the FAT itself … … 494 441 fatfs_ctx->last_allocated_index = 0; // TODO ??? 495 442 fatfs_ctx->fat_mapper_xp = XPTR( local_cxy , fat_mapper ); 443 444 fatfs_dmsg("\n[INFO] %s : exit for fatfs_ctx = %x\n", 445 __FUNCTION__ , fatfs_ctx ); 496 446 497 447 } // end fatfs_ctx_init() -
trunk/kernel/vfs/vfs.c
r271 r279 154 154 error_t error; 155 155 156 vfs_dmsg("\n[INFO] %s : enter / local_cluster = %x / parent_cluster = %x\n", 157 __FUNCTION__ , local_cxy , GET_CXY( dentry_xp ) ); 158 156 159 // check fs type and get pointer on context 157 160 if ( fs_type == FS_TYPE_FATFS ) ctx = &fs_context[FS_TYPE_FATFS]; … … 224 227 remote_rwlock_init( XPTR( local_cxy , &inode->data_lock ) ); 225 228 remote_spinlock_init( XPTR( local_cxy , &inode->main_lock ) ); 229 230 vfs_dmsg("\n[INFO] %s : enter / local_cluster = %x / parent_cluster = %x\n", 231 __FUNCTION__ , local_cxy , GET_CXY( dentry_xp ) ); 226 232 227 233 // return extended pointer on inode … … 1516 1522 parent_ptr = (vfs_inode_t *)GET_PTR( parent_xp ); 1517 1523 1524 vfs_dmsg("\n[INFO] %s : enter in cluster %x / child_cxy = %x / parent_cxy = %x\n", 1525 __FUNCTION__ , local_cxy , child_cxy , parent_cxy ); 1526 1518 1527 // 1. create dentry 1519 1528 if( parent_cxy == local_cxy ) // parent cluster is the local cluster … … 1523 1532 parent_ptr, 1524 1533 &dentry_xp ); 1534 1535 vfs_dmsg("\n[INFO] %s : dentry created in local cluster %x\n", 1536 __FUNCTION__ , local_cxy ); 1525 1537 } 1526 1538 else // parent cluster is remote … … 1532 1544 &dentry_xp, 1533 1545 &error ); 1546 1547 vfs_dmsg("\n[INFO] %s : dentry created in remote cluster %x\n", 1548 __FUNCTION__ , parent_cxy ); 1534 1549 } 1535 1550 … … 1558 1573 gid, 1559 1574 &inode_xp ); 1575 1576 vfs_dmsg("\n[INFO] %s : inode created in local cluster %x\n", 1577 __FUNCTION__ , local_cxy ); 1560 1578 } 1561 1579 else // child cluster is remote … … 1572 1590 &inode_xp, 1573 1591 &error ); 1592 1593 vfs_dmsg("\n[INFO] %s : inodecreated in remote cluster %x\n", 1594 __FUNCTION__ , child_cxy ); 1574 1595 } 1575 1596
Note: See TracChangeset
for help on using the changeset viewer.